]> arthur.barton.de Git - netdata.git/commitdiff
fixed dashboard toolbox zoom in/out to complement each other
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 17 Apr 2016 02:28:18 +0000 (05:28 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 17 Apr 2016 02:28:18 +0000 (05:28 +0300)
web/dashboard.js
web/index.html

index 04a33d21a665686ce47332a235894a768b8f7337..16f578f1f2f4871623062eb97a488486ba51c8c9 100644 (file)
                        color_fill_opacity_area: 0.2,
                        color_fill_opacity_stacked: 0.8,
 
-                       pan_and_zoom_step: 0.1,         // the increment when panning and zooming with the toolbox
-                       pan_and_zoom_step_multiplier_shift: 5,
-                       pan_and_zoom_step_multiplier_alt: 10,
-                       pan_and_zoom_step_multiplier_control: 2,
+                       pan_and_zoom_factor: 0.25,              // the increment when panning and zooming with the toolbox
+                       pan_and_zoom_factor_multiplier_control: 2.0,
+                       pan_and_zoom_factor_multiplier_shift: 3.0,
+                       pan_and_zoom_factor_multiplier_alt: 4.0,
 
                        setOptionCallback: function() { ; }
                },
                                if(this.library.toolboxPanAndZoom !== null) {
 
                                        function get_pan_and_zoom_step(event) {
-                                               if (event.shiftKey)
-                                                       return NETDATA.options.current.pan_and_zoom_step * NETDATA.options.current.pan_and_zoom_step_multiplier_shift;
+                                               if (event.ctrlKey)
+                                                       return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_control;
+
+                                               else if (event.shiftKey)
+                                                       return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_shift;
+
                                                else if (event.altKey)
-                                                       return NETDATA.options.current.pan_and_zoom_step * NETDATA.options.current.pan_and_zoom_step_multiplier_alt;
-                                               else if (event.ctrlKey)
-                                                       return NETDATA.options.current.pan_and_zoom_step * NETDATA.options.current.pan_and_zoom_step_multiplier_control;
+                                                       return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_alt;
+
                                                else
-                                                       return NETDATA.options.current.pan_and_zoom_step;
+                                                       return NETDATA.options.current.pan_and_zoom_factor;
                                        }
 
                                        this.element_legend_childs.toolbox.className += ' netdata-legend-toolbox';
                                        this.element_legend_childs.toolbox_left.onclick = function(e) {
                                                e.preventDefault();
 
-                                               var dt = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
-                                               var before = that.view_before - dt;
-                                               var after = that.view_after - dt;
+                                               var step = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
+                                               var before = that.view_before - step;
+                                               var after = that.view_after - step;
                                                if(after >= that.netdata_first)
                                                        that.library.toolboxPanAndZoom(that, after, before);
                                        };
                                        this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_right);
                                        this.element_legend_childs.toolbox_right.onclick = function(e) {
                                                e.preventDefault();
-                                               var dt = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
-                                               var before = that.view_before + dt;
-                                               var after = that.view_after + dt;
+                                               var step = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
+                                               var before = that.view_before + step;
+                                               var after = that.view_after + step;
                                                if(before <= that.netdata_last)
                                                        that.library.toolboxPanAndZoom(that, after, before);
                                        };
                                        this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomin);
                                        this.element_legend_childs.toolbox_zoomin.onclick = function(e) {
                                                e.preventDefault();
-                                               var dt = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
+                                               var dt = ((that.view_before - that.view_after) * (get_pan_and_zoom_step(e) * 0.8) / 2);
                                                var before = that.view_before - dt;
                                                var after = that.view_after + dt;
                                                that.library.toolboxPanAndZoom(that, after, before);
                                        this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomout);
                                        this.element_legend_childs.toolbox_zoomout.onclick = function(e) {
                                                e.preventDefault();
-                                               var dt = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
+                                               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);
                                                var before = that.view_before + dt;
                                                var after = that.view_after - dt;
 
index 267fc558197992af1dd2adb506c92e2ab67c0705..4f6d259597e42c7b5eccf170ea40d97537e5e6aa 100644 (file)
        </script>
 
        <!-- load the dashboard manager - it will do the rest -->
-       <script type="text/javascript" src="dashboard.js?v29"></script>
+       <script type="text/javascript" src="dashboard.js?v30"></script>
 </head>
 
 <body data-spy="scroll" data-target="#sidebar">