@cryptotaxi247 / netdata-1 / commits / 63f718edc

fixed dashboard toolbox zoom in/out to complement each other

Costa Tsaousis (ktsaou) committed Apr 17, 2016 at 05:28 UTC 63f718edcfeeaef782f7388085bf67e8e2baa210
2 files changed +22 -19
web/dashboard.js
+21 -18
@@ -261,10 +261,10 @@
261 color_fill_opacity_area: 0.2,
262 color_fill_opacity_stacked: 0.8,
263
264 - pan_and_zoom_step: 0.1, // the increment when panning and zooming with the toolbox
265 - pan_and_zoom_step_multiplier_shift: 5,
266 - pan_and_zoom_step_multiplier_alt: 10,
267 - pan_and_zoom_step_multiplier_control: 2,
264 + pan_and_zoom_factor: 0.25, // the increment when panning and zooming with the toolbox
265 + pan_and_zoom_factor_multiplier_control: 2.0,
266 + pan_and_zoom_factor_multiplier_shift: 3.0,
267 + pan_and_zoom_factor_multiplier_alt: 4.0,
268
269 setOptionCallback: function() { ; }
270 },
@@ -2159,14 +2159,17 @@
2159 if(this.library.toolboxPanAndZoom !== null) {
2160
2161 function get_pan_and_zoom_step(event) {
2162 - if (event.shiftKey)
2163 - return NETDATA.options.current.pan_and_zoom_step * NETDATA.options.current.pan_and_zoom_step_multiplier_shift;
2162 + if (event.ctrlKey)
2163 + return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_control;
2164 +
2165 + else if (event.shiftKey)
2166 + return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_shift;
2167 +
2168 else if (event.altKey)
2165 - return NETDATA.options.current.pan_and_zoom_step * NETDATA.options.current.pan_and_zoom_step_multiplier_alt;
2166 - else if (event.ctrlKey)
2167 - return NETDATA.options.current.pan_and_zoom_step * NETDATA.options.current.pan_and_zoom_step_multiplier_control;
2169 + return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_alt;
2170 +
2171 else
2169 - return NETDATA.options.current.pan_and_zoom_step;
2172 + return NETDATA.options.current.pan_and_zoom_factor;
2173 }
2174
2175 this.element_legend_childs.toolbox.className += ' netdata-legend-toolbox';
@@ -2178,9 +2181,9 @@
2181 this.element_legend_childs.toolbox_left.onclick = function(e) {
2182 e.preventDefault();
2183
2181 - var dt = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
2182 - var before = that.view_before - dt;
2183 - var after = that.view_after - dt;
2184 + var step = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
2185 + var before = that.view_before - step;
2186 + var after = that.view_after - step;
2187 if(after >= that.netdata_first)
2188 that.library.toolboxPanAndZoom(that, after, before);
2189 };
@@ -2221,9 +2224,9 @@
2224 this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_right);
2225 this.element_legend_childs.toolbox_right.onclick = function(e) {
2226 e.preventDefault();
2224 - var dt = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
2225 - var before = that.view_before + dt;
2226 - var after = that.view_after + dt;
2227 + var step = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
2228 + var before = that.view_before + step;
2229 + var after = that.view_after + step;
2230 if(before <= that.netdata_last)
2231 that.library.toolboxPanAndZoom(that, after, before);
2232 };
@@ -2245,7 +2248,7 @@
2248 this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomin);
2249 this.element_legend_childs.toolbox_zoomin.onclick = function(e) {
2250 e.preventDefault();
2248 - var dt = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
2251 + var dt = ((that.view_before - that.view_after) * (get_pan_and_zoom_step(e) * 0.8) / 2);
2252 var before = that.view_before - dt;
2253 var after = that.view_after + dt;
2254 that.library.toolboxPanAndZoom(that, after, before);
@@ -2267,7 +2270,7 @@
2270 this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomout);
2271 this.element_legend_childs.toolbox_zoomout.onclick = function(e) {
2272 e.preventDefault();
2270 - var dt = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
2273 + var dt = (((that.view_before - that.view_after) / (1.0 - (get_pan_and_zoom_step(e) * 0.8)) - (that.view_before - that.view_after)) / 2);
2274 var before = that.view_before + dt;
2275 var after = that.view_after - dt;
2276
web/index.html
+1 -1
@@ -330,7 +330,7 @@
330 </script>
331
332 <!-- load the dashboard manager - it will do the rest -->
333 - <script type="text/javascript" src="dashboard.js?v29"></script>
333 + <script type="text/javascript" src="dashboard.js?v30"></script>
334 </head>
335
336 <body data-spy="scroll" data-target="#sidebar">