Browse Source

use chart.get instead of rolling my own..

main
John-Mark Gurney 4 years ago
parent
commit
1e73a58c25
1 changed files with 12 additions and 25 deletions
  1. +12
    -25
      root/js/solardash.base.js

+ 12
- 25
root/js/solardash.base.js View File

@@ -53,17 +53,17 @@ socket.onmessage = function(m) {
// received overview data
var data = JSON.parse(msg[1]);
console.log(solarchart);
solarchart.navigator.series[consumIdx].setData(data.consumption, false);
solarchart.navigator.series[gridIdx].setData(data.grid, false);
solarchart.navigator.series[prodIdx].setData(data.production, false);
solarchart.get('consumptionNav').setData(data.consumption, false);
solarchart.get('gridNav').setData(data.grid, false);
solarchart.get('productionNav').setData(data.production, false);
solarchart.redraw();
} else if (msg[0] == 'windata') {
var data = JSON.parse(msg[1]);
console.log(data);
solarchart.sd_lastwindata = Date.now();
solarchart.series[consumDataIdx].setData(data.consumption, false);
solarchart.series[gridDataIdx].setData(data.grid, false);
solarchart.series[prodDataIdx].setData(data.production, false);
solarchart.get('consumption').setData(data.consumption, false);
solarchart.get('grid').setData(data.grid, false);
solarchart.get('production').setData(data.production, false);
solarchart.redraw();
solarchart.hideLoading()
}
@@ -86,18 +86,21 @@ var solarchart = Highcharts.stockChart('solarchart', {
{
type: 'bar',
name: 'consumptionNav',
id: 'consumptionNav',
showInNavigator: true,
data: [],
},
{
type: 'bar',
name: 'gridNav',
id: 'gridNav',
showInNavigator: true,
data: [],
},
{
type: 'bar',
name: 'productionNav',
id: 'productionNav',
showInNavigator: true,
data: [],
},
@@ -137,37 +140,21 @@ var solarchart = Highcharts.stockChart('solarchart', {
series: [
{
name: 'consumption',
id: 'consumption',
type: 'line',
data: [ ],
},
{
name: 'grid',
id: 'grid',
type: 'line',
data: [ ],
},
{
name: 'production',
id: 'production',
type: 'line',
data: [ ],
},
]
});

// Indexes for chart series
delete solarchart.navigator.series[0];
for (var idx in solarchart.navigator.series) {
if (solarchart.navigator.series[idx].name == 'consumptionNav')
consumIdx = idx;
else if (solarchart.navigator.series[idx].name == 'gridNav')
gridIdx = idx;
else if (solarchart.navigator.series[idx].name == 'productionNav')
prodIdx = idx;
}
for (var idx in solarchart.series) {
if (solarchart.series[idx].name == 'consumption')
consumDataIdx = idx;
else if (solarchart.series[idx].name == 'grid')
gridDataIdx = idx;
else if (solarchart.series[idx].name == 'production')
prodDataIdx = idx;
}

Loading…
Cancel
Save