summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-01-06 02:54:56 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-01-06 02:54:56 +0200
commit416257948feb3ed287cf34940004f37b6c71f729 (patch)
tree4fca12f339f26fb4cf7260c1011129a6eaf26969 /web
parent152067489cf032e16a2d9845f448c55d112285f0 (diff)
easyPieCharts can now be slaves of global selection sync
Diffstat (limited to 'web')
-rwxr-xr-xweb/dashboard.js56
1 files changed, 42 insertions, 14 deletions
diff --git a/web/dashboard.js b/web/dashboard.js
index 813cabe26f..a331c8fb88 100755
--- a/web/dashboard.js
+++ b/web/dashboard.js
@@ -225,7 +225,7 @@
focus: false,
visibility: false,
chart_data_url: false,
- chart_errors: true,
+ chart_errors: false,
chart_timing: false,
chart_calls: false,
libraries: false,
@@ -4100,15 +4100,20 @@
};
NETDATA.easypiechartClearSelection = function(state) {
- var chart = $(state.element_chart);
+ if(typeof state.easyPieChartEvent !== 'undefined') {
+ if(state.easyPieChartEvent.timer !== null)
+ clearTimeout(state.easyPieChartEvent.timer);
+
+ state.easyPieChartEvent.timer = null;
+ }
+
state.easyPieChartLabel.innerHTML = '';
- chart.data('easyPieChart').update(0);
+ state.easyPieChart_instance.update(0);
+ state.easyPieChart_instance.enableAnimation();
return true;
};
NETDATA.easypiechartSetSelection = function(state, t) {
- var chart = $(state.element_chart);
-
if(t < state.data_after || t > state.data_before)
return NETDATA.easypiechartClearSelection(state);
@@ -4128,15 +4133,31 @@
// console.log('slot = ' + slot + ' value = ' + value + ' max = ' + max + ' pcent = ' + pcent);
+ if(typeof state.easyPieChartEvent === 'undefined') {
+ state.easyPieChartEvent = {
+ timer: null,
+ value: 0,
+ pcent: 0,
+ };
+ }
+
+ state.easyPieChartEvent.value = value;
+ state.easyPieChartEvent.pcent = pcent;
state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
- chart.data('easyPieChart').update(pcent);
+
+ if(state.easyPieChartEvent.timer === null) {
+ state.easyPieChart_instance.disableAnimation();
+
+ state.easyPieChartEvent.timer = setTimeout(function() {
+ state.easyPieChartEvent.timer = null;
+ state.easyPieChart_instance.update(state.easyPieChartEvent.pcent);
+ }, 50);
+ }
return true;
};
NETDATA.easypiechartChartUpdate = function(state, data) {
- var chart = $(state.element_chart);
-
var value = data.result[0];
if(value === null) value = 0;
@@ -4147,8 +4168,14 @@
if(max !== 0)
pcent = Math.round(value * 100 / max);
- state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
- chart.data('easyPieChart').update(pcent);
+ if(state.isAutoRefreshed() === true) {
+ state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
+ state.easyPieChart_instance.update(pcent);
+ }
+ else {
+ state.easyPieChartLabel.innerHTML = '';
+ state.easyPieChart_instance.update(0);
+ }
return true;
};
@@ -4218,11 +4245,12 @@
trackWidth: self.data('easypiechart-trackwidth') || undefined,
size: self.data('easypiechart-size') || size,
rotate: self.data('easypiechart-rotate') || 0,
- animate: self.data('easypiechart-rotate') || {duration: data.view_update_every * 1000, enabled: true},
+ animate: self.data('easypiechart-rotate') || {duration: data.view_update_every * 1000 / 2, enabled: true},
easing: self.data('easypiechart-easing') || undefined
});
- chart.data('easyPieChart').update(pcent);
+ state.easyPieChart_instance = chart.data('easyPieChart');
+ state.easyPieChart_instance.update(pcent);
return true;
};
@@ -4395,8 +4423,8 @@
create: NETDATA.easypiechartChartCreate,
update: NETDATA.easypiechartChartUpdate,
resize: null,
- setSelection: undefined, // NETDATA.easypiechartSetSelection,
- clearSelection: undefined, // NETDATA.easypiechartClearSelection,
+ setSelection: NETDATA.easypiechartSetSelection,
+ clearSelection: NETDATA.easypiechartClearSelection,
initialized: false,
enabled: true,
format: function(state) { return 'array'; },