gridviz 3.0.25 → 3.0.27

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 (66) hide show
  1. package/README.md +128 -128
  2. package/dist/gridviz.js +8630 -8615
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +74 -74
  5. package/src/button/Button.js +67 -67
  6. package/src/button/FullscreenButton.js +121 -121
  7. package/src/button/ZoomButtons.js +103 -103
  8. package/src/core/Dataset.js +154 -154
  9. package/src/core/Drawable.js +78 -78
  10. package/src/core/GeoCanvas.js +443 -438
  11. package/src/core/Layer.js +23 -23
  12. package/src/core/Legend.js +108 -108
  13. package/src/core/Map.js +544 -544
  14. package/src/core/MultiResolutionDataset.js +93 -93
  15. package/src/core/Style.js +98 -98
  16. package/src/core/Tooltip.js +182 -182
  17. package/src/dataset/COGeo.js +25 -25
  18. package/src/dataset/CSVGrid.js +112 -112
  19. package/src/dataset/GeoTIFF.js +122 -122
  20. package/src/dataset/JSGrid.js +55 -55
  21. package/src/dataset/TiledGrid.js +302 -302
  22. package/src/dataset/worker.js +18 -18
  23. package/src/index.js +77 -77
  24. package/src/layer/BackgroundLayer.js +173 -173
  25. package/src/layer/BackgroundLayerImage.js +81 -81
  26. package/src/layer/BackgroundLayerWMS.js +104 -104
  27. package/src/layer/GeoJSONLayer.js +224 -214
  28. package/src/layer/GridLayer.js +148 -148
  29. package/src/layer/LabelLayer.js +194 -194
  30. package/src/legend/ColorCategoryLegend.js +109 -109
  31. package/src/legend/ColorDiscreteLegend.js +100 -100
  32. package/src/legend/ColorLegend.js +115 -115
  33. package/src/legend/OrientationLegend.js +89 -89
  34. package/src/legend/SizeLegend.js +224 -224
  35. package/src/legend/TernaryLegend.js +302 -302
  36. package/src/style/CompositionStyle.js +291 -291
  37. package/src/style/ContourStyle.js +21 -21
  38. package/src/style/DotDensityStyle.js +133 -133
  39. package/src/style/ImageStyle.js +100 -100
  40. package/src/style/IsoFenceStyle.js +217 -217
  41. package/src/style/JoyPlotStyle.js +127 -127
  42. package/src/style/LegoStyle.js +110 -110
  43. package/src/style/MosaicStyle.js +99 -99
  44. package/src/style/NinjaStarStyle.js +102 -102
  45. package/src/style/PillarStyle.js +207 -207
  46. package/src/style/SegmentStyle.js +105 -105
  47. package/src/style/ShapeColorSizeStyle.js +147 -147
  48. package/src/style/SideCategoryStyle.js +112 -112
  49. package/src/style/SideStyle.js +212 -212
  50. package/src/style/SquareColorCategoryWebGLStyle.js +107 -107
  51. package/src/style/SquareColorWebGLStyle.js +126 -126
  52. package/src/style/StrokeStyle.js +135 -135
  53. package/src/style/TanakaStyle.js +69 -69
  54. package/src/style/TextStyle.js +110 -110
  55. package/src/style/TimeSeriesStyle.js +222 -222
  56. package/src/utils/WebGLRectangleColoring.js +106 -106
  57. package/src/utils/WebGLSquareColoring.js +118 -118
  58. package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
  59. package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
  60. package/src/utils/WebGLSquareColoringKS.js +153 -153
  61. package/src/utils/scale.js +218 -218
  62. package/src/utils/stretching.js +120 -120
  63. package/src/utils/ternary.js +208 -208
  64. package/src/utils/utils.js +58 -58
  65. package/src/utils/webGLUtils.js +72 -72
  66. package/src/utils/zoomUtils.js +142 -142
