我使用HighCharts庫來繪製非常大的數據集(即〜18,000點)。我在後端使用量化來將點數減少到合理的大小(小於200)。當用戶選擇圖表的一部分時,它向服務器發出ajax請求並接收採樣頻率較高的新集合。但是,在plotOptions中更改pointInterval時,它實際上並不會更改顯示圖表上的間隔。更改HighCharts pointInterval創建圖表後
這些是我使用,使圖表我的選擇:
options = {
chart: {
renderTo: settings.highchartId,
zoomType: 'x',
spacingRight: 20,
events: {
load: getChartData,
selection: zoomChart,
}
},
title: {
text: Drupal.settings.openfitcharts.title
},
subtitle: {
text: document.ontouchstart === undefined ?
'Click and drag in the plot area to zoom in' :
'Drag your finger over the plot to zoom in'
},
xAxis: {
allowDecimals: false,
title: {
text: Drupal.settings.openfitcharts.xAxisTitle
}
},
yAxis: {
title: {
text: Drupal.settings.openfitcharts.yAxisTitle
},
startOnTick: false,
showFirstLabel: false
},
tooltip: {
shared: true
},
legend: {
enabled: false
},
series: [{
type: "line",
data: [],
}],
plotOptions: {
line: {
marker: {
enabled: false,
states: {
hover: {
enabled: true,
radius: 5
}
}
},
pointInterval: 1,
pointStart: 0,
}
}
};
這是我使用來獲取數據的功能:
function getChartData() {
activityId = settings.seriesData.activityId;
trackType = settings.seriesData.type;
jQuery.getJSON(OPENFIT_DATA_URL, {op: 'TrackHandler.getTrackData', actid: activityId, type: trackType}, function(returnData) {
console.log(returnData);
console.log(chart);
if (returnData != null) {
chart.options.plotOptions.line.pointInterval = returnData.interval;
chart.options.plotOptions.line.pointStart = returnData.start;
chart.xAxis[0].adjustTickAmount();
chart.series[0].setData(returnData.data, true);
}
});
}