gridviz 2.1.13 → 2.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +124 -125
  2. package/dist/gridviz.js +8900 -8368
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +77 -77
  5. package/src/App.js +760 -758
  6. package/src/BackgroundLayer.js +182 -182
  7. package/src/BackgroundLayerWMS.js +131 -131
  8. package/src/Dataset.js +76 -76
  9. package/src/DatasetComponent.js +113 -113
  10. package/src/GeoCanvas.js +420 -420
  11. package/src/LabelLayer.js +190 -190
  12. package/src/Layer.js +103 -103
  13. package/src/Legend.js +86 -86
  14. package/src/LineLayer.js +150 -150
  15. package/src/Style.js +131 -129
  16. package/src/Tooltip.js +182 -180
  17. package/src/button/Button.js +66 -54
  18. package/src/button/FullscreenButton.js +120 -98
  19. package/src/button/ZoomButtons.js +95 -72
  20. package/src/dataset/COGeo.js +24 -24
  21. package/src/dataset/CSVGrid.js +104 -104
  22. package/src/dataset/GeoTIFF.js +127 -127
  23. package/src/dataset/GridTile.js +41 -41
  24. package/src/dataset/LGrid.js +54 -54
  25. package/src/dataset/TiledGrid.js +264 -264
  26. package/src/index.js +73 -71
  27. package/src/legend/ColorCategoryLegend.js +124 -124
  28. package/src/legend/ColorDiscreteLegend.js +103 -103
  29. package/src/legend/ColorLegend.js +128 -128
  30. package/src/legend/SegmentOrientationLegend.js +87 -87
  31. package/src/legend/SegmentWidthLegend.js +101 -101
  32. package/src/legend/SizeLegend.js +141 -141
  33. package/src/style/CompositionStyle.js +300 -300
  34. package/src/style/CompositionStyle_.js +293 -0
  35. package/src/style/ContourStyle.js +54 -54
  36. package/src/style/DotDensityStyle.js +156 -156
  37. package/src/style/IsoFenceStyle.js +262 -262
  38. package/src/style/JoyPlotStyle.js +135 -135
  39. package/src/style/LegoStyle.js +112 -112
  40. package/src/style/MosaicStyle.js +107 -107
  41. package/src/style/NinjaStarStyle.js +125 -125
  42. package/src/style/PillarStyle.js +230 -230
  43. package/src/style/SegmentStyle.js +142 -142
  44. package/src/style/ShapeColorSizeStyle.js +152 -152
  45. package/src/style/ShapeColorSizeStyle_.js +108 -0
  46. package/src/style/SideCatStyle.js +172 -172
  47. package/src/style/SideStyle.js +216 -216
  48. package/src/style/SquareColorCatWGLStyle.js +120 -120
  49. package/src/style/SquareColorWGLStyle.js +146 -146
  50. package/src/style/StrokeStyle.js +131 -131
  51. package/src/style/TanakaStyle.js +160 -160
  52. package/src/style/TextStyle.js +132 -132
  53. package/src/style/TimeSeriesStyle.js +259 -259
  54. package/src/utils/Utils.js +35 -35
  55. package/src/utils/WebGLRectangleColoring.js +106 -106
  56. package/src/utils/WebGLSquareColoring.js +118 -118
  57. package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
  58. package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
  59. package/src/utils/WebGLSquareColoringKS.js +153 -153
  60. package/src/utils/stretching.js +154 -131
  61. package/src/utils/webGLUtils.js +71 -71
  62. package/src/utils/zoomUtils.js +142 -142
