Skip to Content
avatar image
Former Member

VizChart on dialog in SAP UI5

I am trying to add a Viz chart on my Dialog Box in SAP UI5, but nothings gets displayed. Here is my code, can someone please help! I added a dialog box on a press which is working fine. Even i put alerts in various part just to check if the code is running proper. There is no error, still i dont see the chart in dialog box.

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();

    },
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Sep 20, 2017 at 06:38 AM

    i followed a previous question trail, which provides a solution. https://archive.sap.com/discussions/thread/3809882 But when i used .rendered() it throws me an error: Cannot read property 'rerender' of undefined

    Add comment
    10|10000 characters needed characters exceeded