allow stacked charts to zoom vertically when dimensions are selected; fixes #3324
Costa Tsaousis (ktsaou) committed
Jan 27, 2018 at 13:38 UTC
5c13ef502eca5aedd9b234bee13ff1f3bc9c5db6
1 file changed
+19
-11
web/dashboard.js
+19
-11
@@ -6072,9 +6072,15 @@ var NETDATA = window.NETDATA || {};
6072
colors: state.chartColors(),
6073
labels: data.result.labels,
6074
labelsDivWidth: state.chartWidth() - 70,
6075
+ includeZero: state.tmp.dygraph_include_zero,
6076
visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names)
6077
};
6078
6079
+ if(state.tmp.dygraph_chart_type === 'stacked') {
6080
+ if(options.includeZero === true && state.dimensions_visibility.countSelected() < options.visibility.length)
6081
+ options.includeZero = 0;
6082
+ }
6083
+
6084
if(!NETDATA.chartLibraries.dygraph.isSparkline(state)) {
6085
options.ylabel = state.units_current; // (state.units_desired === 'auto')?"":state.units_current;
6086
}
@@ -6157,16 +6163,18 @@ var NETDATA = window.NETDATA || {};
6163
if(NETDATA.options.debug.dygraph === true || state.debug === true)
6164
state.log('dygraphChartCreate()');
6165
6160
- var chart_type = NETDATA.dataAttribute(state.element, 'dygraph-type', state.chart.chart_type);
6161
- if(chart_type === 'stacked' && data.dimensions === 1) chart_type = 'area';
6162
- if(chart_type === 'stacked' && NETDATA.chartLibraries.dygraph.isLogScale(state) === true) chart_type = 'area';
6166
+ state.tmp.dygraph_chart_type = NETDATA.dataAttribute(state.element, 'dygraph-type', state.chart.chart_type);
6167
+ if(state.tmp.dygraph_chart_type === 'stacked' && data.dimensions === 1) state.tmp.dygraph_chart_type = 'area';
6168
+ if(state.tmp.dygraph_chart_type === 'stacked' && NETDATA.chartLibraries.dygraph.isLogScale(state) === true) state.tmp.dygraph_chart_type = 'area';
6169
6170
var highlightCircleSize = (NETDATA.chartLibraries.dygraph.isSparkline(state) === true)?3:4;
6171
6172
var smooth = (NETDATA.dygraph.smooth === true)
6167
- ?(NETDATA.dataAttributeBoolean(state.element, 'dygraph-smooth', (chart_type === 'line' && NETDATA.chartLibraries.dygraph.isSparkline(state) === false)))
6173
+ ?(NETDATA.dataAttributeBoolean(state.element, 'dygraph-smooth', (state.tmp.dygraph_chart_type === 'line' && NETDATA.chartLibraries.dygraph.isSparkline(state) === false)))
6174
:false;
6175
6176
+ state.tmp.dygraph_include_zero = NETDATA.dataAttribute(state.element, 'dygraph-includezero', (state.tmp.dygraph_chart_type === 'stacked'));
6177
+
6178
state.tmp.dygraph_options = {
6179
colors: NETDATA.dataAttribute(state.element, 'dygraph-colors', state.chartColors()),
6180
@@ -6187,7 +6195,7 @@ var NETDATA = window.NETDATA || {};
6195
labelsKMG2: false,
6196
showLabelsOnHighlight: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showlabelsonhighlight', true),
6197
hideOverlayOnMouseOut: NETDATA.dataAttributeBoolean(state.element, 'dygraph-hideoverlayonmouseout', true),
6190
- includeZero: NETDATA.dataAttribute(state.element, 'dygraph-includezero', (chart_type === 'stacked')),
6198
+ includeZero: state.tmp.dygraph_include_zero,
6199
xRangePad: NETDATA.dataAttribute(state.element, 'dygraph-xrangepad', 0),
6200
yRangePad: NETDATA.dataAttribute(state.element, 'dygraph-yrangepad', 1),
6201
valueRange: NETDATA.dataAttribute(state.element, 'dygraph-valuerange', [ null, null ]),
@@ -6199,7 +6207,7 @@ var NETDATA = window.NETDATA || {};
6207
6208
// The width of the lines connecting data points.
6209
// This can be used to increase the contrast or some graphs.
6202
- strokeWidth: NETDATA.dataAttribute(state.element, 'dygraph-strokewidth', ((chart_type === 'stacked')?0.1:((smooth === true)?1.5:0.7))),
6210
+ strokeWidth: NETDATA.dataAttribute(state.element, 'dygraph-strokewidth', ((state.tmp.dygraph_chart_type === 'stacked')?0.1:((smooth === true)?1.5:0.7))),
6211
strokePattern: NETDATA.dataAttribute(state.element, 'dygraph-strokepattern', undefined),
6212
6213
// The size of the dot to draw on each point in pixels (see drawPoints).
@@ -6220,14 +6228,14 @@ var NETDATA = window.NETDATA || {};
6228
// Draw a border around graph lines to make crossing lines more easily
6229
// distinguishable. Useful for graphs with many lines.
6230
strokeBorderColor: NETDATA.dataAttribute(state.element, 'dygraph-strokebordercolor', NETDATA.themes.current.background),
6223
- strokeBorderWidth: NETDATA.dataAttribute(state.element, 'dygraph-strokeborderwidth', (chart_type === 'stacked')?0.0:0.0),
6224
- fillGraph: NETDATA.dataAttribute(state.element, 'dygraph-fillgraph', (chart_type === 'area' || chart_type === 'stacked')),
6231
+ strokeBorderWidth: NETDATA.dataAttribute(state.element, 'dygraph-strokeborderwidth', (state.tmp.dygraph_chart_type === 'stacked')?0.0:0.0),
6232
+ fillGraph: NETDATA.dataAttribute(state.element, 'dygraph-fillgraph', (state.tmp.dygraph_chart_type === 'area' || state.tmp.dygraph_chart_type === 'stacked')),
6233
fillAlpha: NETDATA.dataAttribute(state.element, 'dygraph-fillalpha',
6226
- ((chart_type === 'stacked')
6234
+ ((state.tmp.dygraph_chart_type === 'stacked')
6235
?NETDATA.options.current.color_fill_opacity_stacked
6236
:NETDATA.options.current.color_fill_opacity_area)
6237
),
6230
- stackedGraph: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraph', (chart_type === 'stacked')),
6238
+ stackedGraph: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraph', (state.tmp.dygraph_chart_type === 'stacked')),
6239
stackedGraphNaNFill: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraphnanfill', 'none'),
6240
drawAxis: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawaxis', true),
6241
axisLabelFontSize: NETDATA.dataAttribute(state.element, 'dygraph-axislabelfontsize', 10),
@@ -6243,7 +6251,7 @@ var NETDATA = window.NETDATA || {};
6251
valueFormatter: NETDATA.dataAttribute(state.element, 'dygraph-valueformatter', undefined),
6252
highlightCircleSize: NETDATA.dataAttribute(state.element, 'dygraph-highlightcirclesize', highlightCircleSize),
6253
highlightSeriesOpts: NETDATA.dataAttribute(state.element, 'dygraph-highlightseriesopts', null), // TOO SLOW: { strokeWidth: 1.5 },
6246
- highlightSeriesBackgroundAlpha: NETDATA.dataAttribute(state.element, 'dygraph-highlightseriesbackgroundalpha', null), // TOO SLOW: (chart_type === 'stacked')?0.7:0.5,
6254
+ highlightSeriesBackgroundAlpha: NETDATA.dataAttribute(state.element, 'dygraph-highlightseriesbackgroundalpha', null), // TOO SLOW: (state.tmp.dygraph_chart_type === 'stacked')?0.7:0.5,
6255
pointClickCallback: NETDATA.dataAttribute(state.element, 'dygraph-pointclickcallback', undefined),
6256
visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names),
6257
logscale: (NETDATA.chartLibraries.dygraph.isLogScale(state) === true)?'y':undefined,