@@ -1,302 +1,302 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { select } from 'd3-selection'
5
- import { Legend } from '../core/Legend.js'
6
-
7
- /**
8
- *
9
- * @module legend
10
- * @author Julien Gaffuri
11
- */
12
- export class TernaryLegend extends Legend {
13
- /** @param {Object} opts */
14
- constructor(opts) {
15
- super(opts)
16
- opts = opts || {}
17
-
18
- //classifier
19
- this.classifier = opts.classifier
20
-
21
- this.width = opts.width || 150
22
- this.selectionColor = this.selectionColor || 'red'
23
- this.tooltip = opts.tooltip
24
- this.texts = opts.texts
25
-
26
- this.leftText = opts.leftText || 'Category 0'
27
- this.topText = opts.topText || 'Category 1'
28
- this.rightText = opts.rightText || 'Category 2'
29
-
30
- this.centerCoefficient = opts.centerCoefficient || this.classifier.centerCoefficient
31
- }
32
-
33
- /**
34
- * @param {{} } opts
35
- */
36
- update(opts) {
37
- //clear
38
- this.div.selectAll('*').remove()
39
-
40
- //title
41
- this.makeTitle()
42
-
43
- const sqrt3over2 = 0.866025
44
- const w = this.width,
45
- h = w * sqrt3over2
46
- const classifier = this.classifier
47
- const selectionColor = this.selectionColor
48
- const selectionStrokeWidth = 0
49
- const tt = this.tooltip
50
- const texts = this.texts || {}
51
-
52
- const padding = 2
53
- const fontSize = 12
54
-
55
- //make svg element
56
- const svg = this.div
57
- .append('svg')
58
- .attr('width', w + selectionStrokeWidth)
59
- .attr('height', h + 4 * padding + 2 * fontSize)
60
-
61
- //top label
62
- svg.append('text')
63
- .attr('x', w / 2)
64
- .attr('y', padding + fontSize)
65
- .text(this.topText)
66
- .attr('font-size', fontSize)
67
- .attr('text-anchor', 'middle')
68
- //left label
69
- svg.append('text')
70
- .attr('x', 0)
71
- .attr('y', 3 * padding + 2 * fontSize + h)
72
- .text(this.leftText)
73
- .attr('font-size', fontSize)
74
- .attr('text-anchor', 'start')
75
- //right label
76
- svg.append('text')
77
- .attr('x', w)
78
- .attr('y', 3 * padding + 2 * fontSize + h)
79
- .text(this.rightText)
80
- .attr('font-size', fontSize)
81
- .attr('text-anchor', 'end')
82
-
83
- //triangle group
84
- const g = svg
85
- .append('g')
86
- .attr(
87
- 'transform',
88
- 'translate(' +
89
- selectionStrokeWidth / 2 +
90
- ' ' +
91
- (selectionStrokeWidth / 2 + (2 * padding + fontSize)) +
92
- ')'
93
- )
94
-
95
- //common function for triangle patches
96
- const setAttributes = (elt, color, text) => {
97
- //elt.raise();
98
- elt.attr('fill', color)
99
- //.attr("stroke", colorOver)
100
- //.attr("stroke-width", 0)
101
- //.attr("stroke-linejoin", "round")
102
- .on('mouseover', function (e) {
103
- /*this.parentNode.appendChild(this); select(this).attr("stroke-width", selectionStrokeWidth);*/
104
- select(this).attr('fill', selectionColor)
105
- if (!tt || !text) return
106
- tt.html(text)
107
- tt.setPosition(e)
108
- tt.show()
109
- })
110
- .on('mouseout', function () {
111
- /*select(this).attr("stroke-width", 0);*/
112
- select(this).attr('fill', color)
113
- if (tt) tt.hide()
114
- })
115
- if (tt && text)
116
- elt.on('mousemove', function (e) {
117
- tt.setPosition(e)
118
- })
119
- }
120
-
121
- //const [c0, c1, c2] = classifier.center
122
-
123
- //trapezium s0
124
- const t0 = g
125
- .append('polygon')
126
- .attr(
127
- 'points',
128
- '0,' +
129
- h +
130
- ' ' +
131
- w / 3 +
132
- ',' +
133
- h +
134
- ' ' +
135
- w / 2 +
136
- ',' +
137
- (h * 2) / 3 +
138
- ' ' +
139
- w / 6 +
140
- ',' +
141
- (h * 2) / 3
142
- )
143
- setAttributes(t0, classifier.colors[0], texts['0'])
144
- //trapezium s1
145
- const t1 = g
146
- .append('polygon')
147
- .attr(
148
- 'points',
149
- w / 2 +
150
- ',0 ' +
151
- (w * 2) / 3 +
152
- ',' +
153
- h / 3 +
154
- ' ' +
155
- w / 2 +
156
- ',' +
157
- (h * 2) / 3 +
158
- ' ' +
159
- w / 3 +
160
- ',' +
161
- h / 3
162
- )
163
- setAttributes(t1, classifier.colors[1], texts['1'])
164
- //trapezium s2
165
- const t2 = g
166
- .append('polygon')
167
- .attr(
168
- 'points',
169
- w +
170
- ',' +
171
- h +
172
- ' ' +
173
- (w * 5) / 6 +
174
- ',' +
175
- (2 * h) / 3 +
176
- ' ' +
177
- w / 2 +
178
- ',' +
179
- (h * 2) / 3 +
180
- ' ' +
181
- (w * 2) / 3 +
182
- ',' +
183
- h
184
- )
185
- setAttributes(t2, classifier.colors[2], texts['2'])
186
- //triangle s0
187
- const t0_ = g
188
- .append('polygon')
189
- .attr(
190
- 'points',
191
- w / 2 +
192
- ',' +
193
- (h * 2) / 3 +
194
- ' ' +
195
- (w * 5) / 6 +
196
- ',' +
197
- (h * 2) / 3 +
198
- ' ' +
199
- (w * 2) / 3 +
200
- ',' +
201
- h / 3
202
- )
203
- setAttributes(t0_, classifier.mixColors[0], texts['m12'])
204
- //triangle s1
205
- const t1_ = g
206
- .append('polygon')
207
- .attr('points', w / 2 + ',' + (h * 2) / 3 + ' ' + w / 3 + ',' + h + ' ' + (w * 2) / 3 + ',' + h)
208
- setAttributes(t1_, classifier.mixColors[1], texts['m02'])
209
- //triangle s2
210
- const t2_ = g
211
- .append('polygon')
212
- .attr(
213
- 'points',
214
- w / 2 + ',' + (h * 2) / 3 + ' ' + w / 6 + ',' + (h * 2) / 3 + ' ' + w / 3 + ',' + h / 3
215
- )
216
- setAttributes(t2_, classifier.mixColors[2], texts['m01'])
217
-
218
- //center
219
- if (this.centerCoefficient) {
220
- //TODO make it an hexagon !
221
- const center = g
222
- .append('circle')
223
- .attr('cx', w / 2)
224
- .attr('cy', (h * 2) / 3)
225
- .attr('r', (this.centerCoefficient * h) / 3)
226
- setAttributes(center, classifier.centerColor, texts['center'])
227
- }
228
-
229
- /*
230
- let middle, left, top, right, left_, bottom_, right_
231
- if (!this.real) {
232
-
233
- //0 left triangle
234
- left = g.append('polygon')
235
- .attr('points', "0," + h + " " + (w / 3) + "," + h + " " + (w / 6) + "," + (2 * h / 3))
236
- //1 top triangle
237
- top = g.append('polygon')
238
- .attr('points', (w / 3) + "," + (h / 3) + " " + (w * 2 / 3) + "," + (h / 3) + " " + (w / 2) + ",0")
239
- //2 right triangle
240
- right = g.append('polygon')
241
- .attr('points', (w * 2 / 3) + "," + h + " " + w + "," + h + " " + (w * 5 / 6) + "," + (2 * h / 3))
242
- //middle triangle
243
- middle = g.append('polygon')
244
- .attr('points', (w / 2) + "," + (h / 3) + " " + (w / 4) + "," + (h * 5 / 6) + " " + (3 * w / 4) + "," + (h * 5 / 6))
245
- //01 left trapezium
246
- left_ = g.append('polygon')
247
- .attr('points', (w / 6) + "," + (h * 2 / 3) + " " + (w / 4) + "," + (h * 5 / 6) + " " + (w / 2) + "," + (h / 3) + " " + (w / 3) + "," + (h / 3))
248
- //02 bottom trapezium
249
- bottom_ = g.append('polygon')
250
- .attr('points', (w / 3) + "," + (h) + " " + (2 * w / 3) + "," + (h) + " " + (w * 3 / 4) + "," + (h * 5 / 6) + " " + (w / 4) + "," + (h * 5 / 6))
251
- //12 right trapezium
252
- right_ = g.append('polygon')
253
- .attr('points', (w / 2) + "," + (h / 3) + " " + (w * 3 / 4) + "," + (h * 5 / 6) + " " + (w * 5 / 6) + "," + (h * 2 / 3) + " " + (w * 2 / 3) + "," + (h / 3))
254
-
255
- } else {
256
-
257
- //middle triangle
258
- middle = g.append('polygon')
259
- .attr('points', (w / 2) + ",0 0," + h + " " + w + "," + h)
260
-
261
- //draw trapezium
262
- //draw large trapezium first
263
- for (let i_ = 2; i_ >= 0; i_--) {
264
- const i = this.classifier.lowIndex[i_]
265
- const r = this.classifier.lowThreshold[i]
266
- if (i == 2)
267
- //01 left trapezium
268
- left_ = g.append('polygon')
269
- .attr('points', w / 2 + ",0 0," + h + " " + w * r + "," + h + " " + w * (1 + r) / 2 + "," + r * h)
270
- else if (i == 1)
271
- //02 bottom trapezium
272
- bottom_ = g.append('polygon')
273
- .attr('points', "0," + h + " " + w + "," + h + " " + w * (1 - r / 2) + "," + h * (1 - r) + " " + r * w / 2 + "," + h * (1 - r))
274
- else
275
- //12 right trapezium
276
- right_ = g.append('polygon')
277
- .attr('points', w + "," + h + " " + w / 2 + ",0 " + w * (1 - r) / 2 + "," + h * r + " " + w * (1 - r) + "," + h)
278
- }
279
-
280
- //draw triangles
281
- //draw large triangles first
282
- for (let i_ = 2; i_ >= 0; i_--) {
283
- const i = this.classifier.highIndex[i_]
284
- const r = this.classifier.highThreshold[i]
285
-
286
- if (i == 2)
287
- //2 right triangle
288
- right = g.append('polygon')
289
- .attr('points', w + "," + h + " " + w * r + "," + h + " " + w * (1 + r) / 2 + "," + h * r)
290
- else if (i == 1)
291
- //1 top triangle
292
- top = g.append('polygon')
293
- .attr('points', (w / 2) + ",0 " + w * r / 2 + "," + h * (1 - r) + " " + w * (1 - r / 2) + "," + h * (1 - r))
294
- else
295
- //0 left triangle
296
- left = g.append('polygon')
297
- .attr('points', "0," + h + " " + w * (1 - r) + "," + h + " " + w * (1 - r) / 2 + "," + h * r)
298
- }
299
-
300
- }*/
301
- }
302
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { select } from 'd3-selection'
5
+ import { Legend } from '../core/Legend.js'
6
+
7
+ /**
8
+ *
9
+ * @module legend
10
+ * @author Julien Gaffuri
11
+ */
12
+ export class TernaryLegend extends Legend {
13
+ /** @param {Object} opts */
14
+ constructor(opts) {
15
+ super(opts)
16
+ opts = opts || {}
17
+
18
+ //classifier
19
+ this.classifier = opts.classifier
20
+
21
+ this.width = opts.width || 150
22
+ this.selectionColor = this.selectionColor || 'red'
23
+ this.tooltip = opts.tooltip
24
+ this.texts = opts.texts
25
+
26
+ this.leftText = opts.leftText || 'Category 0'
27
+ this.topText = opts.topText || 'Category 1'
28
+ this.rightText = opts.rightText || 'Category 2'
29
+
30
+ this.centerCoefficient = opts.centerCoefficient || this.classifier.centerCoefficient
31
+ }
32
+
33
+ /**
34
+ * @param {{} } opts
35
+ */
36
+ update(opts) {
37
+ //clear
38
+ this.div.selectAll('*').remove()
39
+
40
+ //title
41
+ this.makeTitle()
42
+
43
+ const sqrt3over2 = 0.866025
44
+ const w = this.width,
45
+ h = w * sqrt3over2
46
+ const classifier = this.classifier
47
+ const selectionColor = this.selectionColor
48
+ const selectionStrokeWidth = 0
49
+ const tt = this.tooltip
50
+ const texts = this.texts || {}
51
+
52
+ const padding = 2
53
+ const fontSize = 12
54
+
55
+ //make svg element
56
+ const svg = this.div
57
+ .append('svg')
58
+ .attr('width', w + selectionStrokeWidth)
59
+ .attr('height', h + 4 * padding + 2 * fontSize)
60
+
61
+ //top label
62
+ svg.append('text')
63
+ .attr('x', w / 2)
64
+ .attr('y', padding + fontSize)
65
+ .text(this.topText)
66
+ .attr('font-size', fontSize)
67
+ .attr('text-anchor', 'middle')
68
+ //left label
69
+ svg.append('text')
70
+ .attr('x', 0)
71
+ .attr('y', 3 * padding + 2 * fontSize + h)
72
+ .text(this.leftText)
73
+ .attr('font-size', fontSize)
74
+ .attr('text-anchor', 'start')
75
+ //right label
76
+ svg.append('text')
77
+ .attr('x', w)
78
+ .attr('y', 3 * padding + 2 * fontSize + h)
79
+ .text(this.rightText)
80
+ .attr('font-size', fontSize)
81
+ .attr('text-anchor', 'end')
82
+
83
+ //triangle group
84
+ const g = svg
85
+ .append('g')
86
+ .attr(
87
+ 'transform',
88
+ 'translate(' +
89
+ selectionStrokeWidth / 2 +
90
+ ' ' +
91
+ (selectionStrokeWidth / 2 + (2 * padding + fontSize)) +
92
+ ')'
93
+ )
94
+
95
+ //common function for triangle patches
96
+ const setAttributes = (elt, color, text) => {
97
+ //elt.raise();
98
+ elt.attr('fill', color)
99
+ //.attr("stroke", colorOver)
100
+ //.attr("stroke-width", 0)
101
+ //.attr("stroke-linejoin", "round")
102
+ .on('mouseover', function (e) {
103
+ /*this.parentNode.appendChild(this); select(this).attr("stroke-width", selectionStrokeWidth);*/
104
+ select(this).attr('fill', selectionColor)
105
+ if (!tt || !text) return
106
+ tt.html(text)
107
+ tt.setPosition(e)
108
+ tt.show()
109
+ })
110
+ .on('mouseout', function () {
111
+ /*select(this).attr("stroke-width", 0);*/
112
+ select(this).attr('fill', color)
113
+ if (tt) tt.hide()
114
+ })
115
+ if (tt && text)
116
+ elt.on('mousemove', function (e) {
117
+ tt.setPosition(e)
118
+ })
119
+ }
120
+
121
+ //const [c0, c1, c2] = classifier.center
122
+
123
+ //trapezium s0
124
+ const t0 = g
125
+ .append('polygon')
126
+ .attr(
127
+ 'points',
128
+ '0,' +
129
+ h +
130
+ ' ' +
131
+ w / 3 +
132
+ ',' +
133
+ h +
134
+ ' ' +
135
+ w / 2 +
136
+ ',' +
137
+ (h * 2) / 3 +
138
+ ' ' +
139
+ w / 6 +
140
+ ',' +
141
+ (h * 2) / 3
142
+ )
143
+ setAttributes(t0, classifier.colors[0], texts['0'])
144
+ //trapezium s1
145
+ const t1 = g
146
+ .append('polygon')
147
+ .attr(
148
+ 'points',
149
+ w / 2 +
150
+ ',0 ' +
151
+ (w * 2) / 3 +
152
+ ',' +
153
+ h / 3 +
154
+ ' ' +
155
+ w / 2 +
156
+ ',' +
157
+ (h * 2) / 3 +
158
+ ' ' +
159
+ w / 3 +
160
+ ',' +
161
+ h / 3
162
+ )
163
+ setAttributes(t1, classifier.colors[1], texts['1'])
164
+ //trapezium s2
165
+ const t2 = g
166
+ .append('polygon')
167
+ .attr(
168
+ 'points',
169
+ w +
170
+ ',' +
171
+ h +
172
+ ' ' +
173
+ (w * 5) / 6 +
174
+ ',' +
175
+ (2 * h) / 3 +
176
+ ' ' +
177
+ w / 2 +
178
+ ',' +
179
+ (h * 2) / 3 +
180
+ ' ' +
181
+ (w * 2) / 3 +
182
+ ',' +
183
+ h
184
+ )
185
+ setAttributes(t2, classifier.colors[2], texts['2'])
186
+ //triangle s0
187
+ const t0_ = g
188
+ .append('polygon')
189
+ .attr(
190
+ 'points',
191
+ w / 2 +
192
+ ',' +
193
+ (h * 2) / 3 +
194
+ ' ' +
195
+ (w * 5) / 6 +
196
+ ',' +
197
+ (h * 2) / 3 +
198
+ ' ' +
199
+ (w * 2) / 3 +
200
+ ',' +
201
+ h / 3
202
+ )
203
+ setAttributes(t0_, classifier.mixColors[0], texts['m12'])
204
+ //triangle s1
205
+ const t1_ = g
206
+ .append('polygon')
207
+ .attr('points', w / 2 + ',' + (h * 2) / 3 + ' ' + w / 3 + ',' + h + ' ' + (w * 2) / 3 + ',' + h)
208
+ setAttributes(t1_, classifier.mixColors[1], texts['m02'])
209
+ //triangle s2
210
+ const t2_ = g
211
+ .append('polygon')
212
+ .attr(
213
+ 'points',
214
+ w / 2 + ',' + (h * 2) / 3 + ' ' + w / 6 + ',' + (h * 2) / 3 + ' ' + w / 3 + ',' + h / 3
215
+ )
216
+ setAttributes(t2_, classifier.mixColors[2], texts['m01'])
217
+
218
+ //center
219
+ if (this.centerCoefficient) {
220
+ //TODO make it an hexagon !
221
+ const center = g
222
+ .append('circle')
223
+ .attr('cx', w / 2)
224
+ .attr('cy', (h * 2) / 3)
225
+ .attr('r', (this.centerCoefficient * h) / 3)
226
+ setAttributes(center, classifier.centerColor, texts['center'])
227
+ }
228
+
229
+ /*
230
+ let middle, left, top, right, left_, bottom_, right_
231
+ if (!this.real) {
232
+
233
+ //0 left triangle
234
+ left = g.append('polygon')
235
+ .attr('points', "0," + h + " " + (w / 3) + "," + h + " " + (w / 6) + "," + (2 * h / 3))
236
+ //1 top triangle
237
+ top = g.append('polygon')
238
+ .attr('points', (w / 3) + "," + (h / 3) + " " + (w * 2 / 3) + "," + (h / 3) + " " + (w / 2) + ",0")
239
+ //2 right triangle
240
+ right = g.append('polygon')
241
+ .attr('points', (w * 2 / 3) + "," + h + " " + w + "," + h + " " + (w * 5 / 6) + "," + (2 * h / 3))
242
+ //middle triangle
243
+ middle = g.append('polygon')
244
+ .attr('points', (w / 2) + "," + (h / 3) + " " + (w / 4) + "," + (h * 5 / 6) + " " + (3 * w / 4) + "," + (h * 5 / 6))
245
+ //01 left trapezium
246
+ left_ = g.append('polygon')
247
+ .attr('points', (w / 6) + "," + (h * 2 / 3) + " " + (w / 4) + "," + (h * 5 / 6) + " " + (w / 2) + "," + (h / 3) + " " + (w / 3) + "," + (h / 3))
248
+ //02 bottom trapezium
249
+ bottom_ = g.append('polygon')
250
+ .attr('points', (w / 3) + "," + (h) + " " + (2 * w / 3) + "," + (h) + " " + (w * 3 / 4) + "," + (h * 5 / 6) + " " + (w / 4) + "," + (h * 5 / 6))
251
+ //12 right trapezium
252
+ right_ = g.append('polygon')
253
+ .attr('points', (w / 2) + "," + (h / 3) + " " + (w * 3 / 4) + "," + (h * 5 / 6) + " " + (w * 5 / 6) + "," + (h * 2 / 3) + " " + (w * 2 / 3) + "," + (h / 3))
254
+
255
+ } else {
256
+
257
+ //middle triangle
258
+ middle = g.append('polygon')
259
+ .attr('points', (w / 2) + ",0 0," + h + " " + w + "," + h)
260
+
261
+ //draw trapezium
262
+ //draw large trapezium first
263
+ for (let i_ = 2; i_ >= 0; i_--) {
264
+ const i = this.classifier.lowIndex[i_]
265
+ const r = this.classifier.lowThreshold[i]
266
+ if (i == 2)
267
+ //01 left trapezium
268
+ left_ = g.append('polygon')
269
+ .attr('points', w / 2 + ",0 0," + h + " " + w * r + "," + h + " " + w * (1 + r) / 2 + "," + r * h)
270
+ else if (i == 1)
271
+ //02 bottom trapezium
272
+ bottom_ = g.append('polygon')
273
+ .attr('points', "0," + h + " " + w + "," + h + " " + w * (1 - r / 2) + "," + h * (1 - r) + " " + r * w / 2 + "," + h * (1 - r))
274
+ else
275
+ //12 right trapezium
276
+ right_ = g.append('polygon')
277
+ .attr('points', w + "," + h + " " + w / 2 + ",0 " + w * (1 - r) / 2 + "," + h * r + " " + w * (1 - r) + "," + h)
278
+ }
279
+
280
+ //draw triangles
281
+ //draw large triangles first
282
+ for (let i_ = 2; i_ >= 0; i_--) {
283
+ const i = this.classifier.highIndex[i_]
284
+ const r = this.classifier.highThreshold[i]
285
+
286
+ if (i == 2)
287
+ //2 right triangle
288
+ right = g.append('polygon')
289
+ .attr('points', w + "," + h + " " + w * r + "," + h + " " + w * (1 + r) / 2 + "," + h * r)
290
+ else if (i == 1)
291
+ //1 top triangle
292
+ top = g.append('polygon')
293
+ .attr('points', (w / 2) + ",0 " + w * r / 2 + "," + h * (1 - r) + " " + w * (1 - r / 2) + "," + h * (1 - r))
294
+ else
295
+ //0 left triangle
296
+ left = g.append('polygon')
297
+ .attr('points', "0," + h + " " + w * (1 - r) + "," + h + " " + w * (1 - r) / 2 + "," + h * r)
298
+ }
299
+
300
+ }*/
301
+ }
302
+ }