@@ -1,142 +1,142 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Style } from '../Style.js'
5
-
6
- /**
7
- * A style where each cell is represented by a segment whose length, width, color and orientation can vary according to statistical values.
8
- *
9
- * @author Julien Gaffuri
10
- */
11
- export class SegmentStyle extends Style {
12
- /** @param {object} opts */
13
- constructor(opts) {
14
- super(opts)
15
- opts = opts || {}
16
-
17
- /** A function returning the orientation (in degrees) of the segment representing a cell.
18
- * @type {function(import("../Dataset").Cell):number} */
19
- this.orientation = opts.orientation || (() => 0)
20
-
21
- /**
22
- * @type {string} */
23
- this.colorCol = opts.colorCol
24
-
25
- /** A function returning the color of the cell segment.
26
- * @type {function(number,number,import("../Style").Stat|undefined):string} */
27
- this.color = opts.color || (() => '#EA6BAC')
28
-
29
- /**
30
- * @type {string} */
31
- this.lengthCol = opts.lengthCol
32
-
33
- /** A function returning the length of the segment representing a cell, in geo unit
34
- * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
35
- this.length = opts.length
36
-
37
- /**
38
- * @type {string} */
39
- this.widthCol = opts.widthCol
40
-
41
- /** A function returning the width of the segment representing a cell, in geo unit
42
- * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
43
- this.width = opts.width
44
- }
45
-
46
- /**
47
- * Draw cells as segments.
48
- *
49
- * @param {Array.<import("../Dataset").Cell>} cells
50
- * @param {number} r
51
- * @param {import("../GeoCanvas").GeoCanvas} cg
52
- */
53
- draw(cells, r, cg) {
54
- //filter
55
- if (this.filter) cells = cells.filter(this.filter)
56
-
57
- //zoom factor
58
- const zf = cg.getZf()
59
-
60
- let statColor
61
- if (this.colorCol) {
62
- //compute color variable statistics
63
- statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
64
- }
65
-
66
- let statLength
67
- if (this.lengthCol) {
68
- //if length is used, sort cells by length so that the longests are drawn first
69
- cells.sort((c1, c2) => c2[this.lengthCol] - c1[this.lengthCol])
70
- //and compute size variable statistics
71
- statLength = Style.getStatistics(cells, (c) => c[this.lengthCol], true)
72
- }
73
-
74
- let statWidth
75
- if (this.widthCol) {
76
- //and compute size variable statistics
77
- statWidth = Style.getStatistics(cells, (c) => c[this.widthCol], true)
78
- }
79
-
80
- //
81
- cg.ctx.lineCap = 'butt'
82
-
83
- //conversion factor degree -> radian
84
- const f = Math.PI / 180
85
-
86
- //draw in geo coordinates
87
- cg.setCanvasTransform()
88
-
89
- for (let c of cells) {
90
- //color
91
- /** @type {string|undefined} */
92
- const col = this.color ? this.color(c[this.colorCol], r, statColor) : undefined
93
- if (!col) continue
94
-
95
- //width
96
- /** @type {number|undefined} */
97
- const wG = this.width ? this.width(c[this.widthCol], r, statWidth, zf) : undefined
98
- if (!wG || wG < 0) continue
99
-
100
- //length
101
- /** @type {number|undefined} */
102
- const lG = this.length ? this.length(c[this.lengthCol], r, statLength, zf) : undefined
103
- if (!lG || lG < 0) continue
104
-
105
- //orientation (in radian)
106
- /** @type {number} */
107
- const or = this.orientation(c) * f
108
- if (or === undefined || isNaN(or)) continue
109
-
110
- //get offset
111
- const offset = this.offset(c, r, zf)
112
-
113
- //set color and width
114
- cg.ctx.strokeStyle = col
115
- cg.ctx.lineWidth = wG
116
-
117
- //compute segment centre postition
118
- const cx = c.x + r / 2 + offset.dx
119
- const cy = c.y + r / 2 + offset.dy
120
-
121
- //compute segment direction
122
- const dx = 0.5 * Math.cos(or) * lG
123
- const dy = 0.5 * Math.sin(or) * lG
124
-
125
- //draw segment
126
- cg.ctx.beginPath()
127
- cg.ctx.moveTo(cx - dx, cy - dy)
128
- cg.ctx.lineTo(cx + dx, cy + dy)
129
- cg.ctx.stroke()
130
- }
131
-
132
- //update legend, if any
133
- this.updateLegends({
134
- widthFun: this.width,
135
- r: r,
136
- zf: zf,
137
- sColor: statColor,
138
- //sLength: statLength,
139
- sWidth: statWidth,
140
- })
141
- }
142
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Style } from '../Style.js'
5
+
6
+ /**
7
+ * A style where each cell is represented by a segment whose length, width, color and orientation can vary according to statistical values.
8
+ *
9
+ * @author Julien Gaffuri
10
+ */
11
+ export class SegmentStyle extends Style {
12
+ /** @param {object} opts */
13
+ constructor(opts) {
14
+ super(opts)
15
+ opts = opts || {}
16
+
17
+ /** A function returning the orientation (in degrees) of the segment representing a cell.
18
+ * @type {function(import("../Dataset").Cell):number} */
19
+ this.orientation = opts.orientation || (() => 0)
20
+
21
+ /**
22
+ * @type {string} */
23
+ this.colorCol = opts.colorCol
24
+
25
+ /** A function returning the color of the cell segment.
26
+ * @type {function(number,number,import("../Style").Stat|undefined):string} */
27
+ this.color = opts.color || (() => '#EA6BAC')
28
+
29
+ /**
30
+ * @type {string} */
31
+ this.lengthCol = opts.lengthCol
32
+
33
+ /** A function returning the length of the segment representing a cell, in geo unit
34
+ * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
35
+ this.length = opts.length
36
+
37
+ /**
38
+ * @type {string} */
39
+ this.widthCol = opts.widthCol
40
+
41
+ /** A function returning the width of the segment representing a cell, in geo unit
42
+ * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
43
+ this.width = opts.width
44
+ }
45
+
46
+ /**
47
+ * Draw cells as segments.
48
+ *
49
+ * @param {Array.<import("../Dataset").Cell>} cells
50
+ * @param {number} r
51
+ * @param {import("../GeoCanvas").GeoCanvas} cg
52
+ */
53
+ draw(cells, r, cg) {
54
+ //filter
55
+ if (this.filter) cells = cells.filter(this.filter)
56
+
57
+ //zoom factor
58
+ const zf = cg.getZf()
59
+
60
+ let statColor
61
+ if (this.colorCol) {
62
+ //compute color variable statistics
63
+ statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
64
+ }
65
+
66
+ let statLength
67
+ if (this.lengthCol) {
68
+ //if length is used, sort cells by length so that the longests are drawn first
69
+ cells.sort((c1, c2) => c2[this.lengthCol] - c1[this.lengthCol])
70
+ //and compute size variable statistics
71
+ statLength = Style.getStatistics(cells, (c) => c[this.lengthCol], true)
72
+ }
73
+
74
+ let statWidth
75
+ if (this.widthCol) {
76
+ //and compute size variable statistics
77
+ statWidth = Style.getStatistics(cells, (c) => c[this.widthCol], true)
78
+ }
79
+
80
+ //
81
+ cg.ctx.lineCap = 'butt'
82
+
83
+ //conversion factor degree -> radian
84
+ const f = Math.PI / 180
85
+
86
+ //draw in geo coordinates
87
+ cg.setCanvasTransform()
88
+
89
+ for (let c of cells) {
90
+ //color
91
+ /** @type {string|undefined} */
92
+ const col = this.color ? this.color(c[this.colorCol], r, statColor) : undefined
93
+ if (!col) continue
94
+
95
+ //width
96
+ /** @type {number|undefined} */
97
+ const wG = this.width ? this.width(c[this.widthCol], r, statWidth, zf) : undefined
98
+ if (!wG || wG < 0) continue
99
+
100
+ //length
101
+ /** @type {number|undefined} */
102
+ const lG = this.length ? this.length(c[this.lengthCol], r, statLength, zf) : undefined
103
+ if (!lG || lG < 0) continue
104
+
105
+ //orientation (in radian)
106
+ /** @type {number} */
107
+ const or = this.orientation(c) * f
108
+ if (or === undefined || isNaN(or)) continue
109
+
110
+ //get offset
111
+ const offset = this.offset(c, r, zf)
112
+
113
+ //set color and width
114
+ cg.ctx.strokeStyle = col
115
+ cg.ctx.lineWidth = wG
116
+
117
+ //compute segment centre postition
118
+ const cx = c.x + r / 2 + offset.dx
119
+ const cy = c.y + r / 2 + offset.dy
120
+
121
+ //compute segment direction
122
+ const dx = 0.5 * Math.cos(or) * lG
123
+ const dy = 0.5 * Math.sin(or) * lG
124
+
125
+ //draw segment
126
+ cg.ctx.beginPath()
127
+ cg.ctx.moveTo(cx - dx, cy - dy)
128
+ cg.ctx.lineTo(cx + dx, cy + dy)
129
+ cg.ctx.stroke()
130
+ }
131
+
132
+ //update legend, if any
133
+ this.updateLegends({
134
+ widthFun: this.width,
135
+ r: r,
136
+ zf: zf,
137
+ sColor: statColor,
138
+ //sLength: statLength,
139
+ sWidth: statWidth,
140
+ })
141
+ }
142
+ }
@@ -1,152 +1,152 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Style } from '../Style.js'
5
- import { color } from 'd3-color'
6
-
7
- /**
8
- * A very generic style that shows grid cells with specific color, size and shape.
9
- * It can be used to show variables as cell colors, cell size, cell shape, or any combination of the three visual variables.
10
- *
11
- * @author Joseph Davies, Julien Gaffuri
12
- */
13
- export class ShapeColorSizeStyle extends Style {
14
- /** @param {object} opts */
15
- constructor(opts) {
16
- super(opts)
17
- opts = opts || {}
18
-
19
- /** The name of the column/attribute of the tabular data where to retrieve the variable for color.
20
- * @type {string} */
21
- this.colorCol = opts.colorCol
22
-
23
- /** A function returning the color of the cell.
24
- * @type {function(number,number,import("../Style").Stat|undefined,number):string} */
25
- this.color = opts.color || (() => '#EA6BAC') //(v,r,s,zf) => {}
26
-
27
- /** The name of the column/attribute of the tabular data where to retrieve the variable for size.
28
- * @type {string} */
29
- this.sizeCol = opts.sizeCol
30
-
31
- /** A function returning the size of a cell in geographical unit.
32
- * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
33
- this.size = opts.size
34
-
35
- /** A function returning the shape of a cell.
36
- * @type {function(import("../Dataset").Cell):import("../Style").Shape} */
37
- this.shape = opts.shape || (() => 'square')
38
-
39
- /** The name of the column/attribute of the tabular data where to retrieve the variable for color alpha.
40
- * @type {string} */
41
- this.alphaCol = opts.alphaCol
42
-
43
- /** A function returning the color alpha of the cell.
44
- * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
45
- this.alphaF = opts.alphaF
46
- }
47
-
48
- /**
49
- * Draw cells as squares, with various colors and size.
50
- *
51
- * @param {Array.<import("../Dataset").Cell>} cells
52
- * @param {number} r
53
- * @param {import("../GeoCanvas").GeoCanvas} cg
54
- */
55
- draw(cells, r, cg) {
56
- //filter
57
- if (this.filter) cells = cells.filter(this.filter)
58
-
59
- //zoom factor
60
- const zf = cg.getZf()
61
-
62
- let statSize
63
- if (this.sizeCol) {
64
- //if size is used, sort cells by size so that the biggest are drawn first
65
- cells.sort((c1, c2) => c2[this.sizeCol] - c1[this.sizeCol])
66
- //and compute size variable statistics
67
- statSize = Style.getStatistics(cells, (c) => c[this.sizeCol], true)
68
- }
69
-
70
- let statColor
71
- if (this.colorCol) {
72
- //compute color variable statistics
73
- statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
74
- }
75
-
76
- let statAlpha
77
- if (this.alphaCol) {
78
- //compute color alpha variable statistics
79
- statAlpha = Style.getStatistics(cells, (c) => c[this.alphaCol], true)
80
- }
81
-
82
- //draw with HTML canvas
83
- //in geo coordinates
84
- cg.setCanvasTransform()
85
-
86
- const r2 = r * 0.5
87
- for (let cell of cells) {
88
- //color
89
- let col = this.color ? this.color(cell[this.colorCol], r, statColor, zf) : undefined
90
- if (!col || col === 'none') continue
91
-
92
- //alpha
93
- if (this.alphaCol && this.alphaF) {
94
- //get alpha
95
- const alpha = this.alphaF(cell[this.alphaCol], r, statAlpha, zf)
96
- if (alpha == 0) continue
97
- //apply alpha to color col
98
- const col_ = color(col);
99
- if (col_) col = `rgba(${col_.r}, ${col_.g}, ${col_.b}, ${alpha})`;
100
- else console.warn("Could not decode color " + col + " in ShapeColorSizeStyle")
101
- }
102
-
103
- //shape
104
- const shape = this.shape ? this.shape(cell) : 'square'
105
- if (shape === 'none') continue
106
-
107
- //size
108
- /** @type {function(number,number,import("../Style").Stat|undefined,number):number} */
109
- let s_ = this.size || (() => r)
110
- //size - in geo unit
111
- const sG = s_(cell[this.sizeCol], r, statSize, zf)
112
-
113
- //get offset
114
- const offset = this.offset(cell, r, zf)
115
-
116
- cg.ctx.fillStyle = col
117
- if (shape === 'square') {
118
- //draw square
119
- const d = r * (1 - sG / r) * 0.5
120
- cg.ctx.fillRect(cell.x + d + offset.dx, cell.y + d + offset.dy, sG, sG)
121
- } else if (shape === 'circle') {
122
- //draw circle
123
- cg.ctx.beginPath()
124
- cg.ctx.arc(cell.x + r2 + offset.dx, cell.y + r2 + offset.dy, sG * 0.5, 0, 2 * Math.PI, false)
125
- cg.ctx.fill()
126
- } else if (shape === 'donut') {
127
- //draw donut
128
- const xc = cell.x + r2 + offset.dx,
129
- yc = cell.y + r2 + offset.dy
130
- cg.ctx.beginPath()
131
- cg.ctx.moveTo(xc, yc)
132
- cg.ctx.arc(xc, yc, r2, 0, 2 * Math.PI)
133
- cg.ctx.arc(xc, yc, (1 - sG / r) * r2, 0, 2 * Math.PI, true)
134
- cg.ctx.closePath()
135
- cg.ctx.fill()
136
- } else if (shape === 'diamond') {
137
- const s2 = sG * 0.5
138
- cg.ctx.beginPath()
139
- cg.ctx.moveTo(cell.x + r2 - s2, cell.y + r2)
140
- cg.ctx.lineTo(cell.x + r2, cell.y + r2 + s2)
141
- cg.ctx.lineTo(cell.x + r2 + s2, cell.y + r2)
142
- cg.ctx.lineTo(cell.x + r2, cell.y + r2 - s2)
143
- cg.ctx.fill()
144
- } else {
145
- throw new Error('Unexpected shape:' + shape)
146
- }
147
- }
148
-
149
- //update legends
150
- this.updateLegends({ style: this, r: r, zf: zf, sSize: statSize, sColor: statColor, sAlpha: statAlpha })
151
- }
152
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Style } from '../Style.js'
5
+ import { color } from 'd3-color'
6
+
7
+ /**
8
+ * A very generic style that shows grid cells with specific color, size and shape.
9
+ * It can be used to show variables as cell colors, cell size, cell shape, or any combination of the three visual variables.
10
+ *
11
+ * @author Joseph Davies, Julien Gaffuri
12
+ */
13
+ export class ShapeColorSizeStyle extends Style {
14
+ /** @param {object} opts */
15
+ constructor(opts) {
16
+ super(opts)
17
+ opts = opts || {}
18
+
19
+ /** The name of the column/attribute of the tabular data where to retrieve the variable for color.
20
+ * @type {string} */
21
+ this.colorCol = opts.colorCol
22
+
23
+ /** A function returning the color of the cell.
24
+ * @type {function(number,number,import("../Style").Stat|undefined,number):string} */
25
+ this.color = opts.color || (() => '#EA6BAC') //(v,r,s,zf) => {}
26
+
27
+ /** The name of the column/attribute of the tabular data where to retrieve the variable for size.
28
+ * @type {string} */
29
+ this.sizeCol = opts.sizeCol
30
+
31
+ /** A function returning the size of a cell in geographical unit.
32
+ * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
33
+ this.size = opts.size
34
+
35
+ /** A function returning the shape of a cell.
36
+ * @type {function(import("../Dataset").Cell):import("../Style").Shape} */
37
+ this.shape = opts.shape || (() => 'square')
38
+
39
+ /** The name of the column/attribute of the tabular data where to retrieve the variable for color alpha.
40
+ * @type {string} */
41
+ this.alphaCol = opts.alphaCol
42
+
43
+ /** A function returning the color alpha of the cell.
44
+ * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
45
+ this.alphaF = opts.alphaF
46
+ }
47
+
48
+ /**
49
+ * Draw cells as squares, with various colors and size.
50
+ *
51
+ * @param {Array.<import("../Dataset").Cell>} cells
52
+ * @param {number} r
53
+ * @param {import("../GeoCanvas").GeoCanvas} cg
54
+ */
55
+ draw(cells, r, cg) {
56
+ //filter
57
+ if (this.filter) cells = cells.filter(this.filter)
58
+
59
+ //zoom factor
60
+ const zf = cg.getZf()
61
+
62
+ let statSize
63
+ if (this.sizeCol) {
64
+ //if size is used, sort cells by size so that the biggest are drawn first
65
+ cells.sort((c1, c2) => c2[this.sizeCol] - c1[this.sizeCol])
66
+ //and compute size variable statistics
67
+ statSize = Style.getStatistics(cells, (c) => c[this.sizeCol], true)
68
+ }
69
+
70
+ let statColor
71
+ if (this.colorCol) {
72
+ //compute color variable statistics
73
+ statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
74
+ }
75
+
76
+ let statAlpha
77
+ if (this.alphaCol) {
78
+ //compute color alpha variable statistics
79
+ statAlpha = Style.getStatistics(cells, (c) => c[this.alphaCol], true)
80
+ }
81
+
82
+ //draw with HTML canvas
83
+ //in geo coordinates
84
+ cg.setCanvasTransform()
85
+
86
+ const r2 = r * 0.5
87
+ for (let cell of cells) {
88
+ //color
89
+ let col = this.color ? this.color(cell[this.colorCol], r, statColor, zf) : undefined
90
+ if (!col || col === 'none') continue
91
+
92
+ //alpha
93
+ if (this.alphaCol && this.alphaF) {
94
+ //get alpha
95
+ const alpha = this.alphaF(cell[this.alphaCol], r, statAlpha, zf)
96
+ if (alpha == 0) continue
97
+ //apply alpha to color col
98
+ const col_ = color(col);
99
+ if (col_) col = `rgba(${col_.r}, ${col_.g}, ${col_.b}, ${alpha})`;
100
+ else console.warn("Could not decode color " + col + " in ShapeColorSizeStyle")
101
+ }
102
+
103
+ //shape
104
+ const shape = this.shape ? this.shape(cell) : 'square'
105
+ if (shape === 'none') continue
106
+
107
+ //size
108
+ /** @type {function(number,number,import("../Style").Stat|undefined,number):number} */
109
+ let s_ = this.size || (() => r)
110
+ //size - in geo unit
111
+ const sG = s_(cell[this.sizeCol], r, statSize, zf)
112
+
113
+ //get offset
114
+ const offset = this.offset(cell, r, zf)
115
+
116
+ cg.ctx.fillStyle = col
117
+ if (shape === 'square') {
118
+ //draw square
119
+ const d = r * (1 - sG / r) * 0.5
120
+ cg.ctx.fillRect(cell.x + d + offset.dx, cell.y + d + offset.dy, sG, sG)
121
+ } else if (shape === 'circle') {
122
+ //draw circle
123
+ cg.ctx.beginPath()
124
+ cg.ctx.arc(cell.x + r2 + offset.dx, cell.y + r2 + offset.dy, sG * 0.5, 0, 2 * Math.PI, false)
125
+ cg.ctx.fill()
126
+ } else if (shape === 'donut') {
127
+ //draw donut
128
+ const xc = cell.x + r2 + offset.dx,
129
+ yc = cell.y + r2 + offset.dy
130
+ cg.ctx.beginPath()
131
+ cg.ctx.moveTo(xc, yc)
132
+ cg.ctx.arc(xc, yc, r2, 0, 2 * Math.PI)
133
+ cg.ctx.arc(xc, yc, (1 - sG / r) * r2, 0, 2 * Math.PI, true)
134
+ cg.ctx.closePath()
135
+ cg.ctx.fill()
136
+ } else if (shape === 'diamond') {
137
+ const s2 = sG * 0.5
138
+ cg.ctx.beginPath()
139
+ cg.ctx.moveTo(cell.x + r2 - s2, cell.y + r2)
140
+ cg.ctx.lineTo(cell.x + r2, cell.y + r2 + s2)
141
+ cg.ctx.lineTo(cell.x + r2 + s2, cell.y + r2)
142
+ cg.ctx.lineTo(cell.x + r2, cell.y + r2 - s2)
143
+ cg.ctx.fill()
144
+ } else {
145
+ throw new Error('Unexpected shape:' + shape)
146
+ }
147
+ }
148
+
149
+ //update legends
150
+ this.updateLegends({ style: this, r: r, zf: zf, sSize: statSize, sColor: statColor, sAlpha: statAlpha })
151
+ }
152
+ }