堆积柱与线结合

Stacked Column combined with Line

我们需要显示堆叠柱形图和折线图,并希望坚持使用 UI5 提供的 VizFrame 控件。有没有办法做到这一点?它没有在示例中列出 (https://sapui5.netweaver.ondemand.com/sdk/explored.html#/entity/sap.viz.ui5.controls.VizFrame/samples),但也许有办法做到这一点。

编辑

我们需要显示的数据格式如下:

var data = [
    {week: 1, stacked1: 10, stacked2: 20, stacked3: 30, line: 100},
    {week: 2, stacked1: 12, stacked2: 13, stacked3: 14, line: 40},
    {week: 3, stacked1: 14, stacked2: 25, stacked3: 26, line: 20},
    {week: 4, stacked1: 15, stacked2: 24, stacked3: 33, line: 52}
];

所以我的想法是在 x 轴上设置周数,一个堆叠条表示值 stacked1、stacked2 和 stacked3 以及该线的一个值点。

我认为您想在 VizFrame 上使用 setVizType("stacked_combination") [或 vizType: "stacked_combination"]。您可以在 getVizType() VizFrame 文档中看到所有类型。这是一个简单的例子,我扩展了 VizFrame 并添加了两个函数来显示堆积柱形图:

sap.viz.ui5.controls.VizFrame.extend("jonova.ui5.chart.JuVizFrame", {
  renderer: { },

  setLineStackedBar: function() {
    var oModel = new sap.ui.model.json.JSONModel(
            [{Product:"Total",  Date: 2000, Available: 100},
             {Product:"Total",  Date: 2001, Available: 100},
             {Product:"P1",         Date: 2000, Utilized:  30},
             {Product:"P1",         Date: 2001, Utilized:  20},
             {Product:"P2",         Date: 2000, Utilized:  40},
             {Product:"P2",         Date: 2001, Utilized:  60}]);
    var oDataset = new sap.viz.ui5.data.FlattenedDataset({
        dimensions: [{name: 'Date',      value: '{Date}'},
                     {name: 'Product',   value: '{Product}'}],
        measures:   [{name: 'Available', value: '{Available}'},
                     {name: 'Utilized',  value: '{Utilized}' }],
        data:        {path: "/"}});
    var oFeeds = [new sap.viz.ui5.controls.common.feeds.FeedItem({uid: "valueAxis",    type: "Measure",   values: ["Utilized", "Available"]}),
                  new sap.viz.ui5.controls.common.feeds.FeedItem({uid: "categoryAxis", type: "Dimension", values: ["Date"]}),
                  new sap.viz.ui5.controls.common.feeds.FeedItem({uid: "color",        type: "Dimension", values: ["Product"]})];
    this.setChart("stacked_combination", oDataset, oModel, oFeeds);
  },

  setChart: function(aVizType, aDataset, aModel, aFeeds) {
    this.setVizType(aVizType);
    this.setDataset(aDataset);
    this.setModel(aModel);
    for( var i=0, len=aFeeds.length; i<len; i++) this.addFeed(aFeeds[i]);
  },
});