Project

General

Profile

1
$(function() {
2
    // metrics-graphics
3
    altair_charts.metrics_graphics();
4
    // c3.js
5
    altair_charts.c3js();
6
    // chartist
7
    altair_charts.chartist_charts();
8
});
9

    
10
altair_charts = {
11
    metrics_graphics: function() {
12

    
13
        // linked charts
14
        var mg_linked_charts_id1 = '#mg_chart_linked_a',
15
            mg_linked_charts_id2 = '#mg_chart_linked_b',
16
            mg_linked_charts_id1_height = $(mg_linked_charts_id1).height(),
17
            mg_linked_charts_id2_height = $(mg_linked_charts_id2).height();
18

    
19
        if ($(mg_linked_charts_id1).length && $(mg_linked_charts_id2).length) {
20

    
21
            function mg_linked_charts() {
22

    
23
                var mg_linked_charts_id1_width = $(mg_linked_charts_id1).width(),
24
                    mg_linked_charts_id2_width = $(mg_linked_charts_id2).width();
25

    
26
                d3.json('data/mg_brief-1.min.json').then(function (data) {
27
                    data = MG.convert.date(data, 'date');
28
                    MG.data_graphic({
29
                        data: data,
30
                        linked: true,
31
                        width: mg_linked_charts_id1_width,
32
                        height: mg_linked_charts_id1_height,
33
                        xax_count: 4,
34
                        target: mg_linked_charts_id1
35
                    });
36
                });
37
                d3.json('data/mg_brief-2.min.json').then(function (data) {
38
                    data = MG.convert.date(data, 'date');
39
                    MG.data_graphic({
40
                        data: data,
41
                        area: false,
42
                        linked: true,
43
                        width: mg_linked_charts_id2_width,
44
                        height: mg_linked_charts_id2_height,
45
                        xax_count: 4,
46
                        target: mg_linked_charts_id2
47
                    });
48
                });
49
            }
50

    
51
            mg_linked_charts();
52

    
53
            $window.on('debouncedresize', function () {
54
                mg_linked_charts();
55
            })
56

    
57
        }
58

    
59
        // confidence band
60
        var mg_confidence_band_chart_id = '#mg_chart_confidence_band',
61
            mg_confidence_band_chart_height = $(mg_confidence_band_chart_id).height();
62

    
63
        if ( $(mg_confidence_band_chart_id).length ) {
64

    
65
            function mg_confidence_band_chart() {
66

    
67
                // chart width
68
                var mg_confidence_band_chart_width = $(mg_confidence_band_chart_id).width();
69

    
70
                d3.json('data/mg_confidence_band.min.json').then(function (data) {
71
                    data = MG.convert.date(data, 'date');
72
                    MG.data_graphic({
73
                        title: "Confidence Band",
74
                        description: "This is an example of a graphic with a confidence band and extended x-axis ticks enabled.",
75
                        data: data,
76
                        format: 'percentage',
77
                        width: mg_confidence_band_chart_width,
78
                        height: mg_confidence_band_chart_height,
79
                        target: mg_confidence_band_chart_id,
80
                        show_secondary_x_label: false,
81
                        show_confidence_band: ['l', 'u'],
82
                        x_extended_ticks: true
83
                    });
84
                });
85
            }
86

    
87
            mg_confidence_band_chart();
88

    
89
            $window.on('debouncedresize', function () {
90
                mg_confidence_band_chart();
91
            })
92

    
93
        }
94

    
95
        // some currency
96
        var mg_currency_chart_id = '#mg_chart_currency',
97
            mg_currency_charts_height = $(mg_confidence_band_chart_id).height();
98

    
99
        if ( $(mg_currency_chart_id).length ) {
100

    
101
            function mg_currency_chart() {
102

    
103
                // chart width
104
                var mg_currency_charts_width = $(mg_confidence_band_chart_id).width();
105

    
106
                d3.json('data/mg_some_currency.min.json').then(function (data) {
107
                    data = MG.convert.date(data, 'date');
108
                    MG.data_graphic({
109
                        title: "Some Currency",
110
                        description: "Here is an example that uses custom units for currency.",
111
                        data: data,
112
                        width: mg_currency_charts_width,
113
                        height: mg_currency_charts_height,
114
                        target: mg_currency_chart_id,
115
                        yax_units: '$'
116
                    });
117
                });
118

    
119
            }
120

    
121
            mg_currency_chart();
122

    
123
            $window.on('debouncedresize', function () {
124
                mg_currency_chart();
125
            })
126

    
127
        }
128

    
129
    },
130
    c3js: function() {
131

    
132
        var c3chart_bar_stacked_id = '#c3_chart_bar_stacked';
133

    
134
        if ( $(c3chart_bar_stacked_id).length ) {
135

    
136
            var c3chart_bar_stacked = c3.generate({
137
                bindto: c3chart_bar_stacked_id,
138
                data: {
139
                    columns: [
140
                        ['data1', -30, 200, 200, 400, -150, 250],
141
                        ['data2', 130, 100, -100, 200, -150, 50],
142
                        ['data3', -230, 200, 200, -300, 250, 250]
143
                    ],
144
                    type: 'bar',
145
                    groups: [
146
                        ['data1', 'data2']
147
                    ]
148
                },
149
                grid: {
150
                    y: {
151
                        lines: [
152
                            {
153
                                value: 0
154
                            }
155
                        ]
156
                    }
157
                },
158
                color: {
159
                    pattern: ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
160
                }
161
            });
162

    
163
            $(c3chart_bar_stacked_id).waypoint({
164
                handler: function() {
165
                    setTimeout(function () {
166
                        c3chart_bar_stacked.groups([
167
                            ['data1', 'data2', 'data3']
168
                        ])
169
                    }, 1000);
170

    
171
                    setTimeout(function () {
172
                        c3chart_bar_stacked.load({
173
                            columns: [
174
                                ['data4', 100, -50, 150, 200, -300, -100]
175
                            ]
176
                        });
177
                    }, 1500);
178

    
179
                    setTimeout(function () {
180
                        c3chart_bar_stacked.groups([
181
                            ['data1', 'data2', 'data3', 'data4']
182
                        ])
183
                    }, 2000);
184
                    this.destroy();
185
                },
186
                offset: '80%'
187
            });
188

    
189
            $window.on('debouncedresize', function () {
190
                c3chart_bar_stacked.resize();
191
            })
192

    
193
        }
194

    
195
        // donut chart
196
        var c3chart_donut_id = '#c3_chart_donut';
197

    
198
        if ( $(c3chart_donut_id).length ) {
199

    
200
            var c3chart_donut = c3.generate({
201
                bindto: c3chart_donut_id,
202
                data: {
203
                    columns: [
204
                        ['data1', 30],
205
                        ['data2', 120]
206
                    ],
207
                    type : 'donut',
208
                    onclick: function (d, i) { console.log("onclick", d, i); },
209
                    onmouseover: function (d, i) { console.log("onmouseover", d, i); },
210
                    onmouseout: function (d, i) { console.log("onmouseout", d, i); }
211
                },
212
                donut: {
213
                    title: "Iris Petal Width",
214
                    width: 40
215
                },
216
                color: {
217
                    pattern: ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
218
                }
219
            });
220

    
221
            $(c3chart_donut_id).waypoint({
222
                handler: function() {
223
                    setTimeout(function () {
224
                        c3chart_donut.load({
225
                            columns: [
226
                                ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2],
227
                                ["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3],
228
                                ["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8],
229
                            ]
230
                        });
231
                    }, 1500);
232

    
233
                    setTimeout(function () {
234
                        c3chart_donut.unload({
235
                            ids: 'data1'
236
                        });
237
                        c3chart_donut.unload({
238
                            ids: 'data2'
239
                        });
240
                    }, 2500);
241
                    this.destroy();
242
                },
243
                offset: '80%'
244
            });
245

    
246
            $window.on('debouncedresize', function () {
247
                c3chart_donut.resize();
248
            });
249

    
250
        }
251

    
252
        // spline chart
253
        var c3chart_spline_id = '#c3_chart_spline';
254

    
255
        if ( $(c3chart_spline_id).length ) {
256

    
257
            var c3chart_spline = c3.generate({
258
                bindto: c3chart_spline_id,
259
                data: {
260
                    columns: [
261
                        ['data1', 30, 200, 100, 400, 150, 250],
262
                        ['data2', 130, 100, 140, 200, 150, 50]
263
                    ],
264
                    type: 'spline'
265
                },
266
                color: {
267
                    pattern: ['#5E35B1', '#FB8C00']
268
                }
269
            });
270

    
271
            $window.on('debouncedresize', function () {
272
                c3chart_spline.resize();
273
            });
274

    
275
        }
276

    
277
        // area stacked
278
        var c3chart_area_stacked_id = '#c3_chart_area_stacked';
279

    
280
        if ( $(c3chart_area_stacked_id).length ) {
281

    
282
            var c3chart_area_stacked = c3.generate({
283
                bindto: c3chart_area_stacked_id,
284
                data: {
285
                    columns: [
286
                        ['data1', 300, 350, 300, 0, 0, 120],
287
                        ['data2', 130, 100, 140, 200, 150, 50]
288
                    ],
289
                    types: {
290
                        data1: 'area-spline',
291
                        data2: 'area-spline'
292
                    },
293
                    groups: [['data1', 'data2']]
294
                },
295
                color: {
296
                    pattern: ['#1565C0', '#727272']
297
                }
298
            });
299

    
300
            $window.on('debouncedresize', function () {
301
                c3chart_area_stacked.resize();
302
            });
303

    
304
        }
305

    
306
        // scatter chart
307
        var c3chart_scatter_id = '#c3_chart_scatter';
308

    
309
        if ( $(c3chart_scatter_id).length ) {
310

    
311
            var c3chart_scatter = c3.generate({
312
                bindto: c3chart_scatter_id,
313
                data: {
314
                    xs: {
315
                        setosa: 'setosa_x',
316
                        versicolor: 'versicolor_x',
317
                    },
318
                    // iris data from R
319
                    columns: [
320
                        ["setosa_x", 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.4, 3.0, 3.0, 4.0, 4.4, 3.9, 3.5, 3.8, 3.8, 3.4, 3.7, 3.6, 3.3, 3.4, 3.0, 3.4, 3.5, 3.4, 3.2, 3.1, 3.4, 4.1, 4.2, 3.1, 3.2, 3.5, 3.6, 3.0, 3.4, 3.5, 2.3, 3.2, 3.5, 3.8, 3.0, 3.8, 3.2, 3.7, 3.3],
321
                        ["versicolor_x", 3.2, 3.2, 3.1, 2.3, 2.8, 2.8, 3.3, 2.4, 2.9, 2.7, 2.0, 3.0, 2.2, 2.9, 2.9, 3.1, 3.0, 2.7, 2.2, 2.5, 3.2, 2.8, 2.5, 2.8, 2.9, 3.0, 2.8, 3.0, 2.9, 2.6, 2.4, 2.4, 2.7, 2.7, 3.0, 3.4, 3.1, 2.3, 3.0, 2.5, 2.6, 3.0, 2.6, 2.3, 2.7, 3.0, 2.9, 2.9, 2.5, 2.8],
322
                        ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2],
323
                        ["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3],
324
                    ],
325
                    type: 'scatter'
326
                },
327
                axis: {
328
                    x: {
329
                        label: 'Sepal.Width',
330
                        tick: {
331
                            fit: false
332
                        }
333
                    },
334
                    y: {
335
                        label: 'Petal.Width'
336
                    }
337
                },
338
                color: {
339
                    pattern: ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
340
                }
341
            });
342

    
343
            $(c3chart_scatter_id).waypoint({
344
                handler: function() {
345

    
346
                    setTimeout(function () {
347
                        c3chart_scatter.load({
348
                            xs: {
349
                                virginica: 'virginica_x'
350
                            },
351
                            columns: [
352
                                ["virginica_x", 3.3, 2.7, 3.0, 2.9, 3.0, 3.0, 2.5, 2.9, 2.5, 3.6, 3.2, 2.7, 3.0, 2.5, 2.8, 3.2, 3.0, 3.8, 2.6, 2.2, 3.2, 2.8, 2.8, 2.7, 3.3, 3.2, 2.8, 3.0, 2.8, 3.0, 2.8, 3.8, 2.8, 2.8, 2.6, 3.0, 3.4, 3.1, 3.0, 3.1, 3.1, 3.1, 2.7, 3.2, 3.3, 3.0, 2.5, 3.0, 3.4, 3.0],
353
                                ["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8],
354
                            ]
355
                        });
356
                    }, 1000);
357
                    setTimeout(function () {
358
                        c3chart_scatter.unload({
359
                            ids: 'setosa'
360
                        });
361
                    }, 2000);
362
                    setTimeout(function () {
363
                        c3chart_scatter.load({
364
                            columns: [
365
                                ["virginica", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2],
366
                            ]
367
                        });
368
                    }, 3000);
369

    
370
                    this.destroy();
371
                },
372
                offset: '80%'
373
            });
374

    
375
            $window.on('debouncedresize', function () {
376
                c3chart_scatter.resize();
377
            });
378

    
379
        }
380

    
381
        // live update gauge chart
382
        var c3_server_load_id = '#c3_server_load';
383
        if($(c3_server_load_id).length) {
384
            var server_1 = c3.generate({
385
                bindto: c3_server_load_id,
386
                data: {
387
                    columns: [
388
                        ['data', 24]
389
                    ],
390
                    type: 'gauge',
391
                    onclick: function (d, i) { console.log("onclick", d, i); },
392
                    onmouseover: function (d, i) { console.log("onmouseover", d, i); },
393
                    onmouseout: function (d, i) { console.log("onmouseout", d, i); }
394
                },
395
                gauge: {
396
                    label: {
397
                        format: function(value, ratio) {
398
                            return value;
399
                        },
400
                        show: false
401
                    },
402
                    min: 0,
403
                    max: 100,
404
                    width: 36
405
                },
406
                color: {
407
                    pattern: ['#D32F2F', '#F57C00', '#388E3C' ], // the three color levels for the percentage values.
408
                    threshold: {
409
                        values: [25, 50, 100]
410
                    }
411
                },
412
                size: {
413
                    height: 180
414
                }
415
            });
416

    
417
            setInterval(function () {
418
                var randUsage = Math.floor(Math.random() * 100);
419
                server_1.load({
420
                    columns: [['data', randUsage]]
421
                });
422
            }, 2000);
423

    
424
        }
425

    
426
    },
427
    chartist_charts: function() {
428
        // simple lines
429
        var ch_simple_lines = new Chartist.Line('#chartist_simple_lines', {
430
            labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
431
            series: [
432
                [12, 9, 7, 8, 5],
433
                [2, 1, 3.5, 7, 3],
434
                [1, 3, 4, 5, 6]
435
            ]
436
        }, {
437
            fullWidth: true,
438
            chartPadding: {
439
                right: 40
440
            }
441
        });
442
        $window.on('resize',function() {
443
            ch_simple_lines.update();
444
        });
445

    
446

    
447
        // line chart with area
448
        var ch_line_area = new Chartist.Line('#chartist_line_area', {
449
            labels: [1, 2, 3, 4, 5, 6, 7, 8],
450
            series: [
451
                [5, 9, 7, 8, 5, 3, 5, 4]
452
            ]
453
        }, {
454
            low: 0,
455
            showArea: true
456
        });
457
        $window.on('resize',function() {
458
            ch_line_area.update();
459
        });
460

    
461
        // bi-polar line chart with area only
462
        var ch_bipolar = new Chartist.Line('#chartist_bipolar', {
463
            labels: [1, 2, 3, 4, 5, 6, 7, 8],
464
            series: [
465
                [1, 2, 3, 1, -2, 0, 1, 0],
466
                [-2, -1, -2, -1, -2.5, -1, -2, -1],
467
                [0, 0, 0, 1, 2, 2.5, 2, 1],
468
                [2.5, 2, 1, 0.5, 1, 0.5, -1, -2.5]
469
            ]
470
        }, {
471
            high: 3,
472
            low: -3,
473
            showArea: true,
474
            showLine: false,
475
            showPoint: false,
476
            fullWidth: true,
477
            axisX: {
478
                showLabel: false,
479
                showGrid: false
480
            }
481
        });
482
        $window.on('resize',function() {
483
            ch_bipolar.update();
484
        });
485

    
486
        // distributed series
487
        var ch_distributed_series = new Chartist.Bar('#chartist_distributed_series', {
488
            labels: ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'],
489
            series: [20, 60, 120, 200, 180, 20, 10]
490
        }, {
491
            distributeSeries: true
492
        });
493
        $window.on('resize',function() {
494
            ch_distributed_series.update();
495
        });
496

    
497
        // simple pie chart
498
        var data = {
499
            series: [5, 3, 4]
500
        };
501

    
502
        var sum = function(a, b) { return a + b };
503

    
504
        var ch_simple_pie = new Chartist.Pie('#chartist_simple_pie', data, {
505
            labelInterpolationFnc: function(value) {
506
                return Math.round(value / data.series.reduce(sum) * 100) + '%';
507
            }
508
        });
509
        $window.on('resize',function() {
510
            ch_simple_pie.update();
511
        });
512

    
513
        // pie chart with custom labels
514
        var data = {
515
            labels: ['Bananas', 'Apples', 'Grapes'],
516
            series: [20, 15, 40]
517
        };
518

    
519
        var options = {
520
            labelInterpolationFnc: function(value) {
521
                return value[0]
522
            }
523
        };
524

    
525
        var responsiveOptions = [
526
            ['screen and (max-width: 767px)', {
527
                chartPadding: 50,
528
                labelOffset: 50,
529
                labelDirection: 'explode',
530
                labelInterpolationFnc: function(value) {
531
                    return value;
532
                }
533
            }],
534
            ['screen and (min-width: 768px)', {
535
                chartPadding: 30,
536
                labelOffset: 60,
537
                labelDirection: 'explode',
538
                labelInterpolationFnc: function(value) {
539
                    return value;
540
                }
541
            }],
542
            ['screen and (min-width: 1024px)', {
543
                labelOffset: 80,
544
                chartPadding: 20
545
            }]
546
        ];
547

    
548
        var ch_pie_custom_labels = new Chartist.Pie('#chartist_pie_custom_labels', data, options, responsiveOptions);
549
        $window.on('resize',function() {
550
            ch_pie_custom_labels.update();
551
        });
552

    
553
        // animating a donut with svg.animate
554
        var chart = new Chartist.Pie('#chartist_donut_animate', {
555
            series: [10, 20, 50, 20, 5, 50, 15],
556
            labels: [1, 2, 3, 4, 5, 6, 7]
557
        }, {
558
            donut: true,
559
            showLabel: false
560
        });
561
        $window.on('resize',function() {
562
            chart.update();
563
        });
564

    
565
        chart.on('draw', function(data) {
566
            if(data.type === 'slice') {
567
                // Get the total path length in order to use for dash array animation
568
                var pathLength = data.element._node.getTotalLength();
569

    
570
                // Set a dasharray that matches the path length as prerequisite to animate dashoffset
571
                data.element.attr({
572
                    'stroke-dasharray': pathLength + 'px ' + pathLength + 'px'
573
                });
574

    
575
                // Create animation definition while also assigning an ID to the animation for later sync usage
576
                var animationDefinition = {
577
                    'stroke-dashoffset': {
578
                        id: 'anim' + data.index,
579
                        dur: 1000,
580
                        from: -pathLength + 'px',
581
                        to:  '0px',
582
                        easing: Chartist.Svg.Easing.easeOutQuint,
583
                        // We need to use `fill: 'freeze'` otherwise our animation will fall back to initial (not visible)
584
                        fill: 'freeze'
585
                    }
586
                };
587

    
588
                // If this was not the first slice, we need to time the animation so that it uses the end sync event of the previous animation
589
                if(data.index !== 0) {
590
                    animationDefinition['stroke-dashoffset'].begin = 'anim' + (data.index - 1) + '.end';
591
                }
592

    
593
                // We need to set an initial value before the animation starts as we are not in guided mode which would do that for us
594
                data.element.attr({
595
                    'stroke-dashoffset': -pathLength + 'px'
596
                });
597

    
598
                // We can't use guided mode as the animations need to rely on setting begin manually
599
                // See http://gionkunz.github.io/chartist-js/api-documentation.html#chartistsvg-function-animate
600
                data.element.animate(animationDefinition, false);
601
            }
602
        });
603

    
604
        // For the sake of the example we update the chart every time it's created with a delay of 8 seconds
605
        chart.on('created', function() {
606
            if(window.__anim21278907124) {
607
                clearTimeout(window.__anim21278907124);
608
                window.__anim21278907124 = null;
609
            }
610
            window.__anim21278907124 = setTimeout(chart.update.bind(chart), 10000);
611
        });
612

    
613

    
614
    }
615
};
(75-75/114)