highcharts上的次y轴位置不正确
我正在尝试使用HighCharts创建一个图表,其中次Y轴位置不正确。随着数据串联修改,次轴不断移动。这仅在3D图表的情况下发生。在以下示例中:highcharts上的次y轴位置不正确,highcharts,Highcharts,我正在尝试使用HighCharts创建一个图表,其中次Y轴位置不正确。随着数据串联修改,次轴不断移动。这仅在3D图表的情况下发生。在以下示例中: $(function () { var title="Sales($ '000)"; $('#BatChart_CP1').highcharts({ chart: { margin: 75, options3d: { enabled: true, alpha: 15, beta: 8, depth: 60, vi
$(function () {
var title="Sales($ '000)";
$('#BatChart_CP1').highcharts({
chart: {
margin: 75,
options3d: {
enabled: true,
alpha: 15,
beta: 8,
depth: 60,
viewDistance: 35
}
},
title: {
text: ''
},
xAxis: [{
categories: ['Q1','Q2','Q3','Q4'],
lineColor: '#000',
min: 0,
lineWidth: 1,
labels: {
style: {
font: '12px Arial',
color: 'black'
}
}, min: 0,
}],
yAxis: [{ // Primary yAxis
title: {
text: 'Sales($' + "'" + '000)',
style: {
font: '12px Arial',
color: 'black'
}
}, min: 0,
labels: {
style: {
font: '12px Arial',
color: 'black'
}
},
lineColor: '#000',
lineWidth: 1,
}, { // Secondary yAxis
title: {
text: '% of Franchise Sales',
style: {
font: '12px Arial',
color: 'black'
}
},
labels: {
formatter: function () {
return this.value + '%';
},
style: {
font: '12px Arial',
color: 'black'
}
},
offset:100,
min: 0,
lineColor: '#000',
lineWidth: 1,
opposite: true
}],
tooltip: {
shared: true
},
plotOptions: {
column: {
pointPadding: 0,
borderWidth: 0,
depth: 20,
dataLabels: {
enabled: true,
rotation: -90,
color: 'White',
align: 'right',
format: '{point.y}', // one decimal
y: 5, // 10 pixels down from the top
style: {
font: 'bold 13px Arial ',
textShadow: '0 0 0px black'
}
}
},
series: {
pointWidth: 35
}
},
series: [{ name: 'ACT ',type: 'column', data: [641,627,null,null], color: '#0070C0' },
{ name: 'BUD ',type: 'column', data: [128,88,60,82], color: 'rgb(230, 81, 0)' },
{ name: '% of Franchise Sales',type: 'spline',yAxis: 1,zIndex:999,data: [6.3,11.5,null,null],tooltip: {valueSuffix: '%'},color: '#b71c1c'}]
});
});
您可以使用偏移参数和对齐Y轴
offset:100
示例:可以使用x和y位置作为副轴上的标题和标签,例如以下示例:
// Secondary yAxis
title: {
text: '% of Sales',
style: {
font: '12px Arial',
color: 'black'
},
x:-120
},
labels: {
formatter: function () {
return this.value + '%';
},
style: {
font: '12px Arial',
color: 'black'
},
x:120
},
如果我们添加偏移量,则标题文本在辅助y轴上不可见。如果数据在系列中更改,则辅助轴在偏移量为100时不可见。您可以在此处尝试。您可以通过以下链接检查相同的内容。