是否可以设置子刻度间隔?我只需要在 Y 轴的第一个间隔内有一个差异为 50 的刻度,而 Y 轴的刻度有一个差异为 250 的刻度。
如果 Y 轴的最大值为 1500,则 Y 轴将具有以下间隔:
0、250、500、750、1000、1250、1500
。
在 0 - 250 范围内,我想要 0, 50, 100, 150, 200, 250
因此 Y 轴上的间隔应如下所示:
0、50、100、150、200、250、500、750、1000、1250、1500
。
function loadColumnBarChart(Hired, Scrned, AllTimPreQulfd, Qualfid, AllTimSAD, SAD, SMD, Aprvd, pndin) {
$('#chartMain').highcharts({
chart: {
type: 'column'
},
title: {
text: Data Flow'
},
xAxis: {
categories: [
'Hired',
'Screened',
'Pre-Qualified',
'Submitted All Docs',
'Submittted Missing Docs',
'Approved',
'Pending'
],
crosshair: true
},
yAxis: {
min: 0,
tickInterval: 250,
// tickPixelInterval: 50,
title: {
text: 'Employees'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} </b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Current Status',
data: [Hired, Scrned, Qualfid, SAD, SMD, Aprvd, pndin]
}, {
name: 'Total Amount',
data: [Hired, Scrned, AllTimPreQulfd, AllTimSAD, SMD, Aprvd, pndin]
}]
});
}
最佳答案
这是一个基于文档的粗略示例,您可以根据需要进行清理:
代码:
yAxis: {
min: 0,
max: 1500,
tickPositioner: function() {
var positions = [],
tick = 0,
increment1 = 50,
increment2 = 250;
for (tick; tick < 250; tick += increment1) {
positions.push(tick);
}
for (tick; tick - increment2 < this.max; tick += increment2) {
positions.push(tick);
}
return positions;
}
}
fiddle :
引用:
关于javascript - tickInterval 区间内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38489913/