highcharts - Highstock如何在数据中隐藏零
问题描述
在此图表中,数据是从 csv 文件导入的,无法更改。
data: {
googleSpreadsheetKey: '1TlXkg_COywLso2dcUhkT79L8IEJrLC8Mdb-leXVFgiM',
startColumn: 0,
endColumn: 1,
startRow: 0,
endRow: 4310
}
缺失值表示为零,不应绘制:https ://jsfiddle.net/Joh_Christ/03ugzb1j/1/
我该如何处理(例如用空值替换零)?
解决方案
获取数据后,您可以使用 data.complete 事件编辑数据:https ://api.highcharts.com/highcharts/data.complete
jsFiddle:https ://jsfiddle.net/BlackLabel/uty6e380/
data: {
googleSpreadsheetKey: '1TlXkg_COywLso2dcUhkT79L8IEJrLC8Mdb-leXVFgiM',
startColumn: 0,
endColumn: 1,
startRow: 0,
endRow: 4310,
complete: function(options) {
options.series[0].data.forEach(point => {
if (point[1] === 0) {
point[1] = null;
}
});
}
}