smooth_plot: true, // enable smooth plot, where possible
+ charts_selection_animation_delay: 50, // delay to animate charts when syncing selection
+
color_fill_opacity_line: 1.0,
color_fill_opacity_area: 0.2,
color_fill_opacity_stacked: 0.8,
}
var show_undefined = true;
- if(Math.abs(this.data.last_entry - this.data.before) <= this.data.view_update_every)
+ if(Math.abs(this.netdata_last - this.view_before) <= this.data_update_every)
show_undefined = false;
if(show_undefined) {
return;
}
- this.legendSetDate(this.data.before * 1000);
+ this.legendSetDate(this.view_before);
var labels = this.data.dimension_names;
var i = labels.length;
this.colors = new Array();
this.colors_available = new Array();
- // this.colors_assigned = {};
var c = $(this.element).data('colors');
+ // this.log('read colors: ' + c);
if(typeof c !== 'undefined' && c !== null) {
if(typeof c !== 'string') {
this.log('invalid color given: ' + c + ' (give a space separated list of colors)');
}
else {
c = c.split(' ');
- for(var i = 0, len = c.length; i < len ; i++)
- this.colors_available.push(c[i]);
+ var added = 0;
+
+ while(added < 20) {
+ for(var i = 0, len = c.length; i < len ; i++) {
+ added++;
+ this.colors_available.push(c[i]);
+ // this.log('adding color: ' + c[i]);
+ }
+ }
}
}
// do we have to update the current values?
// we do this, only when the visible chart is current
- if(Math.abs(this.data.last_entry - this.data.before) <= this.data.view_update_every) {
+ if(Math.abs(this.netdata_last - this.view_before) <= this.data_update_every) {
if(this.debug === true)
- this.log('chart in running... updating values on legend...');
+ this.log('chart is in latest position... updating values on legend...');
//var labels = this.data.dimension_names;
//var i = labels.length;
this._chartDimensionColor(this.chart.dimensions[dim].name);
}
// we will re-generate the colors for the chart
+ // based on the selected dimensions
this.colors = null;
if(this.debug === true)
if(NETDATA.options.current.pan_and_zoom_data_padding === true && this.requested_padding !== null) {
if(this.view_after < this.data_after) {
- console.log('adusting view_after from ' + this.view_after + ' to ' + this.data_after);
+ // console.log('adusting view_after from ' + this.view_after + ' to ' + this.data_after);
this.view_after = this.data_after;
}
if(this.view_before > this.data_before) {
- console.log('adusting view_before from ' + this.view_before + ' to ' + this.data_before);
+ // console.log('adusting view_before from ' + this.view_before + ' to ' + this.data_before);
this.view_before = this.data_before;
}
}
}
return true;
- }
+ };
NETDATA.dygraphClearSelection = function(state, t) {
if(typeof state.dygraph_instance !== 'undefined') {
state.dygraph_instance.clearSelection();
}
return true;
- }
+ };
NETDATA.dygraphSmoothInitialize = function(callback) {
$.ajax({
if(NETDATA.options.debug.dygraph === true)
state.log('dygraphDrawCallback()');
- var first = state.data.first_entry * 1000;
- var last = state.data.last_entry * 1000;
-
var x_range = dygraph.xAxisRange();
var after = Math.round(x_range[0]);
var before = Math.round(x_range[1]);
- if(before <= last && after >= first)
+ if(before <= state.netdata_last && after >= state.netdata_first)
state.updateChartPanOrZoom(after, before);
}
},
var after = new_x_range[0];
var before = new_x_range[1];
- var first = (state.data.first_entry + state.data.view_update_every) * 1000;
- var last = (state.data.last_entry + state.data.view_update_every) * 1000;
+ var first = state.netdata_first + state.data_update_every;
+ var last = state.netdata_last + state.data_update_every;
if(before > last) {
after -= (before - last);
};
NETDATA.easypiechartSetSelection = function(state, t) {
- if(t < state.data_after || t > state.data_before)
+ if(state.timeIsVisible(t) !== true)
return NETDATA.easypiechartClearSelection(state);
- var slot = Math.floor(state.data.result.length - 1 - (t - state.data_after) / state.data_update_every);
+ var slot = state.calculateRowForTime(t);
if(slot < 0 || slot >= state.data.result.length)
return NETDATA.easypiechartClearSelection(state);
};
}
- var value = state.data.result[slot];
+ var value = state.data.result[state.data.result.length - 1 - slot];
var max = (state.easyPieChartMax === null)?state.data.max:state.easyPieChartMax;
var pcent = NETDATA.percentFromValueMax(value, max);
state.easyPieChartEvent.timer = setTimeout(function() {
state.easyPieChartEvent.timer = null;
state.easyPieChart_instance.update(state.easyPieChartEvent.pcent);
- }, 100);
+ }, NETDATA.options.current.charts_selection_animation_delay);
}
return true;
if(typeof max !== 'number') max = 0;
if(value > max) max = value;
if(value < min) min = value;
+ if(min > max) {
+ var t = min;
+ min = max;
+ max = t;
+ }
+ else if(min == max)
+ max = min + 1;
- var dvalue = state.gauge_instance.displayedValue;
+ // gauge.js has an issue if the needle
+ // is smaller than min or larger than max
+ // when we set the new values
+ // the needle will go crazy
- if(dvalue >= min && dvalue <= max) {
- state.gauge_instance.minValue = min;
- state.gauge_instance.maxValue = max;
- state.gauge_instance.set(value);
- }
- else {
- // the current display value of the gauge
- // is outside min-max.
- // we have to disable animation
- // otherwise, the gauge will go crazy
- var old_speed = state.___gaugeOld__.speed;
- NETDATA.gaugeAnimation(state, false);
- state.gauge_instance.minValue = min;
- state.gauge_instance.maxValue = max;
- state.gauge_instance.set(value);
- NETDATA.gaugeAnimation(state, old_speed);
- }
+ // to prevent it, we always feed it
+ // with a percentage, so that the needle
+ // is always between min and max
+ var pcent = (value - min) * 100 / (max - min);
+
+ state.gauge_instance.set(pcent);
state.___gaugeOld__.value = value;
state.___gaugeOld__.min = min;
};
NETDATA.gaugeSetSelection = function(state, t) {
- if(t < state.data_after || t > state.data_before)
+ if(state.timeIsVisible(t) !== true)
return NETDATA.gaugeClearSelection(state);
- var slot = Math.floor(state.data.result.length - 1 - (t - state.data_after) / state.data_update_every);
+ var slot = state.calculateRowForTime(t);
if(slot < 0 || slot >= state.data.result.length)
return NETDATA.gaugeClearSelection(state);
};
}
- var value = state.data.result[slot];
+ var value = state.data.result[state.data.result.length - 1 - slot];
var max = (state.gaugeMax === null)?state.data.max:state.gaugeMax;
var min = 0;
state.gaugeEvent.timer = setTimeout(function() {
state.gaugeEvent.timer = null;
NETDATA.gaugeSet(state, state.gaugeEvent.value, state.gaugeEvent.min, state.gaugeEvent.max);
- }, 100);
+ }, NETDATA.options.current.charts_selection_animation_delay);
}
return true;
var value = data.result[0];
var max = self.data('gauge-max-value') || null;
var adjust = self.data('gauge-adjust') || null;
-
+ var pointerColor = self.data('gauge-pointer-color') || '#C0C0C0';
+ var strokeColor = self.data('gauge-stroke-color') || '#F0F0F0';
+ var startColor = self.data('gauge-start-color') || state.chartColors()[0];
+ var stopColor = self.data('gauge-stop-color') || void 0;
+ var generateGradient = self.data('gauge-generate-gradient') || false;
+
if(max === null) {
max = data.max;
state.gaugeMax = null;
pointer: {
length: 0.8, // 0.9 The radius of the inner circle
strokeWidth: 0.035, // The rotation offset
- color: '#C0C0C0' // Fill color
+ color: pointerColor // Fill color
},
- colorStart: state.chartColors()[0], // Colors
- colorStop: void 0, // just experiment with them
- strokeColor: '#F0F0F0', // to see which ones work best for you
+ colorStart: startColor, // Colors
+ colorStop: stopColor, // just experiment with them
+ strokeColor: strokeColor, // to see which ones work best for you
limitMax: true,
- generateGradient: false,
+ generateGradient: generateGradient,
gradientType: 0,
percentColors: [
[0.0, NETDATA.colorLuminance(state.chartColors()[0], (lum_d * 10) - (lum_d * 0))],
maxLabel: null
};
+ // we will always feed a percentage
+ state.gauge_instance.minValue = 0;
+ state.gauge_instance.maxValue = 100;
+
NETDATA.gaugeAnimation(state, animate);
NETDATA.gaugeSet(state, value, 0, max);
NETDATA.gaugeSetLabels(state, value, 0, max);
legend: function(state) { return null; },
autoresize: function(state) { return false; },
max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return false; },
+ track_colors: function(state) { return true; },
pixels_per_point: function(state) { return 3; },
aspect_ratio: 100
},
legend: function(state) { return null; },
autoresize: function(state) { return false; },
max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return false; },
+ track_colors: function(state) { return true; },
pixels_per_point: function(state) { return 3; },
aspect_ratio: 70
}
--- /dev/null
+<!DOCTYPE html>\r
+<html lang="en">\r
+<head>\r
+ <title>NetData Dashboard</title>\r
+\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
+ <meta charset="utf-8">\r
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\r
+ <meta name="viewport" content="width=device-width, initial-scale=1">\r
+ <meta name="apple-mobile-web-app-capable" content="yes">\r
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">\r
+ <meta name="author" content="costa@tsaousis.gr">\r
+\r
+ <style>\r
+ .easyPieChartLabel {\r
+ color: #222 !important;\r
+ font-weight: normal;\r
+ text-shadow: #333 0px 0px 1px !important;\r
+ -webkit-font-smoothing: none;\r
+ }\r
+ </style>\r
+\r
+ <script type="text/javascript" src="dashboard.js"></script>\r
+</head>\r
+<body style="background-color: #444;">\r
+\r
+<div style="width: 100%; padding-top: 10px; text-align: center; color: #AAA">\r
+ <div style="font-size: 8vw;">why netdata?</div>\r
+ <br/>\r
+ <div style="font-size: 2vw;">These charts update the same data...</div>\r
+ <div data-netdata="example.random"\r
+ data-dimensions="random1"\r
+ data-chart-library="easypiechart"\r
+ data-easypiechart-max-value="100"\r
+ data-width="25%"\r
+ data-after="-600"\r
+ data-points="600"\r
+ data-title="1/second (netdata default)"\r
+ data-units="something"\r
+ data-colors="#CCC"\r
+ data-easypiechart-trackcolor="#555"\r
+ data-easypiechart-scalecolor="#555"\r
+ ></div>\r
+ <div data-netdata="example.random"\r
+ data-dimensions="random1"\r
+ data-chart-library="easypiechart"\r
+ data-easypiechart-max-value="100"\r
+ data-width="20%"\r
+ data-after="-600"\r
+ data-points="300"\r
+ data-title="Updates Every 2 Seconds"\r
+ data-units="something"\r
+ data-colors="#AAA"\r
+ data-easypiechart-trackcolor="#555"\r
+ data-easypiechart-scalecolor="#555"\r
+ ></div>\r
+ <div data-netdata="example.random"\r
+ data-dimensions="random1"\r
+ data-chart-library="easypiechart"\r
+ data-easypiechart-max-value="100"\r
+ data-width="17.5%"\r
+ data-after="-600"\r
+ data-points="120"\r
+ data-title="Updates Every 5 Seconds"\r
+ data-units="something"\r
+ data-colors="#999"\r
+ data-easypiechart-trackcolor="#555"\r
+ data-easypiechart-scalecolor="#555"\r
+ ></div>\r
+ <div data-netdata="example.random"\r
+ data-dimensions="random1"\r
+ data-chart-library="easypiechart"\r
+ data-easypiechart-max-value="100"\r
+ data-width="15%"\r
+ data-after="-600"\r
+ data-points="10"\r
+ data-title="Updates Every 1 Minute"\r
+ data-units="something"\r
+ data-colors="#888"\r
+ data-easypiechart-trackcolor="#555"\r
+ data-easypiechart-scalecolor="#555"\r
+ ></div>\r
+ <div style="font-size: 2vw;">Hover on the peaks and the lows of the chart below, to see the diff on the charts above!</div>\r
+ <div data-netdata="example.random"\r
+ data-dimensions="random1"\r
+ data-dygraph-theme="sparkline"\r
+ data-width="90%"\r
+ data-height="20vh"\r
+ data-after="-600"\r
+ data-points="600"\r
+ data-title="1/second (netdata default)"\r
+ data-units="something"\r
+ data-colors="#CCC"\r
+ ></div>\r
+</div>\r
+</body>\r
+</html>\r
+ ' data-before="0"'
+ ' data-after="-' + duration.toString() + '"'
+ ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[0] + '"'
+ ' role="application"></div>';
head += '<div data-netdata="' + f.id + '"'
+ ' data-before="0"'
+ ' data-after="-' + duration.toString() + '"'
+ ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[1] + '"'
+ ' role="application"></div>';
break;
+ ' data-before="0"'
+ ' data-after="-' + duration.toString() + '"'
+ ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[0] + '"'
+ ' role="application"></div>';
head += '<div data-netdata="' + f.id + '"'
+ ' data-before="0"'
+ ' data-after="-' + duration.toString() + '"'
+ ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[1] + '"'
+ ' role="application"></div>';
break;
case 'disk_backlog': c = '#DD4477'; break;
+ ' data-before="0"'
+ ' data-after="-' + duration.toString() + '"'
+ ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[0] + '"'
+ ' role="application"></div>';
head += '<div style="margin-right: 10px;" data-netdata="system.io"'
+ ' data-before="0"'
+ ' data-after="-' + duration.toString() + '"'
+ ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[1] + '"'
+ ' role="application"></div>';
}
+ ' data-before="0"'
+ ' data-after="-' + duration.toString() + '"'
+ ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[0] + '"'
+ ' role="application"></div>';
head += '<div style="margin-right: 10px;" data-netdata="system.ipv4"'
+ ' data-before="0"'
+ ' data-after="-' + duration.toString() + '"'
+ ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[1] + '"'
+ ' role="application"></div>';
}