争取有两个具有相同x和y值的数据点的行为类似于stackedColumn图表类型,即彼此重叠

时间:2017-02-20 13:34:53

标签: canvasjs

我有以下示例与具有相同的x一些点的数据的,y值,这意味着它们覆盖在彼此的柱形图中apear - 有使他们出现stcked在彼此的顶部上像在stackedColumn图表的方式类型。

参见工作示例:http://jsfiddle.net/yjxoLr9e/

部分json数据:

"purchaseRows": [
{x: new Date("2017-03-10"), y:600},
{x: new Date("2017-04-06"), y:504},
{x: new Date("2017-04-06"), y:600},
{x: new Date("2017-05-03"), y:504},
{x: new Date("2017-05-03"), y:504},
{x: new Date("2017-06-05"), y:504},
{x: new Date("2017-08-07"), y:714},
{x: new Date("2017-09-04"), y:714},
{x: new Date("2017-10-02"), y:504},
{x: new Date("2017-11-06"), y:504},
{x: new Date("2017-12-04"), y:540},
],

和数据数组:

data: [     { type: "stepLine", showInLegend: true, lineThickness: 2, name: "Transactions", markerSize: 5, markerType: "circle", color: "SteelBlue", dataPoints: json.transactionData },
                    { type: "stepLine", lineDashType: "dot", showInLegend: true, lineThickness: 2, name: "Stock forecast", markerSize: 5, markerType: "circle", color: "SteelBlue", dataPoints: json.stockForecast },
                    { type: "stackedColumn", showInLegend: true, lineThickness: 0, name: "Backlog", markerSize: 8, markerType: "circle", color: "coral", dataPoints: json.currentbacklog },
                    { type: "stackedColumn", showInLegend: true, lineThickness: 0, name: "Demand", markerSize: 8, markerType: "circle", color: "red", dataPoints: json.unconsumedFcst },
                    { type: "line", showInLegend: true, lineThickness: 0, name: "Stock", markerSize: 8, markerType: "circle", color: "red", dataPoints: json.currentStock },
                    { type: "column", showInLegend: true, lineThickness: 2, name: "Purchase rows", markerSize: 8, markerType: "circle", color: "lightgreen", dataPoints: json.purchaseRows }

        ],

1 个答案:

答案 0 :(得分:1)

Beevk是正确的图表类型stackedColumn dors的技巧。