我在chartJs上有一个示例。将鼠标悬停在图表上时,会出现两行。
var data_set = [{x: 1, y: 12}, {x: 2, y: 3}, {x: 3, y: 2}, {x: 4, y: 1}, {x: 5, y: 8}, {x: 6, y: 8}, {x: 7, y: 2}, {x: 8, y: 2}, {x: 9, y: 3}, {x: 10, y: 5}, {x: 11, y: 11}, {x: 12, y: 1}];
//draw lines on yAxis.
addLine(3.5);
addLine(7);
在此示例中y
,data_set的坐标不在addLines的下面。但是当我将data_set的第一个索引更改为y:12
toy:1
并像这样绘制线时addLine(11.5)
,图表会重新缩放以使其始终在边界内。我想破坏这种行为。我从不希望它成为重新调整悬停状态。该怎么做?
小提琴上的示例:https : //jsfiddle.net/ckhf0q9g/
你搞砸了轴刻度。这些标尺可以正常工作:
scales: {
xAxes: [{
id: 'x-axis',
type: 'linear',
position: 'bottom',
ticks: {
stepSize: 1,
callback: function(value, index, values) {
return data.labels[index];
}
}
}],
yAxes: [{
id: 'y-axis',
type: 'linear',
ticks: {
max: 12,
min: 1,
stepSize: 1,
}
}],
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句