Javascript 如何更改highcahrts最小和最大选择行为?
我有highstock图表,带有Javascript 如何更改highcahrts最小和最大选择行为?,javascript,highcharts,highstock,Javascript,Highcharts,Highstock,我有highstock图表,带有散点类型。我选择时间范围,然后y轴比例改变,但最小值和最大值由上一个可见点选择,而不仅仅是当前可见点。 如何改变这种行为 比如说, series : [{ id: 'id', data : [100,101,102,0,103,104,105], type: "scatter", marker : { enabled : true, radius : 20 } }] 如果我查看1031041
散点类型。我选择时间范围,然后y轴比例改变,但最小值和最大值由上一个可见点选择,而不仅仅是当前可见点。
如何改变这种行为
比如说,
series : [{
id: 'id',
data : [100,101,102,0,103,104,105],
type: "scatter",
marker : {
enabled : true,
radius : 20
}
}]
如果我查看103104105
点,y轴上有0,如果104105
,则没有
在中,如果选择预设1,则水平轴和底点之间有填充,当隐藏左点时,允许更改比例(预设2)。这是从可见范围外的第一个点计算数据最小值和数据最大值的正常Highcharts功能。您可以通过更改GetExterms方法来更改此行为:
Highcharts.Series.prototype.getExtremes = function(yData) {
var xAxis = this.xAxis,
yAxis = this.yAxis,
xData = this.processedXData,
UNDEFINED = undefined,
yDataLength,
activeYData = [],
activeCounter = 0,
xExtremes = xAxis.getExtremes(), // #2117, need to compensate for log X axis
xMin = xExtremes.min,
xMax = xExtremes.max,
validValue,
withinRange,
x,
y,
i,
j;
yData = yData || this.stackedYData || this.processedYData || [];
yDataLength = yData.length;
for (i = 0; i < yDataLength; i++) {
x = xData[i];
y = yData[i];
// For points within the visible range, not including the first point outside the
// visible range, consider y extremes
validValue = y !== null && y !== UNDEFINED && (!yAxis.isLog || (y.length || y > 0));
withinRange = this.getExtremesFromAll || this.options.getExtremesFromAll || this.cropped ||
((xData[i] || x) >= xMin && (xData[i] || x) <= xMax);
if (validValue && withinRange) {
j = y.length;
if (j) { // array, like ohlc or range data
while (j--) {
if (y[j] !== null) {
activeYData[activeCounter++] = y[j];
}
}
} else {
activeYData[activeCounter++] = y;
}
}
}
this.dataMin = arrayMin(activeYData);
this.dataMax = arrayMax(activeYData);
};
Highcharts.Series.prototype.getExtremes=函数(yData){
var xAxis=this.xAxis,
yAxis=this.yAxis,
扩展数据=this.processedXData,
未定义=未定义,
伊达塔伦斯,
activeYData=[],
activeCounter=0,
xExtremes=xAxis.getExtremes(),//#2117,需要补偿对数X轴
xMin=xExtremes.min,
xMax=xExtremes.max,
有效值,
在范围内,
x,,
Y
我
J
yData=yData | | this.stackedYData | | this.processedYData | |[];
yDataLength=yData.length;
对于(i=0;i0));
withinRange=this.getExtremesFromAll | | | this.options.getExtremesFromAll | | this.crapped||
((扩展数据[i]| | x)>=xMin&(扩展数据[i]| | x)我希望在预设1上具有与预设2相同的缩放范围,因为它具有相同的可见底部点