@orbcharts/plugins-basic 3.0.0-alpha.50 → 3.0.0-alpha.51
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +200 -200
- package/dist/orbcharts-plugins-basic.es.js +4893 -4913
- package/dist/orbcharts-plugins-basic.umd.js +7 -7
- package/dist/src/base/BaseGroupAxis.d.ts +1 -0
- package/dist/src/grid/index.d.ts +1 -1
- package/dist/src/grid/plugins/BarsPN.d.ts +1 -0
- package/dist/src/grid/types.d.ts +3 -2
- package/dist/src/series/types.d.ts +2 -3
- package/package.json +42 -42
- package/src/base/BaseBarStack.ts +778 -778
- package/src/base/BaseBars.ts +764 -764
- package/src/base/BaseBarsTriangle.ts +672 -672
- package/src/base/BaseDots.ts +513 -502
- package/src/base/BaseGroupAxis.ts +562 -496
- package/src/base/BaseLegend.ts +641 -641
- package/src/base/BaseLineAreas.ts +625 -625
- package/src/base/BaseLines.ts +699 -699
- package/src/base/BaseValueAxis.ts +478 -478
- package/src/base/types.ts +2 -2
- package/src/grid/defaults.ts +125 -123
- package/src/grid/gridObservables.ts +248 -248
- package/src/grid/index.ts +15 -15
- package/src/grid/plugins/BarStack.ts +43 -43
- package/src/grid/plugins/Bars.ts +44 -44
- package/src/grid/plugins/{BarsDiverging.ts → BarsPN.ts} +41 -41
- package/src/grid/plugins/BarsTriangle.ts +42 -42
- package/src/grid/plugins/Dots.ts +37 -37
- package/src/grid/plugins/GridLegend.ts +59 -59
- package/src/grid/plugins/GroupAux.ts +645 -645
- package/src/grid/plugins/GroupAxis.ts +35 -35
- package/src/grid/plugins/LineAreas.ts +39 -39
- package/src/grid/plugins/Lines.ts +38 -38
- package/src/grid/plugins/ScalingArea.ts +173 -173
- package/src/grid/plugins/ValueAxis.ts +36 -36
- package/src/grid/plugins/ValueStackAxis.ts +38 -38
- package/src/grid/types.ts +122 -120
- package/src/index.ts +9 -9
- package/src/multiGrid/defaults.ts +152 -152
- package/src/multiGrid/index.ts +13 -13
- package/src/multiGrid/multiGridObservables.ts +44 -44
- package/src/multiGrid/plugins/MultiBarStack.ts +78 -78
- package/src/multiGrid/plugins/MultiBars.ts +77 -77
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +77 -77
- package/src/multiGrid/plugins/MultiDots.ts +65 -65
- package/src/multiGrid/plugins/MultiGridLegend.ts +89 -89
- package/src/multiGrid/plugins/MultiGroupAxis.ts +69 -69
- package/src/multiGrid/plugins/MultiLineAreas.ts +67 -67
- package/src/multiGrid/plugins/MultiLines.ts +66 -66
- package/src/multiGrid/plugins/MultiValueAxis.ts +69 -69
- package/src/multiGrid/plugins/MultiValueStackAxis.ts +69 -69
- package/src/multiGrid/plugins/OverlappingValueAxes.ts +166 -166
- package/src/multiGrid/plugins/OverlappingValueStackAxes.ts +167 -167
- package/src/multiGrid/types.ts +71 -71
- package/src/noneData/defaults.ts +64 -64
- package/src/noneData/index.ts +3 -3
- package/src/noneData/plugins/Container.ts +10 -10
- package/src/noneData/plugins/Tooltip.ts +310 -310
- package/src/noneData/types.ts +26 -26
- package/src/series/defaults.ts +126 -126
- package/src/series/index.ts +9 -9
- package/src/series/plugins/Bubbles.ts +545 -602
- package/src/series/plugins/Pie.ts +576 -576
- package/src/series/plugins/PieEventTexts.ts +262 -262
- package/src/series/plugins/PieLabels.ts +304 -304
- package/src/series/plugins/Rose.ts +472 -472
- package/src/series/plugins/RoseLabels.ts +362 -362
- package/src/series/plugins/SeriesLegend.ts +59 -59
- package/src/series/seriesObservables.ts +145 -145
- package/src/series/seriesUtils.ts +51 -51
- package/src/series/types.ts +83 -83
- package/src/tree/defaults.ts +22 -22
- package/src/tree/index.ts +3 -3
- package/src/tree/plugins/TreeLegend.ts +59 -59
- package/src/tree/plugins/TreeMap.ts +305 -305
- package/src/tree/types.ts +23 -23
- package/src/utils/commonUtils.ts +21 -21
- package/src/utils/d3Graphics.ts +124 -124
- package/src/utils/d3Utils.ts +73 -73
- package/src/utils/observables.ts +14 -14
- package/src/utils/orbchartsUtils.ts +100 -100
- package/tsconfig.dev.json +16 -16
- package/tsconfig.json +13 -13
- package/tsconfig.prod.json +13 -13
- package/vite.config.js +49 -49
- package/dist/src/grid/plugins/BarsDiverging.d.ts +0 -1
package/src/base/BaseDots.ts
CHANGED
@@ -1,503 +1,514 @@
|
|
1
|
-
import * as d3 from 'd3'
|
2
|
-
import {
|
3
|
-
combineLatest,
|
4
|
-
map,
|
5
|
-
switchMap,
|
6
|
-
takeUntil,
|
7
|
-
distinctUntilChanged,
|
8
|
-
Observable,
|
9
|
-
Subject } from 'rxjs'
|
10
|
-
import type { BasePluginFn } from './types'
|
11
|
-
import type {
|
12
|
-
ComputedDatumGrid,
|
13
|
-
ComputedDataGrid,
|
14
|
-
ComputedLayoutDataGrid,
|
15
|
-
EventGrid,
|
16
|
-
ChartParams,
|
17
|
-
GridContainerPosition,
|
18
|
-
Layout,
|
19
|
-
TransformData,
|
20
|
-
ColorType } from '@orbcharts/core'
|
21
|
-
import { getDatumColor, getClassName, getUniID } from '../utils/orbchartsUtils'
|
22
|
-
import { gridSelectionsObservable } from '../grid/gridObservables'
|
23
|
-
|
24
|
-
export interface BaseDotsParams {
|
25
|
-
radius: number
|
26
|
-
fillColorType: ColorType
|
27
|
-
strokeColorType: ColorType
|
28
|
-
strokeWidth: number
|
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
|
-
// const
|
66
|
-
// const
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
const
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
.
|
90
|
-
.
|
91
|
-
|
92
|
-
|
93
|
-
enterDuration
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
.
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
.
|
104
|
-
|
105
|
-
|
106
|
-
.
|
107
|
-
.
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
.
|
112
|
-
.style('
|
113
|
-
.
|
114
|
-
.
|
115
|
-
.
|
116
|
-
.
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
.
|
125
|
-
|
126
|
-
// .attr('
|
127
|
-
.attr('
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
.attr('
|
133
|
-
.attr('
|
134
|
-
.attr('stroke
|
135
|
-
.attr('
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
//
|
141
|
-
// .
|
142
|
-
// .
|
143
|
-
//
|
144
|
-
//
|
145
|
-
// enterDuration
|
146
|
-
|
147
|
-
|
148
|
-
//
|
149
|
-
// .
|
150
|
-
//
|
151
|
-
//
|
152
|
-
//
|
153
|
-
//
|
154
|
-
//
|
155
|
-
// .
|
156
|
-
//
|
157
|
-
//
|
158
|
-
// .
|
159
|
-
// .
|
160
|
-
//
|
161
|
-
//
|
162
|
-
//
|
163
|
-
// .
|
164
|
-
// .style('
|
165
|
-
// .
|
166
|
-
// .
|
167
|
-
// .
|
168
|
-
// .
|
169
|
-
//
|
170
|
-
//
|
171
|
-
//
|
172
|
-
//
|
173
|
-
//
|
174
|
-
//
|
175
|
-
//
|
176
|
-
// .
|
177
|
-
//
|
178
|
-
// // .attr('
|
179
|
-
// .attr('
|
180
|
-
//
|
181
|
-
//
|
182
|
-
//
|
183
|
-
//
|
184
|
-
// .attr('
|
185
|
-
// .attr('
|
186
|
-
// .attr('stroke
|
187
|
-
// .attr('
|
188
|
-
//
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
.
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
d3.select(n[i])
|
221
|
-
|
222
|
-
.
|
223
|
-
.
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
takeUntil(destroy$),
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
datum,
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
)
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
})
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
1
|
+
import * as d3 from 'd3'
|
2
|
+
import {
|
3
|
+
combineLatest,
|
4
|
+
map,
|
5
|
+
switchMap,
|
6
|
+
takeUntil,
|
7
|
+
distinctUntilChanged,
|
8
|
+
Observable,
|
9
|
+
Subject } from 'rxjs'
|
10
|
+
import type { BasePluginFn } from './types'
|
11
|
+
import type {
|
12
|
+
ComputedDatumGrid,
|
13
|
+
ComputedDataGrid,
|
14
|
+
ComputedLayoutDataGrid,
|
15
|
+
EventGrid,
|
16
|
+
ChartParams,
|
17
|
+
GridContainerPosition,
|
18
|
+
Layout,
|
19
|
+
TransformData,
|
20
|
+
ColorType } from '@orbcharts/core'
|
21
|
+
import { getDatumColor, getClassName, getUniID } from '../utils/orbchartsUtils'
|
22
|
+
import { gridSelectionsObservable } from '../grid/gridObservables'
|
23
|
+
|
24
|
+
export interface BaseDotsParams {
|
25
|
+
radius: number
|
26
|
+
fillColorType: ColorType
|
27
|
+
strokeColorType: ColorType
|
28
|
+
strokeWidth: number
|
29
|
+
// strokeWidthWhileHighlight: number
|
30
|
+
onlyShowHighlighted: boolean
|
31
|
+
}
|
32
|
+
|
33
|
+
interface BaseDotsContext {
|
34
|
+
selection: d3.Selection<any, unknown, any, unknown>
|
35
|
+
computedData$: Observable<ComputedDataGrid>
|
36
|
+
computedLayoutData$: Observable<ComputedLayoutDataGrid>
|
37
|
+
visibleComputedData$: Observable<ComputedDatumGrid[][]>
|
38
|
+
visibleComputedLayoutData$: Observable<ComputedLayoutDataGrid>
|
39
|
+
seriesLabels$: Observable<string[]>
|
40
|
+
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
41
|
+
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
42
|
+
fullParams$: Observable<BaseDotsParams>
|
43
|
+
fullChartParams$: Observable<ChartParams>
|
44
|
+
gridAxesTransform$: Observable<TransformData>
|
45
|
+
gridGraphicTransform$: Observable<TransformData>
|
46
|
+
gridGraphicReverseScale$: Observable<[number, number][]>
|
47
|
+
gridAxesSize$: Observable<{
|
48
|
+
width: number;
|
49
|
+
height: number;
|
50
|
+
}>
|
51
|
+
gridHighlight$: Observable<ComputedDatumGrid[]>
|
52
|
+
gridContainerPosition$: Observable<GridContainerPosition[]>
|
53
|
+
event$: Subject<EventGrid>
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
type ClipPathDatum = {
|
58
|
+
id: string;
|
59
|
+
// x: number;
|
60
|
+
// y: number;
|
61
|
+
width: number;
|
62
|
+
height: number;
|
63
|
+
}
|
64
|
+
|
65
|
+
// const pluginName = 'Dots'
|
66
|
+
// const circleGClassName = getClassName(pluginName, 'circleG')
|
67
|
+
// const circleClassName = getClassName(pluginName, 'circle')
|
68
|
+
|
69
|
+
function renderDots ({ graphicGSelection, circleGClassName, circleClassName, visibleComputedLayoutData, fullParams, fullChartParams, graphicReverseScale }: {
|
70
|
+
graphicGSelection: d3.Selection<SVGGElement, any, any, any>
|
71
|
+
circleGClassName: string
|
72
|
+
circleClassName: string
|
73
|
+
visibleComputedLayoutData: ComputedLayoutDataGrid
|
74
|
+
fullParams: BaseDotsParams
|
75
|
+
fullChartParams: ChartParams
|
76
|
+
graphicReverseScale: [number, number][]
|
77
|
+
}) {
|
78
|
+
const createEnterDuration = (enter: d3.Selection<d3.EnterElement, ComputedDatumGrid, SVGGElement, any>) => {
|
79
|
+
const enterSize = enter.size()
|
80
|
+
const eachDuration = fullChartParams.transitionDuration / enterSize
|
81
|
+
return eachDuration
|
82
|
+
}
|
83
|
+
// enterDuration
|
84
|
+
let enterDuration = 0
|
85
|
+
|
86
|
+
graphicGSelection
|
87
|
+
.each((seriesData, seriesIndex, g) => {
|
88
|
+
d3.select(g[seriesIndex])
|
89
|
+
.selectAll<SVGGElement, ComputedDatumGrid>('g')
|
90
|
+
.data(visibleComputedLayoutData[seriesIndex], d => d.id)
|
91
|
+
.join(
|
92
|
+
enter => {
|
93
|
+
// enterDuration
|
94
|
+
enterDuration = createEnterDuration(enter)
|
95
|
+
|
96
|
+
return enter
|
97
|
+
.append('g')
|
98
|
+
.classed(circleGClassName, true)
|
99
|
+
},
|
100
|
+
update => update,
|
101
|
+
exit => exit.remove()
|
102
|
+
)
|
103
|
+
.attr('transform', d => `translate(${d.axisX}, ${d.axisY})`)
|
104
|
+
.each((d, i, g) => {
|
105
|
+
const circle = d3.select(g[i])
|
106
|
+
.selectAll('circle')
|
107
|
+
.data([d])
|
108
|
+
.join(
|
109
|
+
enter => {
|
110
|
+
return enter
|
111
|
+
.append('circle')
|
112
|
+
.style('cursor', 'pointer')
|
113
|
+
.style('vector-effect', 'non-scaling-stroke')
|
114
|
+
.classed(circleClassName, true)
|
115
|
+
.attr('opacity', 0)
|
116
|
+
.transition()
|
117
|
+
.delay((_d, _i) => {
|
118
|
+
return i * enterDuration
|
119
|
+
})
|
120
|
+
.attr('opacity', 1)
|
121
|
+
},
|
122
|
+
update => {
|
123
|
+
return update
|
124
|
+
.transition()
|
125
|
+
.duration(50)
|
126
|
+
// .attr('cx', d => d.axisX)
|
127
|
+
// .attr('cy', d => d.axisY)
|
128
|
+
.attr('opacity', 1)
|
129
|
+
},
|
130
|
+
exit => exit.remove()
|
131
|
+
)
|
132
|
+
.attr('r', fullParams.radius)
|
133
|
+
.attr('fill', (d, i) => getDatumColor({ datum: d, colorType: fullParams.fillColorType, fullChartParams }))
|
134
|
+
.attr('stroke', (d, i) => getDatumColor({ datum: d, colorType: fullParams.strokeColorType, fullChartParams }))
|
135
|
+
.attr('stroke-width', fullParams.strokeWidth)
|
136
|
+
.attr('transform', `scale(${graphicReverseScale[seriesIndex][0] ?? 1}, ${graphicReverseScale[seriesIndex][1] ?? 1})`)
|
137
|
+
})
|
138
|
+
})
|
139
|
+
|
140
|
+
// const dots = graphicGSelection
|
141
|
+
// .selectAll<SVGGElement, ComputedDatumGrid>('g')
|
142
|
+
// .data(data, d => d.id)
|
143
|
+
// .join(
|
144
|
+
// enter => {
|
145
|
+
// // enterDuration
|
146
|
+
// enterDuration = createEnterDuration(enter)
|
147
|
+
|
148
|
+
// return enter
|
149
|
+
// .append('g')
|
150
|
+
// .classed(circleGClassName, true)
|
151
|
+
// },
|
152
|
+
// update => update,
|
153
|
+
// exit => exit.remove()
|
154
|
+
// )
|
155
|
+
// .attr('transform', d => `translate(${d.axisX}, ${d.axisY})`)
|
156
|
+
// .each((d, i, g) => {
|
157
|
+
// const circle = d3.select(g[i])
|
158
|
+
// .selectAll('circle')
|
159
|
+
// .data([d])
|
160
|
+
// .join(
|
161
|
+
// enter => {
|
162
|
+
// return enter
|
163
|
+
// .append('circle')
|
164
|
+
// .style('cursor', 'pointer')
|
165
|
+
// .style('vector-effect', 'non-scaling-stroke')
|
166
|
+
// .classed(circleClassName, true)
|
167
|
+
// .attr('opacity', 0)
|
168
|
+
// .transition()
|
169
|
+
// .delay((_d, _i) => {
|
170
|
+
// return i * enterDuration
|
171
|
+
// })
|
172
|
+
// .attr('opacity', 1)
|
173
|
+
// },
|
174
|
+
// update => {
|
175
|
+
// return update
|
176
|
+
// .transition()
|
177
|
+
// .duration(50)
|
178
|
+
// // .attr('cx', d => d.axisX)
|
179
|
+
// // .attr('cy', d => d.axisY)
|
180
|
+
// .attr('opacity', 1)
|
181
|
+
// },
|
182
|
+
// exit => exit.remove()
|
183
|
+
// )
|
184
|
+
// .attr('r', fullParams.radius)
|
185
|
+
// .attr('fill', (d, i) => getDatumColor({ datum: d, colorType: fullParams.fillColorType, fullChartParams }))
|
186
|
+
// .attr('stroke', (d, i) => getDatumColor({ datum: d, colorType: fullParams.strokeColorType, fullChartParams }))
|
187
|
+
// .attr('stroke-width', fullParams.strokeWidth)
|
188
|
+
// .attr('transform', `scale(${graphicReverseScale[0]}, ${graphicReverseScale[1]})`)
|
189
|
+
// })
|
190
|
+
|
191
|
+
const graphicCircleSelection: d3.Selection<SVGRectElement, ComputedDatumGrid, SVGGElement, unknown> = graphicGSelection.selectAll(`circle.${circleClassName}`)
|
192
|
+
|
193
|
+
return graphicCircleSelection
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
function highlightDots ({ selection, ids, onlyShowHighlighted, fullChartParams }: {
|
198
|
+
selection: d3.Selection<SVGGElement, ComputedDatumGrid, any, any>
|
199
|
+
ids: string[]
|
200
|
+
onlyShowHighlighted: boolean
|
201
|
+
// fullParams: BaseDotsParams
|
202
|
+
fullChartParams: ChartParams
|
203
|
+
}) {
|
204
|
+
selection.interrupt('highlight')
|
205
|
+
if (!ids.length) {
|
206
|
+
// remove highlight
|
207
|
+
selection
|
208
|
+
.transition('highlight')
|
209
|
+
.duration(200)
|
210
|
+
.style('opacity', onlyShowHighlighted === true ? 0 : 1)
|
211
|
+
// selection
|
212
|
+
// .attr('stroke-width', fullParams.strokeWidth)
|
213
|
+
|
214
|
+
return
|
215
|
+
}
|
216
|
+
|
217
|
+
selection
|
218
|
+
.each((d, i, n) => {
|
219
|
+
if (ids.includes(d.id)) {
|
220
|
+
const dot = d3.select(n[i])
|
221
|
+
dot
|
222
|
+
.style('opacity', 1)
|
223
|
+
.transition('highlight')
|
224
|
+
.duration(200)
|
225
|
+
// dot
|
226
|
+
// .attr('stroke-width', fullParams.strokeWidthWhileHighlight)
|
227
|
+
} else {
|
228
|
+
const dot = d3.select(n[i])
|
229
|
+
dot
|
230
|
+
.style('opacity', onlyShowHighlighted === true ? 0 : fullChartParams.styles.unhighlightedOpacity)
|
231
|
+
.transition('highlight')
|
232
|
+
.duration(200)
|
233
|
+
// dot
|
234
|
+
// .attr('stroke-width', fullParams.strokeWidth)
|
235
|
+
|
236
|
+
}
|
237
|
+
})
|
238
|
+
}
|
239
|
+
|
240
|
+
function renderClipPath ({ defsSelection, clipPathData }: {
|
241
|
+
defsSelection: d3.Selection<SVGDefsElement, any, any, any>
|
242
|
+
clipPathData: ClipPathDatum[]
|
243
|
+
}) {
|
244
|
+
const clipPath = defsSelection
|
245
|
+
.selectAll<SVGClipPathElement, Layout>('clipPath')
|
246
|
+
.data(clipPathData)
|
247
|
+
.join(
|
248
|
+
enter => {
|
249
|
+
return enter
|
250
|
+
.append('clipPath')
|
251
|
+
},
|
252
|
+
update => update,
|
253
|
+
exit => exit.remove()
|
254
|
+
)
|
255
|
+
.attr('id', d => d.id)
|
256
|
+
.each((d, i, g) => {
|
257
|
+
const rect = d3.select(g[i])
|
258
|
+
.selectAll<SVGRectElement, typeof d>('rect')
|
259
|
+
.data([d])
|
260
|
+
.join('rect')
|
261
|
+
.attr('x', 0)
|
262
|
+
.attr('y', 0)
|
263
|
+
.attr('width', _d => _d.width)
|
264
|
+
.attr('height', _d => _d.height)
|
265
|
+
})
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
export const createBaseDots: BasePluginFn<BaseDotsContext> = (pluginName: string, {
|
272
|
+
selection,
|
273
|
+
computedData$,
|
274
|
+
computedLayoutData$,
|
275
|
+
visibleComputedData$,
|
276
|
+
visibleComputedLayoutData$,
|
277
|
+
seriesLabels$,
|
278
|
+
SeriesDataMap$,
|
279
|
+
GroupDataMap$,
|
280
|
+
fullParams$,
|
281
|
+
fullChartParams$,
|
282
|
+
gridAxesTransform$,
|
283
|
+
gridGraphicTransform$,
|
284
|
+
gridGraphicReverseScale$,
|
285
|
+
gridAxesSize$,
|
286
|
+
gridHighlight$,
|
287
|
+
gridContainerPosition$,
|
288
|
+
event$
|
289
|
+
}) => {
|
290
|
+
|
291
|
+
const destroy$ = new Subject()
|
292
|
+
|
293
|
+
const clipPathID = getUniID(pluginName, 'clipPath-box')
|
294
|
+
const circleGClassName = getClassName(pluginName, 'circleG')
|
295
|
+
const circleClassName = getClassName(pluginName, 'circle')
|
296
|
+
|
297
|
+
// const axisSelection: d3.Selection<SVGGElement, any, any, any> = selection
|
298
|
+
// .append('g')
|
299
|
+
// .attr('clip-path', `url(#${clipPathID})`)
|
300
|
+
// const defsSelection: d3.Selection<SVGDefsElement, any, any, any> = axisSelection.append('defs')
|
301
|
+
// const dataAreaSelection: d3.Selection<SVGGElement, any, any, any> = axisSelection.append('g')
|
302
|
+
// const graphicSelection$: Subject<d3.Selection<SVGGElement, ComputedDatumGrid, any, any>> = new Subject()
|
303
|
+
|
304
|
+
const {
|
305
|
+
seriesSelection$,
|
306
|
+
axesSelection$,
|
307
|
+
defsSelection$,
|
308
|
+
graphicGSelection$
|
309
|
+
} = gridSelectionsObservable({
|
310
|
+
selection,
|
311
|
+
pluginName,
|
312
|
+
clipPathID,
|
313
|
+
seriesLabels$,
|
314
|
+
gridContainerPosition$,
|
315
|
+
gridAxesTransform$,
|
316
|
+
gridGraphicTransform$
|
317
|
+
})
|
318
|
+
|
319
|
+
const graphicReverseScale$: Observable<[number, number][]> = combineLatest({
|
320
|
+
// gridGraphicTransform: gridGraphicTransform$,
|
321
|
+
// gridContainerPosition: gridContainerPosition$,
|
322
|
+
// gridAxesTransform: gridAxesTransform$
|
323
|
+
computedData: computedData$,
|
324
|
+
gridGraphicReverseScale: gridGraphicReverseScale$
|
325
|
+
}).pipe(
|
326
|
+
takeUntil(destroy$),
|
327
|
+
switchMap(async data => data),
|
328
|
+
map(data => {
|
329
|
+
return data.computedData.map((series, seriesIndex) => {
|
330
|
+
return data.gridGraphicReverseScale[seriesIndex]
|
331
|
+
})
|
332
|
+
})
|
333
|
+
)
|
334
|
+
|
335
|
+
const clipPathSubscription = combineLatest({
|
336
|
+
defsSelection: defsSelection$,
|
337
|
+
gridAxesSize: gridAxesSize$,
|
338
|
+
}).pipe(
|
339
|
+
takeUntil(destroy$),
|
340
|
+
switchMap(async (d) => d),
|
341
|
+
).subscribe(data => {
|
342
|
+
// 外層的遮罩
|
343
|
+
const clipPathData = [{
|
344
|
+
id: clipPathID,
|
345
|
+
width: data.gridAxesSize.width,
|
346
|
+
height: data.gridAxesSize.height
|
347
|
+
}]
|
348
|
+
renderClipPath({
|
349
|
+
defsSelection: data.defsSelection,
|
350
|
+
clipPathData,
|
351
|
+
})
|
352
|
+
})
|
353
|
+
|
354
|
+
const highlightTarget$ = fullChartParams$.pipe(
|
355
|
+
takeUntil(destroy$),
|
356
|
+
map(d => d.highlightTarget),
|
357
|
+
distinctUntilChanged()
|
358
|
+
)
|
359
|
+
|
360
|
+
const graphicSelection$ = combineLatest({
|
361
|
+
graphicGSelection: graphicGSelection$,
|
362
|
+
visibleComputedLayoutData: visibleComputedLayoutData$,
|
363
|
+
graphicReverseScale: graphicReverseScale$,
|
364
|
+
fullChartParams: fullChartParams$,
|
365
|
+
fullParams: fullParams$,
|
366
|
+
}).pipe(
|
367
|
+
takeUntil(destroy$),
|
368
|
+
switchMap(async (d) => d),
|
369
|
+
map(data => {
|
370
|
+
return renderDots({
|
371
|
+
graphicGSelection: data.graphicGSelection,
|
372
|
+
circleGClassName,
|
373
|
+
circleClassName,
|
374
|
+
visibleComputedLayoutData: data.visibleComputedLayoutData,
|
375
|
+
fullParams: data.fullParams,
|
376
|
+
fullChartParams: data.fullChartParams,
|
377
|
+
graphicReverseScale: data.graphicReverseScale
|
378
|
+
})
|
379
|
+
})
|
380
|
+
)
|
381
|
+
|
382
|
+
combineLatest({
|
383
|
+
graphicSelection: graphicSelection$,
|
384
|
+
computedData: computedData$,
|
385
|
+
SeriesDataMap: SeriesDataMap$,
|
386
|
+
GroupDataMap: GroupDataMap$,
|
387
|
+
highlightTarget: highlightTarget$
|
388
|
+
}).pipe(
|
389
|
+
takeUntil(destroy$),
|
390
|
+
switchMap(async (d) => d),
|
391
|
+
).subscribe(data => {
|
392
|
+
|
393
|
+
data.graphicSelection
|
394
|
+
.on('mouseover', (event, datum) => {
|
395
|
+
event.stopPropagation()
|
396
|
+
|
397
|
+
event$.next({
|
398
|
+
type: 'grid',
|
399
|
+
eventName: 'mouseover',
|
400
|
+
pluginName,
|
401
|
+
highlightTarget: data.highlightTarget,
|
402
|
+
datum,
|
403
|
+
gridIndex: datum.gridIndex,
|
404
|
+
series: data.SeriesDataMap.get(datum.seriesLabel)!,
|
405
|
+
seriesIndex: datum.seriesIndex,
|
406
|
+
seriesLabel: datum.seriesLabel,
|
407
|
+
groups: data.GroupDataMap.get(datum.groupLabel)!,
|
408
|
+
groupIndex: datum.groupIndex,
|
409
|
+
groupLabel: datum.groupLabel,
|
410
|
+
event,
|
411
|
+
data: data.computedData
|
412
|
+
})
|
413
|
+
})
|
414
|
+
.on('mousemove', (event, datum) => {
|
415
|
+
event.stopPropagation()
|
416
|
+
|
417
|
+
event$.next({
|
418
|
+
type: 'grid',
|
419
|
+
eventName: 'mousemove',
|
420
|
+
pluginName,
|
421
|
+
highlightTarget: data.highlightTarget,
|
422
|
+
data: data.computedData,
|
423
|
+
datum,
|
424
|
+
gridIndex: datum.gridIndex,
|
425
|
+
series: data.SeriesDataMap.get(datum.seriesLabel)!,
|
426
|
+
seriesIndex: datum.seriesIndex,
|
427
|
+
seriesLabel: datum.seriesLabel,
|
428
|
+
groups: data.GroupDataMap.get(datum.groupLabel)!,
|
429
|
+
groupIndex: datum.groupIndex,
|
430
|
+
groupLabel: datum.groupLabel,
|
431
|
+
event
|
432
|
+
})
|
433
|
+
})
|
434
|
+
.on('mouseout', (event, datum) => {
|
435
|
+
event.stopPropagation()
|
436
|
+
|
437
|
+
event$.next({
|
438
|
+
type: 'grid',
|
439
|
+
eventName: 'mouseout',
|
440
|
+
pluginName,
|
441
|
+
highlightTarget: data.highlightTarget,
|
442
|
+
datum,
|
443
|
+
gridIndex: datum.gridIndex,
|
444
|
+
series: data.SeriesDataMap.get(datum.seriesLabel)!,
|
445
|
+
seriesIndex: datum.seriesIndex,
|
446
|
+
seriesLabel: datum.seriesLabel,
|
447
|
+
groups: data.GroupDataMap.get(datum.groupLabel)!,
|
448
|
+
groupIndex: datum.groupIndex,
|
449
|
+
groupLabel: datum.groupLabel,
|
450
|
+
event,
|
451
|
+
data: data.computedData
|
452
|
+
})
|
453
|
+
})
|
454
|
+
.on('click', (event, datum) => {
|
455
|
+
event.stopPropagation()
|
456
|
+
|
457
|
+
event$.next({
|
458
|
+
type: 'grid',
|
459
|
+
eventName: 'click',
|
460
|
+
pluginName,
|
461
|
+
highlightTarget: data.highlightTarget,
|
462
|
+
datum,
|
463
|
+
gridIndex: datum.gridIndex,
|
464
|
+
series: data.SeriesDataMap.get(datum.seriesLabel)!,
|
465
|
+
seriesIndex: datum.seriesIndex,
|
466
|
+
seriesLabel: datum.seriesLabel,
|
467
|
+
groups: data.GroupDataMap.get(datum.groupLabel)!,
|
468
|
+
groupIndex: datum.groupIndex,
|
469
|
+
groupLabel: datum.groupLabel,
|
470
|
+
event,
|
471
|
+
data: data.computedData
|
472
|
+
})
|
473
|
+
})
|
474
|
+
|
475
|
+
})
|
476
|
+
|
477
|
+
// const datumList$ = computedData$.pipe(
|
478
|
+
// takeUntil(destroy$),
|
479
|
+
// map(d => d.flat())
|
480
|
+
// )
|
481
|
+
// const highlight$ = highlightObservable({ datumList$, fullChartParams$, event$: store.event$ })
|
482
|
+
// const highlightSubscription = gridHighlight$.subscribe()
|
483
|
+
const onlyShowHighlighted$ = fullParams$.pipe(
|
484
|
+
takeUntil(destroy$),
|
485
|
+
map(d => d.onlyShowHighlighted),
|
486
|
+
distinctUntilChanged()
|
487
|
+
)
|
488
|
+
|
489
|
+
combineLatest({
|
490
|
+
graphicSelection: graphicSelection$,
|
491
|
+
highlight: gridHighlight$.pipe(
|
492
|
+
map(data => data.map(d => d.id))
|
493
|
+
),
|
494
|
+
onlyShowHighlighted: onlyShowHighlighted$,
|
495
|
+
// fullParams: fullParams$,
|
496
|
+
fullChartParams: fullChartParams$
|
497
|
+
}).pipe(
|
498
|
+
takeUntil(destroy$),
|
499
|
+
switchMap(async d => d)
|
500
|
+
).subscribe(data => {
|
501
|
+
highlightDots({
|
502
|
+
selection: data.graphicSelection,
|
503
|
+
ids: data.highlight,
|
504
|
+
onlyShowHighlighted: data.onlyShowHighlighted,
|
505
|
+
// fullParams: data.fullParams,
|
506
|
+
fullChartParams: data.fullChartParams
|
507
|
+
})
|
508
|
+
})
|
509
|
+
|
510
|
+
return () => {
|
511
|
+
destroy$.next(undefined)
|
512
|
+
// highlightSubscription.unsubscribe()
|
513
|
+
}
|
503
514
|
}
|