我使用highcharts和ajax創建了一個相當複雜的圖表,它包含使用datetime xAxis的堆積列和多個樣條曲線圖。當放大高圖時只獲取可見的x軸日期
我還會根據用戶選擇事件(如使用圖例打開/關閉系列)重新生成圖表數據的HTML表格。這工作正常,但我有麻煩的是收集正確的數據時,用戶放大(它仍然抓住從第一次日期到結束日期的所有數據)。
主要問題是,我似乎無法找到變量,如可見:true,以區分循環期間當前視圖中是否存在xAxis值。我沒有運氣看過包括系列,點等圖表對象。
我也使用getExtremes嘗試,但值顯示從由幾千毫秒的實際日期關閉(我會考慮這個方法明天再次)
下面是一小段代碼,用於在我使用jQuery構建HTML表格來收集一些數據之前。
$.each(chart.series, function (i, item) {
//Generation Data
if (item.name === "Generation") {
generation.push(item.yData);
}
//Check if points are defined and then loop to get total circuit data
if (typeof (item.points) !== "undefined") {
$.each(item.points, function (j, point) {
//Check if asset is visible
if (point.series.visible === true) {
var type = point.series.options.type;
//Get only data that is a column (asset)
if (type !== "spline" || typeof (type) === "undefined") {
//Check if previous key exists already or not
if (typeof (totalCircuits[point.x]) === 'undefined') {
totalCircuits[point.x] = point.y;
}
else {
var oldVal = 0;
oldVal = totalCircuits[point.x];
var newVal = oldVal + point.y;
totalCircuits[point.x] = newVal;
}
}
}
});
}
});
希望這是至少有一些感覺和任何幫助或方向將不勝感激
你可以做一個小的小提琴,我們可以看一下? – srijan 2014-12-03 18:06:11