Project

General

Profile

Revision bd5905c3

IDbd5905c31ba7af96dcf243b0d99a58868d540b54
Parent f36cbd91
Child 80b3c990

Added by Francois POIROTTE almost 13 years ago

Meilleur algo de zoom/dézoome sur VigiGraph (#865)

Lorsqu'on zoome, le zoom porte désormais sur la partie centrale du
graphe. Lorsqu'on dézoome, la partie précédemment affichée devient la
nouvelle partie centrale du graphe et des données supplémentaires sont
affichées équitablement de chaque côté.
Ce changement rend plus facile le repérage lors de la navigation dans
les graphes.

Change-Id: I25174026337318e1008589e180081612b6cf1a54
Refs: #865.
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/319
Tested-by: Build system <>
Reviewed-by: Aurelien BOMPARD <>

View differences:

vigigraph/public/js/graph.js
156 156
            image: app_path + 'images/zoom-in.png',
157 157
            tooltip: _("Zoom in"),
158 158
            onClick: function() {
159
                this.updateZoom(0.5);
159
                this.updateZoom(true);
160 160
            }.bind(this)
161 161
        });
162 162

  
......
164 164
            image: app_path + 'images/zoom-out.png',
165 165
            tooltip: _("Zoom out"),
166 166
            onClick: function() {
167
                this.updateZoom(2);
167
                this.updateZoom(false);
168 168
            }.bind(this)
169 169
        });
170 170

  
......
283 283
        window.updateURI();
284 284
    },
285 285

  
286
    updateZoom: function (factor) {
287
        this.options.duration = parseInt(this.options.duration, 10) * factor;
286
    updateZoom: function (zoom_in) {
287
        var start = this.options.start;
288
        var factor = zoom_in ? 0.5 : 2;
289
        this.options.duration = parseInt(this.options.duration, 10);
290
        if (start !== null) {
291
            // On zoom sur la partie centrale du graphe.
292
            if (zoom_in) start += this.options.duration * 0.25;
293
            // On dézoome "par les 2 côtés".
294
            else start -= this.options.duration * 0.5;
295
            this.options.start = start;
296
        }
297
        this.options.duration *= factor;
288 298
        // Période minimale d'affichage : 1 minute.
289 299
        if (this.options.duration < 60)
290 300
            this.options.duration = 60;

Also available in: Unified diff