我正在使用ng2-chart
库(基于ChartJS),并且试图创建具有多个y轴的堆叠条形图。这是我到目前为止的内容:
我希望左侧的堆积条沿左侧的y轴,而右侧的堆积条沿右侧的y轴。
但是如您所见,图表运行不正常。橙色数据跟随右侧的y轴,蓝色数据跟随左侧的y轴。
我该如何做到?
这是我的代码:
// CHART LABELS
chartLabels: string[] = [
'Commissions Earned',
'Lots Traded'
];
// CHART OPTIONS
chartOptions = {
responsive: true,
responsiveAnimationDuration: 0,
scales: {
yAxes: [
{
id: 'y-axis-0',
position: 'left',
scaleLabel: {
display: true,
labelString: 'probability'
}
},
{
id: 'y-axis-1',
position: 'right',
}
]
}
};
// CHART DATA
this.chartData = [
{
// Data is for Commissions, followed by Lots traded
data: variableAccounts,
label: 'Fixed/Variable Accounts',
stack: 'a',
yAxisID: 'y-axis-0'
},
{
// Data is for Commissions, followed by Lots traded
data: ecnAccounts,
label: 'ECN Premier Accounts',
stack: 'a',
yAxisID: 'y-axis-1'
},
];