如何在条形图中获取多个维度 - SAPUI5 VizFrame

时间:2017-08-31 12:16:07

标签: charts sapui5 bar-chart

我是SAPUI5的新用户,我正在尝试使用VizFrame在条形图中获取多个维度。我需要显示图表,如下图所示:

请查看我的code

2 个答案:

答案 0 :(得分:1)

我认为您正在寻找条形图来显示金额与天数

以下是working link.

我已更新 _setupChart 方法,如下所示。

_setupChart: function() {
    var oVizFrame = this.getView().byId("idVizFrame");
    oVizFrame.setModel(new JSONModel('./data.json'));
    var oDataset = new sap.viz.ui5.data.FlattenedDataset({
        dimensions: [{
            name: "Days",
            value: "{Days}"
        }],
        measures: [{
            name: "Amount",
            value: "{Amount}"
        }],
        data: {
            path: "/dueDays"
        }
   });
   oVizFrame.setDataset(oDataset);
   oVizFrame.setVizType('bar');
   var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
       "uid": "valueAxis",
       "type": "Measure",
       "values": ["Amount"]
   });
   var feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
       "uid": "categoryAxis",
       "type": "Dimension",
       "values": ["Days"]
   });
   oVizFrame.addFeed(feedValueAxis);
   oVizFrame.addFeed(feedCategoryAxis);
}

我还更新了数据json,如下所示

{
    "dueDays": [{  
        "Days": "Current",
        "Amount": "44334.00"
      }, {          
        "Days": "1 to 30",
        "Amount": "53454.00"
      }, {          
        "Days": "31 to 60",
        "Amount": "34443.65"
      }, {          
        "Days": "61 to 90",
        "Amount": "65554.43"
      }, {          
        "Days": "91 to 120",
        "Amount": "43524.00"
      },{           
        "Days": "121 to 150",
        "Amount": "54554.00"
      }, {          
        "Days": "151 to 180",
        "Amount": "43324.00"
      }, {          
        "Days": "Above 180",
        "Amount": "54355"
    }]
}

答案 1 :(得分:0)

感谢您的工作和帮助;时间 !! ..我使用setVizProperties> plotArea> dataPointStyle>规则..这是更新的link