Project

General

Profile

Revision ce020707

IDce0207075eab85b5d7dc17fbc6717c15e93033bc
Parent a4dfb6e7
Child f7ce3376

Added by Francois POIROTTE over 13 years ago

Amélioration de la robustesse de VigiRRD et VigiGraph (cf. #376) :
- VigiGraph n'essaye plus de transmettre des valeurs non-entières à VigiRRD (il arrondi à l'inférieur à la place),
- VigiGraph empêche de descendre en dessous de la minute au niveau du zoom,
- VigiGraph ne plante plus lorsqu'on dézoome trop (ie: lorsque la date de début d'affichage devient < Epoch),
- VigiRRD est plus laxiste dans ce qu'il accepte lorsqu'il graphe des données (s'il reçoit un flottant, il arrondi la valeur à l'inférieur).

git-svn-id: https://vigilo-dev.si.c-s.fr/svn@5407 b22e2e97-25c9-44ff-b637-2e5ceca36478

View differences:

vigigraph/public/js/graph.js
106 106
            }.bind(this)
107 107
        });
108 108

  
109
        this.zoom_in = new Jx.Button({
110
            image: app_path + 'images/zoom-in.png',
111
            tooltip: _("Zoom in"),
112
            onClick: function() {
113
                this.updateZoom(0.5);
114
            }.bind(this)
115
        });
116

  
117
        this.zoom_out = new Jx.Button({
118
            image: app_path + 'images/zoom-out.png',
119
            tooltip: _("Zoom out"),
120
            onClick: function() {
121
                this.updateZoom(2);
122
            }.bind(this)
123
        });
124

  
109 125
        toolbar.add(
110 126
            this.refresh_button,
111 127
            timeframe,
......
141 157
                    this.updateGraph();
142 158
                }.bind(this)
143 159
            }),
144
            new Jx.Button({
145
                image: app_path + 'images/zoom-in.png',
146
                tooltip: _("Zoom in"),
147
                onClick: function() {
148
                    if (this.options.duration > 1) {
149
                        this.options.duration /= 2;
150
                        this.updateGraph();
151
                    }
152
                }.bind(this)
153
            }),
154
            new Jx.Button({
155
                image: app_path + 'images/zoom-out.png',
156
                tooltip: _("Zoom out"),
157
                onClick: function() {
158
                    this.options.duration *= 2;
159
                    this.updateGraph();
160
                }.bind(this)
161
            }),
160
            this.zoom_in,
161
            this.zoom_out,
162 162
            this.indicators,
163 163
            new Jx.Button({
164 164
                image: app_path + 'images/document-print-small.png',
......
215 215
        this.updateURI();
216 216
    },
217 217

  
218
    updateZoom: function (factor) {
219
        this.options.duration = parseInt(this.options.duration * factor);
220
        // Période minimale d'affichage : 1 minute.
221
        if (this.options.duration < 60)
222
            this.options.duration = 60;
223
        // On (dés)active le bouton de zoom en avant au besoin.
224
        this.zoom_in.setEnabled(this.options.duration != 60);
225
        this.updateGraph();
226
    },
227

  
218 228
    updateURI: function () {
219 229
        var graphs = [];
220 230
        var uri = new URI();
......
231 241
    },
232 242

  
233 243
    getStartTime: function () {
234
        if (this.options.start == null)
244
        var start = this.options.start;
245
        if (start == null)
235 246
            // @TODO: cette heure est en localtime a priori.
236
            return (new Date() / 1000).toInt() - this.options.duration;
237
        return this.options.start;
247
            start = (new Date() / 1000).toInt() - this.options.duration;
248
        if (start < 0)
249
            return 0;
250
        return start;
238 251
    },
239 252

  
240 253
    exportCSV: function (menuItem) {

Also available in: Unified diff