Bonjour,

Ça fait peu de temps que je me suis mis au technologies du web, et je patauge encore entre les différentes bibliothèques javascript. En ce moment j'essaye de modifier un exemple de heatmap ( http://www.highcharts.com/demo/heatmap-canvas )

fonction:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
 
 
    */
    (function (H) {
        var Series = H.Series,
            each = H.each;
 
        /**
         * Create a hidden canvas to draw the graph on. The contents is later copied over
         * to an SVG image element.
         */
        Series.prototype.getContext = function () {
            if (!this.canvas) {
                this.canvas = document.createElement('canvas');
                this.canvas.setAttribute('width', this.chart.chartWidth);
                this.canvas.setAttribute('height', this.chart.chartHeight);
                this.image = this.chart.renderer.image('', 0, 0, this.chart.chartWidth, this.chart.chartHeight).add(this.group);
                this.ctx = this.canvas.getContext('2d');
            }
            return this.ctx;
        };
 
        /**
         * Draw the canvas image inside an SVG image
         */
        Series.prototype.canvasToSVG = function () {
            this.image.attr({ href: this.canvas.toDataURL('image/png') });
        };
 
        /**
         * Wrap the drawPoints method to draw the points in canvas instead of the slower SVG,
         * that requires one shape each point.
         */
        H.wrap(H.seriesTypes.heatmap.prototype, 'drawPoints', function () {
 
            var ctx = this.getContext();
 
            if (ctx) {
 
                // draw the columns
                each(this.points, function (point) {
                    var plotY = point.plotY,
                        shapeArgs;
 
                    if (plotY !== undefined && !isNaN(plotY) && point.y !== null) {
                        shapeArgs = point.shapeArgs;
 
                        ctx.fillStyle = point.pointAttr[''].fill;
                        ctx.fillRect(shapeArgs.x, shapeArgs.y, shapeArgs.width, shapeArgs.height);
                    }
                });
 
                this.canvasToSVG();
 
            } else {
                this.chart.showLoading('Your browser doesn\'t support HTML5 canvas, <br>please use a modern browser');
 
                // Uncomment this to provide low-level (slow) support in oldIE. It will cause script errors on
                // charts with more than a few thousand points.
                // arguments[0].call(this);
            }
        });
        H.seriesTypes.heatmap.prototype.directTouch = false; // Use k-d-tree
    }(Highcharts));
 
 
    var start;
    $('#container').highcharts({
 
        data: {
            csv: document.getElementById('csv').innerHTML,
            parsed: function () {
                start = +new Date();
            }
        },
 
        chart: {
            type: 'heatmap',
            margin: [60, 10, 80, 50]
        },
 
 
        title: {
            text: 'Highcharts extended heat map',
            align: 'left',
            x: 40
        },
 
        subtitle: {
            text: 'Temperature variation by day and hour through 2013',
            align: 'left',
            x: 40
        },
 
        xAxis: {
            type: 'datetime',
            min: Date.UTC(2013, 0, 1),
            max: Date.UTC(2014, 0, 1),
            labels: {
                align: 'left',
                x: 5,
                y: 14,
                format: '{value:%B}' // long month
            },
            showLastLabel: false,
            tickLength: 16
        },
 
        yAxis: {
            title: {
                text: null
            },
            labels: {
                format: '{value}:00'
            },
            minPadding: 0,
            maxPadding: 0,
            startOnTick: false,
            endOnTick: false,
            tickPositions: [0, 6, 12, 18, 24],
            tickWidth: 1,
            min: 0,
            max: 23,
            reversed: true
        },
 
        colorAxis: {
            stops: [
                [0, '#3060cf'],
                [0.5, '#fffbbc'],
                [0.9, '#c4463a'],
                [1, '#c4463a']
            ],
            min: -15,
            max: 25,
            startOnTick: false,
            endOnTick: false,
            labels: {
                format: '{value}℃'
            }
        },
 
        series: [{
            borderWidth: 0,
            nullColor: '#EFEFEF',
            colsize: 24 * 36e5, // one day
            tooltip: {
                headerFormat: 'Temperature<br/>',
                pointFormat: '{point.x:%e %b, %Y} {point.y}:00: <b>{point.value} ℃</b>'
            },
            turboThreshold: Number.MAX_VALUE // #3404, remove after 4.0.5 release
        }]
 
    });
    console.log('Rendered in ' + (new Date() - start) + ' ms'); // eslint-disable-line no-console
 
});

Data :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
<pre id="csv" style="display: none">Date,Time,Temperature
2013-01-01,0,1.3
2013-01-01,1,1.4
2013-01-01,2,1.6
2013-01-01,3,2.0
2013-01-01,4,2.4
2013-01-01,5,17
2013-01-01,6,3.1
2013-01-01,7,2.8
2013-01-01,8,2.8
2013-01-01,9,2.7
2013-01-01,10,3.4
2013-01-01,11,2.6
2013-01-01,12,2.4
2013-01-01,13,2.9
2013-01-01,15,2.8
2013-01-01,14,2.8
2013-01-01,16,2.2
2013-01-01,18,1.7
2013-01-01,17,1.8
2013-01-01,19,1.8
2013-01-01,20,1.8
2013-01-01,21,1.7
2013-01-01,22,1.7
2013-01-01,23,2.2
2013-01-02,0,2.2
2013-01-02,1,2.1
2013-01-02,2,1.9
2013-01-02,3,2.0
2013-01-02,4,2.0
2013-01-02,5,2.0
...
</pre>
Ce que j'aimerais faire c'est utiliser ce modèle mais à partir d'une matrice à axes complètement différents avec une data du même type que je pourrais produire en perl... Malheureusement je n'arrive pas à introduire des nouvelles catégories dans la fonction et j'ai du mal a voir ce qui cloche.
J'avoue que je patauge entre tout ces formats de data que je peu voir chez highcharts ou protovis...

Voilà c'est un petit appel à l'aide

Bon dimanche !

Paul.