Highchart - 多轴对齐不适用于多个测试

时间:2015-12-03 20:45:18

标签: javascript css charts highcharts report

我使用此函数来实现轴对齐:

(function (H) {
var Axis = H.Axis,
inArray = HighchartsAdapter.inArray,
wrap = H.wrap;

wrap(Axis.prototype, 'adjustTickAmount', function (proceed) {
debugger;
var chart = this.chart,
primaryAxis = chart[this.coll][0],
primaryThreshold,
primaryIndex,
index,
newTickPos,
threshold,
// Find the index and return boolean result
isAligned = function (axis) {
index = inArray(threshold, axis.tickPositions); // used in while-loop
return axis.tickPositions.length === axis.tickAmount && index === primaryIndex;
};

if (chart.options.chart.alignThresholds && this !== primaryAxis) {
debugger;
primaryThreshold = (primaryAxis.series[0] && primaryAxis.series[0].options.threshold) || 0;
threshold = (this.series[0] && this.series[0].options.threshold) || 0;

primaryIndex = primaryAxis.tickPositions && inArray(primaryThreshold, primaryAxis.tickPositions);

if (this.tickPositions && primaryIndex > 0 && primaryIndex < primaryAxis.tickPositions.length - 1) {
// Add tick positions to the top or bottom in order to align the threshold
// to the primary axis threshold
if (this.tickAmount) {
while (!isAligned(this)) {

if (index < primaryIndex) {
newTickPos = this.tickPositions[0] - this.tickInterval;
this.tickPositions.unshift(newTickPos);
this.min = newTickPos;
} else {
newTickPos = this.tickPositions[this.tickPositions.length - 1] + this.tickInterval;
this.tickPositions.push(newTickPos);
this.max = newTickPos;
}
proceed.call(this);
}
}
}

} else {
proceed.call(this);
}
});
}(Highcharts));
})

enter image description here

如果我的所有多轴图表都在1列上,那么它可以正常工作,但如果我在屏幕截图中有多列图表,它就无法正常工作。我该如何解决这个问题?

0 个答案:

没有答案