Anychart:如何结合跳转线和多系列柱形图?
Anychart: how to combine Jump line and multiseries column chart?
我正在尝试将跳转线与多系列柱形图结合起来。是否可以专门为多系列柱形图的每一列创建一条跳线?现在我唯一可以获得的是每组数据集的跳转线,这是一个例子:
anychart.onDocumentReady(function () {
var data = [
["January", 12000, 10000, 8100],
["February", 15000, 12000, 8200],
["March", 16000, 18000, 8300],
];
var dataSet = anychart.data.set(data);
var mapping1 = dataSet.mapAs({x: 0, value: 1});
var mapping2 = dataSet.mapAs({x: 0, value: 2});
var jump1 = dataSet.mapAs({x: 0, value: 3});
// create a chart
var chart = anychart.column();
// create the series and set the data
var series1 = chart.column(mapping1);
var series2 = chart.column(mapping2);
var series3 = chart.jumpLine(jump1);
series3.stroke("3 #FFFF00");
chart.container("container");
chart.draw();
});
如果我的理解正确,那么您可以创建一个额外的 xScale 和 xAxis。然后将跳跃系列绑定到该附加比例。这里是 the live sample based on your code.
如果有人需要这个,感谢 @AnyChart Support 的回答,这里是合并这两个图表的代码。
anychart.onDocumentReady(function () {
var data = [
["January", 12000, 10000],
["February", 15000, 12000],
["March", 16000, 18000],
];
var jumpData = [
['January_1', 1000],
['January_2', 3000],
['February_1', 5000],
['February_2', 6000],
['March_1', 5000],
['March_2', 7500],
];
var dataSet = anychart.data.set(data);
var jumpDataSet = anychart.data.set(jumpData);
var mapping1 = dataSet.mapAs({x: 0, value: 1});
var mapping2 = dataSet.mapAs({x: 0, value: 2});
var jump1 = jumpDataSet.mapAs({x: 0, value: 1});
// create a chart
var chart = anychart.column();
chart.barGroupsPadding(1);
// Set the padding between bars or columns.
chart.barsPadding(1);
// create the series and set the data
var series1 = chart.column(mapping1);
var series2 = chart.column(mapping2);
var additionalXscale = anychart.scales.ordinal();
chart.xAxis(1).scale(additionalXscale).enabled(false);
var series3 = chart.jumpLine(jump1);
series3.pointWidth('60%');
series3.xScale(additionalXscale);
series3.stroke("5 #00FF00");
series3.name = "AAA"
chart.container("container");
chart.draw();
});
我正在尝试将跳转线与多系列柱形图结合起来。是否可以专门为多系列柱形图的每一列创建一条跳线?现在我唯一可以获得的是每组数据集的跳转线,这是一个例子:
anychart.onDocumentReady(function () {
var data = [
["January", 12000, 10000, 8100],
["February", 15000, 12000, 8200],
["March", 16000, 18000, 8300],
];
var dataSet = anychart.data.set(data);
var mapping1 = dataSet.mapAs({x: 0, value: 1});
var mapping2 = dataSet.mapAs({x: 0, value: 2});
var jump1 = dataSet.mapAs({x: 0, value: 3});
// create a chart
var chart = anychart.column();
// create the series and set the data
var series1 = chart.column(mapping1);
var series2 = chart.column(mapping2);
var series3 = chart.jumpLine(jump1);
series3.stroke("3 #FFFF00");
chart.container("container");
chart.draw();
});
如果我的理解正确,那么您可以创建一个额外的 xScale 和 xAxis。然后将跳跃系列绑定到该附加比例。这里是 the live sample based on your code.
如果有人需要这个,感谢 @AnyChart Support 的回答,这里是合并这两个图表的代码。
anychart.onDocumentReady(function () {
var data = [
["January", 12000, 10000],
["February", 15000, 12000],
["March", 16000, 18000],
];
var jumpData = [
['January_1', 1000],
['January_2', 3000],
['February_1', 5000],
['February_2', 6000],
['March_1', 5000],
['March_2', 7500],
];
var dataSet = anychart.data.set(data);
var jumpDataSet = anychart.data.set(jumpData);
var mapping1 = dataSet.mapAs({x: 0, value: 1});
var mapping2 = dataSet.mapAs({x: 0, value: 2});
var jump1 = jumpDataSet.mapAs({x: 0, value: 1});
// create a chart
var chart = anychart.column();
chart.barGroupsPadding(1);
// Set the padding between bars or columns.
chart.barsPadding(1);
// create the series and set the data
var series1 = chart.column(mapping1);
var series2 = chart.column(mapping2);
var additionalXscale = anychart.scales.ordinal();
chart.xAxis(1).scale(additionalXscale).enabled(false);
var series3 = chart.jumpLine(jump1);
series3.pointWidth('60%');
series3.xScale(additionalXscale);
series3.stroke("5 #00FF00");
series3.name = "AAA"
chart.container("container");
chart.draw();
});