VizFrame Combination Chart with Multiple Y-Axis

I have a problem with the VizFrame control for the SAPUI5 platform. I want to display some data in a complex diagram with two Y-axes. My data model is as follows:

{
      "d" : {
        "results" : [
          {
            "DataA" : "2",
            "DataB" : "4",
            "Id" : "1",
          },
          {
            "DataA" : "3",
            "DataB" : "2",
            "Id" : "2",
          }
       ]
   }
}

I tried to display DataA on the left of Y-Axis and DataB on the right, using Id for the X-axis. This works without problems with the VizFrame types: dual_line and dual_column .

I did not find a way to display the data as a string (DataA on Y1) and a string (DataB on Y2). My current encoding looks like this:

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

        oModel.loadData("data.json");

        var oDataset = new sap.viz.ui5.data.FlattenedDataset({              
            dimensions: [{
                axis : 2,
                name : oLocText.getText('Id'),
                value : "{Id}"
            }],         
            measures : [{
                    group : 1,
                    name : DataA,
                    value : '{DataA}'
                },{
                    group : 2,
                    name: DataB,
                    value: '{DataB}'
                }],
            data : {
                path : "/d/results"
            }
        }); 

        oVizFrame.setDataset(oDataset);
        oVizFrame.setModel(oModel); 
        oVizFrame.setVizType('combination');

        oVizFrame.setVizProperties({
            title: {
                  visible: true,
                  text: "Combined"
              },            
            plotArea: {
                colorPalette : d3.scale.category20().range(),
            }});

        var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
              'uid': "primaryValues",
              'type': "Measure",
              'values': [ DataA , DataB]
            }),
            feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
              'uid': "axisLabels",
              'type': "Dimension",
              'values': [ Id]
            });

        oVizFrame.addFeed(feedValueAxis);
        oVizFrame.addFeed(feedCategoryAxis); 

Many thanks for your help!

+4
source share
2 answers

Try:

var feedValueAxis1 = new sap.viz.ui5.controls.common.feeds.FeedItem({
              'uid': "valueAxis",
              'type': "Measure",
              'values': [ DataA ]
            }), feedValueAxis2 = new sap.viz.ui5.controls.common.feeds.FeedItem({
              'uid': "valueAxis2",
              'type': "Measure",
              'values': [DataB]
            }),

plot DataA left axis DataB right axis .

, SAPUI5 1.40.

0

, . , /. , , dataShape plotArea:

oVizFrame.setVizProperties({
    plotArea: { dataShape : {primaryAxis : ['bar','bar','bar'],
                            secondaryAxis : ['line', 'line', 'line']}}
});

3 1 2. , , , , . . : "" "" ( , ). , Sebastian

0

Source: https://habr.com/ru/post/1650008/


All Articles