懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
1ac2bc 1 (function (Highcharts) {
2     var seriesTypes = Highcharts.seriesTypes,
3         each = Highcharts.each;
4     
5     seriesTypes.heatmap = Highcharts.extendClass(seriesTypes.map, {
6         colorKey: 'z',
7         useMapGeometry: false,
8         pointArrayMap: ['y', 'z'],
9         translate: function () {
10             var series = this,
11                 options = series.options,
12                 dataMin = Number.MAX_VALUE,
13                 dataMax = Number.MIN_VALUE;
14
15             series.generatePoints();
16     
17             each(series.data, function (point) {
18                 var x = point.x,
19                     y = point.y,
20                     value = point.z,
21                     xPad = (options.colsize || 1) / 2,
22                     yPad = (options.rowsize || 1) / 2;
23
24                 point.path = [
25                     'M', x - xPad, y - yPad,
26                     'L', x + xPad, y - yPad,
27                     'L', x + xPad, y + yPad,
28                     'L', x - xPad, y + yPad,
29                     'Z'
30                 ];
31                 
32                 point.shapeType = 'path';
33                 point.shapeArgs = {
34                     d: series.translatePath(point.path)
35                 };
36                 
37                 if (typeof value === 'number') {
38                     if (value > dataMax) {
39                         dataMax = value;
40                     } else if (value < dataMin) {
41                         dataMin = value;
42                     }
43                 }
44             });
45             
46             series.translateColors(dataMin, dataMax);
47         },
48         
49         getBox: function () {}
50             
51     });
52     
53 }(Highcharts));