Quantcast
Channel: SCN : Discussion List - SAP Fiori
Viewing all articles
Browse latest Browse all 1804

Setting data to chart using odata service

$
0
0

Hi experts,

 

I am trying to set data in chartcontainer   in my fiori application, i am using odata service from my xs application to feed data,

Code for my view is

 

<core:View

    controllerName="sap.ui.demo.wt.controller.ChartContainer"

    xmlns="sap.suite.ui.commons"

    xmlns:m="sap.m"

    xmlns:mvc="sap.ui.core.mvc"

    xmlns:viz="sap.viz.ui5.controls"

    xmlns:layout="sap.ui.layout"

    xmlns:core="sap.ui.core">

    <layout:Splitter width="100%" height="100%">

    <layout:contentAreas>

    <ChartContainer

        id="idChartContainer"

        showFullScreen="true"

        showPersonalization="false"

        autoAdjustHeight="false"

        showLegend="true"

        personalizationPress="attachPersonalizationPress"

        contentChange="attachContentChange"

        title="Revenue">

 

      

        <content>

            <ChartContainerContent

                   icon = "sap-icon://bubble-chart"

                title = "Bubble Chart">

                <content>

                    <viz:VizFrame id="idoVizFrame" height="700px" width="100%" uiConfig="{applicationSet:'fiori'}"> </viz:VizFrame>

                </content>

            </ChartContainerContent>      

        </content>  

    </ChartContainer>

    </layout:contentAreas>

    </layout:Splitter>  

</core:View>

 

Code for my controller is



sap.ui.controller("sap.ui.demo.wt.controller.ChartContainer", {

  

    onInit: function() {

      

        var url ="/destinations/XXXX/services.xsodata/XXX(XXXXXXX) + ")/Results/?$format=json";

        var  oModel_bl = new sap.ui.model.json.JSONModel();

         oModel_bl.loadData(url);

        //alert(url);

        /*var oModel = new sap.ui.model.json.JSONModel("/destinations/XXXX/services.xsodata/XXX(XXXXXXX) + ")/Results/?$format=json");*/

  

oModel_bl.attachRequestFailed(function() { alert("OData Request Failed!"); });

 

 

 

        oModel_bl.attachRequestCompleted(function() {

 

            alert(oModel_bl.getJSON());

 

 

        });

          

        var oVizFrame = this.getView().byId("idoVizFrame");

 

      

          

            var oDataset_bl = new sap.viz.ui5.data.FlattenedDataset({

            

               dimensions: [{

                                  

                                    name: 'PD_DESC', // 'name' is used as label in the Legend

                                    value: '{PD_DESC}' // 'value' defines the binding for the displayed value 

                                }],

               measures: [

                 {

                

                name: 'CNT', // 'name' is used as label in the Legend

                    value: '{CNT}'

                 }

               ],

               data: {

                 path: "/d/results"

               }

             

             });

        

         oVizFrame.setVizProperties({

              plotArea: {

                showGap: true

              }/*,

            title : {

                visible : false,

                text : 'Revenue'

      }             */

            });

            oVizFrame.setDataset(oDataset_bl);

            //oVizFrame.setModel(oModel_bl);

            //alert(oModel_bl);

            oVizFrame.setModel(oModel_bl);

 

            var feedPrimaryValues_bl7 = new sap.viz.ui5.controls.common.feeds.FeedItem({

              'uid' : "primaryValues",

              'type' : "Measure",

//              'values' : ["Profit", "Revenue"]

              'values' : ["CNT"]

            }), feedAxisLabels_bl7 = new sap.viz.ui5.controls.common.feeds.FeedItem({

              'uid' : "axisLabels",

              'type' : "Dimension",

              'values' : ["PD_DESC"]

            })/*,

            feedTargetValues_bl7 = new sap.viz.ui5.controls.common.feeds.FeedItem({

              'uid' : "targetValues",

              'type' : "Measure",

              'values' : ["CNT"]

            })*/;

 

            oVizFrame.addFeed(feedPrimaryValues_bl7);

            oVizFrame.addFeed(feedAxisLabels_bl7);

            //oVizFrame.addFeed(feedTargetValues_bl7);

            oVizFrame.setVizType('bar');

            //oVizFrame.setUiConfig({'applicationSet': 'fiori'});

          

 

    }

 

/*    attachPersonalizationPress : function(oE) {

        sap.m.MessageToast.show("Personlainzation event was fired.");

    },

    attachContentChange : function(evt){

        var itemId = evt.getParameter("selectedItemId");

        sap.m.MessageToast.show("ContentChange event was fired. Selected Item was changed to:" + itemId);

    }*/

 

});

 

Output



sc99.png

 

sc100.png

 

Thanks


Viewing all articles
Browse latest Browse all 1804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>