【问题标题】:VizChart on dialog in SAP UI5SAP UI5 中对话框上的 VizChart
【发布时间】:2017-09-20 17:42:11
【问题描述】:

我正在尝试在 SAP UI5 的对话框中添加可视化图表,但没有显示任何内容。这是我的代码,有人可以帮忙!我在工作正常的印刷机上添加了一个对话框。即使我在各个部分都设置了警报,只是为了检查代码是否运行正常。没有错误,我仍然没有在对话框中看到图表。

    pressTemp: function() {
        var oView = this.getView();
        var oDialog = oView.byId("helloSiteDialog");

        // create dialog lazily
        if (!oDialog) {

            // create dialog via fragment factory
            oDialog = sap.ui.xmlfragment(oView.getId(), "Hari_At_Work.view.HelloSiteDialog", this);
            var oVizFrame = this.getView().byId("idVizFrame");

            oVizFrame.destroyDataset();
            oVizFrame.destroyFeeds();

            console.log("chart here");

            //New dataset
            oVizFrame.setDataset(new sap.viz.ui5.data.FlattenedDataset({
                dimensions: [{
                    name: 'Timeline',
                    value: "{Country}"
                }],
                measures: [{
                    name: 'Value',
                    value: '{revenue}'
                }],
                data : {
    path : "/businessData"
} 
            }));

            alert("Dataset found");

            //Add feeds
            oVizFrame.addFeed(new sap.viz.ui5.controls.common.feeds.FeedItem({
                uid: "categoryAxis",
                type: "Dimension",
                values: ["Timeline"]
            }));

            oVizFrame.addFeed(new sap.viz.ui5.controls.common.feeds.FeedItem({
                uid: "valueAxis",
                type: "Measure",
                values: ["Value"]
            }));

        //  oVizFrame.setModel(sap.ui.getCore().getModel());

            var oModel = new sap.ui.model.json.JSONModel({
                businessData: [{
                    Country: "Canada",
                    revenue: 410.87,
                    profit: -141.25,
                    population: 34789000
                }, {
                    Country: "China",
                    revenue: 338.29,
                    profit: 133.82,
                    population: 1339724852
                }, {
                    Country: "France",
                    revenue: 487.66,
                    profit: 348.76,
                    population: 65350000
                }, {
                    Country: "Germany",
                    revenue: 470.23,
                    profit: 217.29,
                    population: 81799600
                }, {
                    Country: "India",
                    revenue: 170.93,
                    profit: 117.00,
                    population: 1210193422
                }, {
                    Country: "United States",
                    revenue: 905.08,
                    profit: 609.16,
                    population: 313490000
                }]
            });

            oVizFrame.setModel(oModel);
            alert("Model found");

            oView.addDependent(oDialog);

        }

        oDialog.open();
    //  oVizFrame.invalidate();

    },

我的片段 XML 代码:

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:l="sap.ui.layout"  xmlns:viz.feeds="sap.viz.ui5.controls.common.feeds"
xmlns:viz.data="sap.viz.ui5.data"  xmlns:viz="sap.viz.ui5.controls" xmlns:fb="sap.ui.comp.filterbar">




<Dialog id="helloSiteDialog" title="Temperature Trend">


    <viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
            height='100%' width="100%" vizType='column'>
            <viz:dataset>
                <viz.data:FlattenedDataset data="{/businessData}">
                    <viz.data:dimensions>
                        <viz.data:DimensionDefinition name="Name"
                            value="{Country}" />
                    </viz.data:dimensions>
                    <viz.data:measures>
                        <viz.data:MeasureDefinition name="Revenue"
                            value="{revenue}" />
                        <viz.data:MeasureDefinition name="Cost"
                            value="{Cost}" />
                    </viz.data:measures>
                </viz.data:FlattenedDataset>
            </viz:dataset>

            <viz:feeds>
                <viz.feeds:FeedItem id='valueAxisFeed' uid="valueAxis" type="Measure"
                    values="Revenue" />
                <viz.feeds:FeedItem id='categoryAxisFeed' uid="categoryAxis" type="Dimension"
                    values="Name" />
            </viz:feeds>
        </viz:VizFrame>




    <beginButton>
        <Button text="Close" press="onCloseSiteDialog"/>
    </beginButton>
</Dialog>

【问题讨论】:

    标签: dialog sapui5


    【解决方案1】:

    还粘贴视图和片段代码..我已经尝试过您的代码。地图显示给我看 plunkr 中的示例。您是否在控制台中遇到任何错误? Plunk of vizframe

    我用过popover.所以代码的变化只是

    oDialog.openBy(btn);
    

    【讨论】:

    • 片段只有一个普通的 VizChart 代码,带有id="idVizFrame"。我的观点实际上与控件无关。这一切都发生在新闻行动上。例如考虑点击按钮。
    • 是的,代码很好。正如我所说,如果我在不同的视图(页面)中使用它,它就可以工作。但在对话框中它没有出现。要求是在对话框中显示!
    • 在 plunker 代码中,图表仅显示一次。如果我第二次点击,没有图表。
    • 那是因为 id 重复。当第二次点击片段时,尝试添加相同的 viz,id 为 oViz
    • 如何停止相同的 viz id 情况?此外,即使在使用 Popover 之后,我的图表也没有显示。它不工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 2016-07-18
    • 2023-04-07
    • 2017-02-27
    • 1970-01-01
    相关资源
    最近更新 更多