我正在为我的项目使用 highcharts。我使用多个轴来绘制图表。我想要的是即使具有不同的值,固定的 x 轴上也应该有一条直线。
我想要像plotLines这样的东西,它是笔直的并固定在x轴上,但仍然显示我输入的不同值。
最佳答案
我会创建单独的系列来实现这一目标。我认为这比使用渲染器更简单的解决方案。演示:http://jsfiddle.net/6wo5mzo4/
(function(H) {
var seriesTypes = H.seriesTypes;
seriesTypes.fakeLine = Highcharts.extendClass(seriesTypes.line);
seriesTypes.fakeLine.prototype.translate = function() {
var s = this;
seriesTypes.line.prototype.translate.call(s);
H.each(s.points, function(point) {
point.plotY = s.chart.plotWidth / 2; // display in the middle - note: plotWidth, not plotHeight, because chart is inverted
});
}
})(Highcharts);
但是,我仍然怀疑这样的图表有多大用处。我还建议审查要求。
关于javascript - HighCharts:如何在多个轴上绘制直线,例如具有固定 X 轴且具有不同值的plotLines,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34044855/