Skip to content

Commit 2d3f19c

Browse files
committed
update plotly to version 3.1.0
add them support to graphs, #185
1 parent bd4328e commit 2d3f19c

File tree

3 files changed

+3892
-66
lines changed

3 files changed

+3892
-66
lines changed

octoprint_tasmota/static/js/plotly-latest.min.js

Lines changed: 3854 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

octoprint_tasmota/static/js/tasmota.js

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ $(function() {
232232
var sensor_labels = [0,0,'Temperature','Humidity'];
233233
var traces = [];
234234

235+
var background_color = (self.getInheritedBackgroundColor(document.getElementById('tab_plugin_tasmota')) == 'rgba(0, 0, 0, 0)') ? '#FFFFFF' : self.getInheritedBackgroundColor(document.getElementById('tab_plugin_tasmota'));
236+
var foreground_color = ($('#tab_plugin_tasmota').css('color') == 'rgba(0, 0, 0, 0)') ? '#FFFFFF' : $('#tab_plugin_tasmota').css('color');
237+
235238
var layout = {
236239
grid: {
237240
rows: (data.sensor_data.length > 0 && data.energy_data.length > 0) ? 6 : (data.energy_data.length > 0) ? 4 : (data.sensor_data.length > 0) ? 2 : 1,
@@ -245,23 +248,28 @@ $(function() {
245248
xaxis: {
246249
type: "date", /* tickformat:"%H:%M:%S", */ automargin: true,
247250
mirror: true,
248-
showticklabels: false,
249251
anchor: 'x',
252+
tickcolor: foreground_color,
253+
linecolor: foreground_color,
254+
color: foreground_color
250255
},
251256
yaxis: {
252257
automargin: true,
253-
title: '',
258+
title: {text: 'No Data'},
254259
hoverformat: '.3f',
255260
anchor:'x',
256261
tickangle:-45,
257262
tickformat:'.1f',
258263
mirror:true,
259-
rangemode: 'nonnegative'
264+
rangemode: 'nonnegative',
265+
tickcolor: foreground_color,
266+
linecolor: foreground_color,
267+
color: foreground_color
260268
},
261269
margin: {
262270
l: 35,
263271
r: 30,
264-
b: 0,
272+
b: 20,
265273
t: 20,
266274
pad: 5
267275
},
@@ -279,37 +287,41 @@ $(function() {
279287
displayModeBar: false,
280288
editable: false,
281289
showTips: false,
290+
responsive: true
282291
};
283292

284293
if(data.sensor_data.length > 0 && data.energy_data.length == 0){ // sensor data only
285-
layout.yaxis.title = 'Temperature';
286-
layout['xaxis2'] = {automargin: true, anchor: 'y2', showticklabels: true, mirror: true, matches: 'x'/*, overlaying: 'x',*/}
287-
layout['yaxis2'] = {automargin:true, title:'Humidity', hoverformat:'.3f', anchor:'x2', tickangle:-45, tickformat:'.1f', mirror:true, rangemode: 'nonnegative'}
294+
layout.yaxis.title.text = 'Temperature';
295+
layout['xaxis2'] = {automargin: true, anchor: 'y2', mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color/*, overlaying: 'x',*/}
296+
layout['yaxis2'] = {automargin:true, title: {text: 'Humidity'}, hoverformat:'.3f', anchor:'x2', tickangle:-45, tickformat:'.1f', mirror:true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color}
288297
} else if(data.sensor_data.length == 0 && data.energy_data.length > 0){ // power data only
289-
layout.yaxis.title = 'Total';
290-
layout['xaxis2'] = {anchor: 'y2', mirror: true, showticklabels: false, matches: 'x'};
291-
layout['yaxis2'] = {automargin: true, title: 'Current', hoverformat: '.3f', anchor: 'x2', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative'};
292-
layout['xaxis3'] = {anchor: 'y3', showticklabels: false, mirror: true, matches: 'x'};
293-
layout['yaxis3'] = {automargin: true, title: 'Power', hoverformat: '.3f', anchor: 'x3', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative'};
294-
layout['xaxis4'] = {anchor: 'y4', showticklabels: true, mirror: true, matches: 'x'};
295-
layout['yaxis4'] = {automargin: true, title: 'Cost', hoverformat: '.3f', anchor: 'x4', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative'};
298+
layout.yaxis.title.text = 'Total';
299+
layout['xaxis2'] = {anchor: 'y2', mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
300+
layout['yaxis2'] = {automargin: true, title: {text: 'Current'}, hoverformat: '.3f', anchor: 'x2', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
301+
layout['xaxis3'] = {anchor: 'y3', mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
302+
layout['yaxis3'] = {automargin: true, title: {text: 'Power'}, hoverformat: '.3f', anchor: 'x3', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
303+
layout['xaxis4'] = {anchor: 'y4', showticklabels: true, mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
304+
layout['yaxis4'] = {automargin: true, title: {text: 'Cost'}, hoverformat: '.3f', anchor: 'x4', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
296305
} else if(data.sensor_data.length > 0 && data.energy_data.length > 0) { // sensor and power data
297-
layout.yaxis.title = 'Total';
298-
layout['xaxis2'] = {anchor: 'y2', mirror: true, showticklabels: false, matches: 'x'};
299-
layout['yaxis2'] = {automargin: true, title: 'Current', hoverformat: '.3f', anchor: 'x2', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative'};
300-
layout['xaxis3'] = {anchor: 'y3', showticklabels: false, mirror: true, matches: 'x'};
301-
layout['yaxis3'] = {automargin: true, title: 'Power', hoverformat: '.3f', anchor: 'x3', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative'};
302-
layout['xaxis4'] = {anchor: 'y4', showticklabels: true, mirror: true, matches: 'x'};
303-
layout['yaxis4'] = {automargin: true, title: 'Cost', hoverformat: '.3f', anchor: 'x4', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative'};
304-
layout['xaxis5'] = {anchor: 'y5', showticklabels: false, mirror: true, matches: 'x'/*, overlaying: 'x',*/}
305-
layout['yaxis5'] = {automargin:true, title:'Temperature', hoverformat:'.3f', anchor:'x5', tickangle:-45, tickformat:'.1f', mirror:true, rangemode: 'nonnegative'}
306-
layout['xaxis6'] = {anchor: 'y6', showticklabels: true, mirror: true, matches: 'x'/*, overlaying: 'x',*/}
307-
layout['yaxis6'] = {automargin:true, title:'Humidity', hoverformat:'.3f', anchor:'x6', tickangle:-45, tickformat:'.1f', mirror:true, rangemode: 'nonnegative'}
306+
layout.yaxis.title.text = 'Total';
307+
layout['xaxis2'] = {anchor: 'y2', mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
308+
layout['yaxis2'] = {automargin: true, title: {text: 'Current'}, hoverformat: '.3f', anchor: 'x2', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
309+
layout['xaxis3'] = {anchor: 'y3', mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
310+
layout['yaxis3'] = {automargin: true, title: {text: 'Power'}, hoverformat: '.3f', anchor: 'x3', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
311+
layout['xaxis4'] = {anchor: 'y4', showticklabels: true, mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
312+
layout['yaxis4'] = {automargin: true, title: {text: 'Cost'}, hoverformat: '.3f', anchor: 'x4', tickangle: -45, tickformat: '.1f', mirror: true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color};
313+
layout['xaxis5'] = {anchor: 'y5', mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color/*, overlaying: 'x',*/}
314+
layout['yaxis5'] = {automargin:true, title: {text: 'Temperature'}, hoverformat:'.3f', anchor:'x5', tickangle:-45, tickformat:'.1f', mirror:true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color}
315+
layout['xaxis6'] = {anchor: 'y6', showticklabels: true, mirror: true, matches: 'x', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color/*, overlaying: 'x',*/}
316+
layout['yaxis6'] = {automargin:true, title: {text: 'Humidity'}, hoverformat:'.3f', anchor:'x6', tickangle:-45, tickformat:'.1f', mirror:true, rangemode: 'nonnegative', tickcolor: foreground_color, linecolor: foreground_color, color: foreground_color}
308317
} else { // no data
309318
layout['annotations'] = [{text: 'No Data', xref: 'x domain', yref: 'y domain', x: 0.5, y: 0.5, showarrow: false, font: { size: 16 }}];
319+
layout.xaxis['range'] = [self.graph_start_date(), self.graph_end_date()];
310320
console.log('no data to graph')
311321
}
312322

323+
console.log(layout);
324+
313325
for(var i=0;i<data.energy_data.length;i++){
314326
for(var j=2;j<data.energy_data[i].length;j++){
315327
var trace = {mode: 'lines'};
@@ -368,9 +380,6 @@ $(function() {
368380
}
369381
}
370382

371-
var background_color = (self.getInheritedBackgroundColor(document.getElementById('tab_plugin_tasmota')) == 'rgba(0, 0, 0, 0)') ? '#FFFFFF' : self.getInheritedBackgroundColor(document.getElementById('tab_plugin_tasmota'));
372-
var foreground_color = ($('.tab-content').css('color') == 'rgba(0, 0, 0, 0)') ? '#FFFFFF' : $('#tabs_content').css('color');
373-
374383
Plotly.react('tasmota_graph', traces, layout, options);
375384
});
376385
};

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
plugin_name = "OctoPrint-Tasmota"
1515

1616
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
17-
plugin_version = "1.1.5rc1"
17+
plugin_version = "1.1.5rc2"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module

0 commit comments

Comments
 (0)