0

anychart.theme(anychart.themes.darkEarth);

anychart.onDocumentReady(function () {

var dataSet = anychart.data.set([
    ['P1', 969.5, 2040, 1200, 1600,2000],
    ['P2', 779.1, 1794, 1124, 1724,4000],
    ['P3', 739.2, 2026, 1006, 1806,5000]
]);


var seriesData_1 = dataSet.mapAs({x: [0], value: [1]});


var seriesData_2 = dataSet.mapAs({x: [0], value: [2]});


var seriesData_3 = dataSet.mapAs({x: [0], value: [3]});


var seriesData_4 = dataSet.mapAs({x: [0], value: [4]});

 var seriesData_5 = dataSet.mapAs({x: [0], value: [5]});


chart = anychart.column();


chart.animation(true);


chart.container('container');


chart.title('Combination of Stacked Column and Line Chart (Dual Y-Axis)');

var scale = anychart.scales.linear();

scale.stackMode('value');


chart.column(seriesData_2);


var lineSeries = chart.area(seriesData_1);
lineSeries.yScale(scale);



var lineSeries2 = chart.area(seriesData_5);
lineSeries2.yScale(scale);


chart.column(seriesData_3);


chart.column(seriesData_4);


chart.draw();

});

我正在尝试添加带有堆积区域的系列柱形图。但是 Series Column 和 Stacked Area 应该有不同的 Scales 以使它们与 Stacking 分开。如何将这两个 Scales 整合到 Yaxis 中。有什么办法吗?请建议!

4

1 回答 1

1

我认为您可以使用图表左侧或右侧的附加轴。

左轴示例:

var secondYAxis = chart.yAxis(1).scale(scale);

http://jsfiddle.net/cgquc1pz/1/

右轴示例:

var secondYAxis = chart.yAxis(1).scale(scale);
secondYAxis.orientation('right');

http://jsfiddle.net/cgquc1pz/2/

于 2017-04-20T14:47:05.657 回答