mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Show legends and toggle display of datasets
This commit is contained in:
1 parent
5abeb8c9a6
commit
fedf9f6df1
1 file changed
+22
-5
+22
-5
@@ -98,26 +98,43 @@ function generateLineChartArray(data, nameKey) {
|
||||
}
|
||||
let xyz = {};
|
||||
xyz.name = nameKey;
|
||||
xyz.type = "spline";
|
||||
xyz.type = "line";
|
||||
xyz.showInLegend = true;
|
||||
xyz.dataPoints = chartData;
|
||||
return xyz;
|
||||
}
|
||||
|
||||
var chartsByID = {};
|
||||
function drawChart(selector, chartData) {
|
||||
// selector is ID of element, ex "chartContainer"
|
||||
var chart = new CanvasJS.Chart(selector, {
|
||||
// selector is ID of element, ex "chartContainer" or "-123199123"
|
||||
console.log(chartData)
|
||||
chartsByID[selector] = new CanvasJS.Chart(selector, {
|
||||
title:{
|
||||
text: "Production graph"
|
||||
},
|
||||
toolTip:{
|
||||
content: "{name}: {y}"
|
||||
content: "{name}: {y}"
|
||||
},
|
||||
zoomEnabled: true,
|
||||
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
|
||||
});
|
||||
chart = chartsByID[selector];
|
||||
// console.log(chart)
|
||||
chart.render();
|
||||
}
|
||||
Reference in new issue
Block a user