Skip to Content
avatar image
Former Member

How to create Dynamic Measure Legend/Value

I am creating an XML view in SAPUI5, where i am using VizFrame Chart. I gave the "Measure" value a hard coded name as i am not sure how to make it dynamic as per user select. The use case is on select, the measure value/legend on the chart should change as per the selected item.

The XML code:

<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}" vizProperties="{ title: {text : 'Energy', visible : true}, plotArea: {dataLabel:{visible: true} ,colorPalette : ['#eab64d','#cb8589'] }}" height='100%' width="100%" vizType='line'> <viz:dataset> <viz.data:FlattenedDataset data="{/T_TABLE}"> <viz.data:dimensions> <viz.data:DimensionDefinition name="Timeline" value="{ path: 'C_READINGTIMESTAMP', type: 'sap.ui.model.type.Date', formatOptions: { pattern : 'dd/MM hh a' }}" /> </viz.data:dimensions> <viz.data:measures> <viz.data:MeasureDefinition name="Value" value="{C_READINGVALUE}" /> </viz.data:measures> </viz.data:FlattenedDataset> </viz:dataset> <viz:feeds> <viz.feeds:FeedItem id='valueAxisFeed' uid="valueAxis" type="Measure" values="Value" /> <viz.feeds:FeedItem id='categoryAxisFeed' uid="categoryAxis" type="Dimension" values="Timeline" /> </viz:feeds> </viz:VizFrame>

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Aug 09, 2017 at 05:12 PM

    Based on the selected item you want to update the measure....

    On item select event handler destroy dataset and feeds from the chart using below code:

    var oVizFrame = this.getView().byId("idVizFrame");
    oVizFrame.destroyDataset();
    oVizFrame.destroyFeeds();
    

    Create new dataset and feeds

    //New dataset
    oVizFrame.setDataset(new sap.viz.ui5.data.FlattenedDataset({
       dimensions: [{
            name : 'Timeline',
            value: "{ path: 'C_READINGTIMESTAMP', type: 'sap.ui.model.type.Date', formatOptions: { pattern : 'dd/MM hh a' } }"
       }],
       measures: [{
            name: 'Value',
            value: '{C_READINGVALUE}'
      }]
    }));
    
    //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"]
    }));
    Add comment
    10|10000 characters needed characters exceeded