mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Show legends and toggle display of datasets
This commit is contained in:
1 parent
5abeb8c9a6
commit
fedf9f6df1
1 file changed
+21
-4
+21
-4
@@ -98,14 +98,17 @@ function generateLineChartArray(data, nameKey) {
|
|||||||
}
|
}
|
||||||
let xyz = {};
|
let xyz = {};
|
||||||
xyz.name = nameKey;
|
xyz.name = nameKey;
|
||||||
xyz.type = "spline";
|
xyz.type = "line";
|
||||||
|
xyz.showInLegend = true;
|
||||||
xyz.dataPoints = chartData;
|
xyz.dataPoints = chartData;
|
||||||
return xyz;
|
return xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var chartsByID = {};
|
||||||
function drawChart(selector, chartData) {
|
function drawChart(selector, chartData) {
|
||||||
// selector is ID of element, ex "chartContainer"
|
// selector is ID of element, ex "chartContainer" or "-123199123"
|
||||||
var chart = new CanvasJS.Chart(selector, {
|
console.log(chartData)
|
||||||
|
chartsByID[selector] = new CanvasJS.Chart(selector, {
|
||||||
title:{
|
title:{
|
||||||
text: "Production graph"
|
text: "Production graph"
|
||||||
},
|
},
|
||||||
@@ -114,10 +117,24 @@ function drawChart(selector, chartData) {
|
|||||||
},
|
},
|
||||||
zoomEnabled: true,
|
zoomEnabled: true,
|
||||||
axisY:{
|
axisY:{
|
||||||
includeZero: true
|
includeZero: true,
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
cursor: "pointer",
|
||||||
|
itemclick: function (e) {
|
||||||
|
//console.log("legend click: " + e.dataPointIndex);
|
||||||
|
//console.log(e);
|
||||||
|
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
|
||||||
|
e.dataSeries.visible = false;
|
||||||
|
} else {
|
||||||
|
e.dataSeries.visible = true;
|
||||||
|
}
|
||||||
|
e.chart.render();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data: chartData
|
data: chartData
|
||||||
});
|
});
|
||||||
|
chart = chartsByID[selector];
|
||||||
// console.log(chart)
|
// console.log(chart)
|
||||||
chart.render();
|
chart.render();
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user