@cryptotaxi247 / netdata-1 / commits / 54334554b

added dygraph-theme="logscale"; fixes #3237

Costa Tsaousis (ktsaou) committed Jan 14, 2018 at 21:06 UTC 54334554b6ad23ddbeed72188c91d7c52df3853b
1 file changed +19 -6
web/dashboard.js
+19 -6
@@ -6034,6 +6034,7 @@ var NETDATA = window.NETDATA || {};
6034
6035 var chart_type = NETDATA.dataAttribute(state.element, 'dygraph-type', state.chart.chart_type);
6036 if(chart_type === 'stacked' && data.dimensions === 1) chart_type = 'area';
6037 + if(chart_type === 'stacked' && this.isLogScale(state) === true) chart_type = 'area';
6038
6039 var highlightCircleSize = (NETDATA.chartLibraries.dygraph.isSparkline(state) === true)?3:4;
6040
@@ -6056,7 +6057,7 @@ var NETDATA = window.NETDATA || {};
6057 labelsDivStyles: NETDATA.dataAttribute(state.element, 'dygraph-labelsdivstyles', { 'fontSize':'1px' }),
6058 labelsDivWidth: NETDATA.dataAttribute(state.element, 'dygraph-labelsdivwidth', state.chartWidth() - 70),
6059 labelsSeparateLines: NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsseparatelines', true),
6059 - labelsShowZeroValues: NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsshowzerovalues', true),
6060 + labelsShowZeroValues: (this.isLogScale(state) === true)?false:NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsshowzerovalues', true),
6061 labelsKMB: false,
6062 labelsKMG2: false,
6063 showLabelsOnHighlight: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showlabelsonhighlight', true),
@@ -6085,7 +6086,7 @@ var NETDATA = window.NETDATA || {};
6086 // Draw points at the edges of gaps in the data.
6087 // This improves visibility of small data segments or other data irregularities.
6088 drawGapEdgePoints: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawgapedgepoints', true),
6088 - connectSeparatedPoints: NETDATA.dataAttributeBoolean(state.element, 'dygraph-connectseparatedpoints', false),
6089 + connectSeparatedPoints: (this.isLogScale(state) === true)?false:NETDATA.dataAttributeBoolean(state.element, 'dygraph-connectseparatedpoints', false),
6090 pointSize: NETDATA.dataAttribute(state.element, 'dygraph-pointsize', 1),
6091
6092 // enabling this makes the chart with little square lines
@@ -6120,6 +6121,7 @@ var NETDATA = window.NETDATA || {};
6121 highlightSeriesBackgroundAlpha: NETDATA.dataAttribute(state.element, 'dygraph-highlightseriesbackgroundalpha', null), // TOO SLOW: (chart_type === 'stacked')?0.7:0.5,
6122 pointClickCallback: NETDATA.dataAttribute(state.element, 'dygraph-pointclickcallback', undefined),
6123 visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names),
6124 + logscale: (this.isLogScale(state) === true)?'y':undefined,
6125
6126 axes: {
6127 x: {
@@ -6132,6 +6134,7 @@ var NETDATA = window.NETDATA || {};
6134 }
6135 },
6136 y: {
6137 + logscale: (this.isLogScale(state) === true)?true:undefined,
6138 pixelsPerLabel: NETDATA.dataAttribute(state.element, 'dygraph-ypixelsperlabel', 15),
6139 axisLabelWidth: NETDATA.dataAttribute(state.element, 'dygraph-yaxislabelwidth', 50),
6140 axisLabelFormatter: function (y) {
@@ -6695,7 +6698,7 @@ var NETDATA = window.NETDATA || {};
6698 }
6699 };
6700
6698 - if(NETDATA.chartLibraries.dygraph.isSparkline(state)) {
6701 + if(NETDATA.chartLibraries.dygraph.isSparkline(state) === true) {
6702 state.tmp.dygraph_options.drawGrid = false;
6703 state.tmp.dygraph_options.drawAxis = false;
6704 state.tmp.dygraph_options.title = undefined;
@@ -7813,7 +7816,7 @@ var NETDATA = window.NETDATA || {};
7816 initialized: false,
7817 enabled: true,
7818 format: function(state) { void(state); return 'json'; },
7816 - options: function(state) { void(state); return 'ms|flip'; },
7819 + options: function(state) { return 'ms|flip' + (this.isLogScale(state)?'|abs':'').toString(); },
7820 legend: function(state) {
7821 return (this.isSparkline(state) === false && NETDATA.dataAttributeBoolean(state.element, 'legend', true) === true) ? 'right-side' : null;
7822 },
@@ -7825,11 +7828,21 @@ var NETDATA = window.NETDATA || {};
7828 },
7829 isSparkline: function(state) {
7830 if(typeof state.tmp.dygraph_sparkline === 'undefined') {
7828 - var t = NETDATA.dataAttribute(state.element, 'dygraph-theme', undefined);
7829 - state.tmp.dygraph_sparkline = (t === 'sparkline');
7831 + state.tmp.dygraph_sparkline = (this.theme(state) === 'sparkline');
7832 }
7833 return state.tmp.dygraph_sparkline;
7834 },
7835 + isLogScale: function(state) {
7836 + if(typeof state.tmp.dygraph_logscale === 'undefined') {
7837 + state.tmp.dygraph_logscale = (this.theme(state) === 'logscale');
7838 + }
7839 + return state.tmp.dygraph_logscale;
7840 + },
7841 + theme: function(state) {
7842 + if(typeof state.tmp.dygraph_theme === 'undefined')
7843 + state.tmp.dygraph_theme = NETDATA.dataAttribute(state.element, 'dygraph-theme', 'default');
7844 + return state.tmp.dygraph_theme;
7845 + },
7846 container_class: function(state) {
7847 if(this.legend(state) !== null)
7848 return 'netdata-container-with-legend';