@orbcharts/plugins-basic 3.0.0-beta.6 → 3.0.0-beta.8

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 (78) hide show
  1. package/dist/orbcharts-plugins-basic/src/base/{BaseBarStack.d.ts → BaseStackedBar.d.ts} +4 -4
  2. package/dist/orbcharts-plugins-basic/src/grid/defaults.d.ts +3 -3
  3. package/dist/orbcharts-plugins-basic/src/grid/index.d.ts +2 -2
  4. package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +1 -0
  5. package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedValueAxis.d.ts +1 -0
  6. package/dist/orbcharts-plugins-basic/src/index.d.ts +1 -0
  7. package/dist/orbcharts-plugins-basic/src/multiGrid/defaults.d.ts +4 -4
  8. package/dist/orbcharts-plugins-basic/src/multiGrid/index.d.ts +3 -3
  9. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +1 -0
  10. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedValueAxis.d.ts +1 -0
  11. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +1 -0
  12. package/dist/orbcharts-plugins-basic/src/noneData/plugins/Container.d.ts +0 -1
  13. package/dist/orbcharts-plugins-basic/src/noneData/plugins/Tooltip.d.ts +0 -3
  14. package/dist/orbcharts-plugins-basic/src/relationship/defaults.d.ts +5 -0
  15. package/dist/orbcharts-plugins-basic/src/relationship/index.d.ts +4 -0
  16. package/dist/orbcharts-plugins-basic/src/relationship/plugins/ForceDirected.d.ts +3 -0
  17. package/dist/orbcharts-plugins-basic/src/relationship/plugins/RelationshipLegend.d.ts +1 -0
  18. package/dist/orbcharts-plugins-basic/src/relationship/plugins/RelationshipTooltip.d.ts +1 -0
  19. package/dist/orbcharts-plugins-basic/src/relationship/relationshipObservables.d.ts +1 -0
  20. package/dist/orbcharts-plugins-basic/src/utils/commonUtils.d.ts +1 -1
  21. package/dist/orbcharts-plugins-basic/src/utils/d3Utils.d.ts +2 -2
  22. package/dist/orbcharts-plugins-basic/src/utils/orbchartsUtils.d.ts +1 -1
  23. package/dist/orbcharts-plugins-basic.es.js +8088 -7413
  24. package/dist/orbcharts-plugins-basic.umd.js +45 -32
  25. package/package.json +4 -4
  26. package/src/base/BaseBars.ts +4 -4
  27. package/src/base/BaseBarsTriangle.ts +4 -2
  28. package/src/base/BaseDots.ts +1 -1
  29. package/src/base/BaseGroupAxis.ts +47 -47
  30. package/src/base/BaseLegend.ts +4 -4
  31. package/src/base/BaseLineAreas.ts +1 -1
  32. package/src/base/{BaseBarStack.ts → BaseStackedBar.ts} +20 -18
  33. package/src/base/BaseTooltip.ts +1 -1
  34. package/src/base/BaseValueAxis.ts +55 -55
  35. package/src/grid/defaults.ts +8 -6
  36. package/src/grid/gridObservables.ts +32 -32
  37. package/src/grid/index.ts +2 -2
  38. package/src/grid/plugins/GridZoom.ts +6 -6
  39. package/src/grid/plugins/GroupAux.ts +23 -23
  40. package/src/grid/plugins/{BarStack.ts → StackedBar.ts} +7 -7
  41. package/src/grid/plugins/{ValueStackAxis.ts → StackedValueAxis.ts} +5 -5
  42. package/src/index.ts +1 -5
  43. package/src/multiGrid/defaults.ts +7 -7
  44. package/src/multiGrid/index.ts +3 -3
  45. package/src/multiGrid/plugins/MultiBars.ts +1 -1
  46. package/src/multiGrid/plugins/MultiBarsTriangle.ts +1 -1
  47. package/src/multiGrid/plugins/MultiGroupAxis.ts +1 -1
  48. package/src/multiGrid/plugins/{MultiBarStack.ts → MultiStackedBar.ts} +8 -8
  49. package/src/multiGrid/plugins/{MultiValueStackAxis.ts → MultiStackedValueAxis.ts} +3 -3
  50. package/src/multiGrid/plugins/MultiValueAxis.ts +1 -1
  51. package/src/multiGrid/plugins/{OverlappingValueStackAxes.ts → OverlappingStackedValueAxes.ts} +8 -8
  52. package/src/multiGrid/plugins/OverlappingValueAxes.ts +3 -3
  53. package/src/multiValue/defaults.ts +10 -6
  54. package/src/multiValue/multiValueObservables.ts +50 -11
  55. package/src/multiValue/plugins/ScatterBubbles.ts +6 -3
  56. package/src/multiValue/plugins/XYAxes.ts +36 -28
  57. package/src/noneData/plugins/Container.ts +23 -23
  58. package/src/noneData/plugins/Tooltip.ts +365 -365
  59. package/src/relationship/defaults.ts +113 -0
  60. package/src/relationship/index.ts +4 -0
  61. package/src/relationship/plugins/ForceDirected.ts +1148 -0
  62. package/src/relationship/plugins/RelationshipLegend.ts +100 -0
  63. package/src/relationship/plugins/RelationshipTooltip.ts +66 -0
  64. package/src/relationship/relationshipObservables.ts +50 -0
  65. package/src/series/defaults.ts +8 -8
  66. package/src/series/plugins/Bubbles.ts +14 -13
  67. package/src/series/plugins/PieEventTexts.ts +20 -19
  68. package/src/tree/defaults.ts +1 -1
  69. package/src/utils/commonUtils.ts +5 -5
  70. package/src/utils/d3Utils.ts +2 -2
  71. package/src/utils/orbchartsUtils.ts +22 -7
  72. package/dist/orbcharts-plugins-basic/src/grid/plugins/BarStack.d.ts +0 -1
  73. package/dist/orbcharts-plugins-basic/src/grid/plugins/ValueStackAxis.d.ts +0 -1
  74. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiBarStack.d.ts +0 -1
  75. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiValueStackAxis.d.ts +0 -1
  76. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/OverlappingValueStackAxes.d.ts +0 -1
  77. /package/dist/orbcharts-plugins-basic/src/relationship/plugins/{Relationship.d.ts → ForceDirectedBubbles.d.ts} +0 -0
  78. /package/src/relationship/plugins/{Relationship.ts → ForceDirectedBubbles.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbcharts/plugins-basic",
3
- "version": "3.0.0-beta.6",
3
+ "version": "3.0.0-beta.8",
4
4
  "description": "plugins for OrbCharts",
5
5
  "author": "Blue Planet Inc.",
6
6
  "license": "Apache-2.0",
@@ -35,9 +35,9 @@
35
35
  "vite-plugin-dts": "^3.7.3"
36
36
  },
37
37
  "dependencies": {
38
- "@orbcharts/core": "^3.0.0-beta.4",
39
- "@orbcharts/core-types": "^3.0.0-beta.3",
40
- "@orbcharts/plugins-basic-types": "^3.0.0-beta.4",
38
+ "@orbcharts/core": "^3.0.0-beta.6",
39
+ "@orbcharts/core-types": "^3.0.0-beta.5",
40
+ "@orbcharts/plugins-basic-types": "^3.0.0-beta.8",
41
41
  "d3": "^7.8.5",
42
42
  "rxjs": "^7.8.1"
43
43
  }
@@ -92,7 +92,7 @@ function calcBarWidth ({ axisWidth, groupAmount, barAmountOfGroup, barPadding =
92
92
  barPadding: number
93
93
  barGroupPadding: number
94
94
  }) {
95
- const eachGroupWidth = groupAmount > 1
95
+ const eachGroupWidth = groupAmount > 1 // 等於 1 時會算出 Infinity
96
96
  ? axisWidth / (groupAmount - 1) // -1是因為要扣掉兩側的padding
97
97
  : axisWidth
98
98
  const width = (eachGroupWidth - barGroupPadding) / barAmountOfGroup - barPadding
@@ -127,7 +127,7 @@ function calctransitionItem (barGroupAmount: number, totalDuration: number) {
127
127
  function renderRectBars ({ graphicGSelection, rectClassName, visibleComputedLayoutData, zeroYArr, groupLabels, barScale, params, chartParams, barWidth, transformedBarRadius, delayGroup, transitionItem, isSeriesSeprate }: RenderBarParams) {
128
128
 
129
129
  const barHalfWidth = barWidth! / 2
130
- // console.log(visibleComputedLayoutData)
130
+
131
131
  graphicGSelection
132
132
  .each((seriesData, seriesIndex, g) => {
133
133
  d3.select(g[seriesIndex])
@@ -140,7 +140,7 @@ function renderRectBars ({ graphicGSelection, rectClassName, visibleComputedLayo
140
140
  .append('rect')
141
141
  .classed(rectClassName, true)
142
142
  .attr('cursor', 'pointer')
143
- .attr('height', d => 0)
143
+ .attr('height', d => 1)
144
144
  },
145
145
  update => update,
146
146
  exit => exit.remove()
@@ -156,7 +156,7 @@ function renderRectBars ({ graphicGSelection, rectClassName, visibleComputedLayo
156
156
  .duration(transitionItem)
157
157
  .ease(getD3TransitionEase(chartParams.transitionEase))
158
158
  .delay((d, i) => d.groupIndex * delayGroup)
159
- .attr('height', d => Math.abs(d.axisYFromZero))
159
+ .attr('height', d => Math.abs(d.axisYFromZero) || 1) // 無值還是給一個 1 的高度
160
160
  })
161
161
 
162
162
 
@@ -100,7 +100,9 @@ function calcBarWidth ({ axisWidth, groupAmount, barAmountOfGroup, barPadding =
100
100
  barPadding: number
101
101
  barGroupPadding: number
102
102
  }) {
103
- const eachGroupWidth = axisWidth / (groupAmount - 1)
103
+ const eachGroupWidth = groupAmount > 1 // 等於 1 時會算出 Infinity
104
+ ? axisWidth / (groupAmount - 1)
105
+ : axisWidth
104
106
  const width = (eachGroupWidth - barGroupPadding) / barAmountOfGroup - barPadding
105
107
  return width > 1 ? width : 1
106
108
  }
@@ -164,7 +166,7 @@ function renderTriangleBars ({ graphicGSelection, pathGClassName, pathClassName,
164
166
 
165
167
  // path
166
168
  gSelection.select(`path.${pathClassName}`)
167
- .attr('height', d => Math.abs(d.axisYFromZero))
169
+ .attr('height', d => Math.abs(d.axisYFromZero) || 1) // 無值還是給一個 1 的高度
168
170
  .attr('y', d => d.axisY < zeroYArr[seriesIndex] ? d.axisY : zeroYArr[seriesIndex])
169
171
  .attr('x', d => isSeriesSeprate ? 0 : barScale(d.seriesLabel)!)
170
172
  // .style('fill', d => `url(#${d.linearGradientId})`)
@@ -340,7 +340,7 @@ export const createBaseDots: BasePluginFn<BaseDotsContext> = (pluginName: string
340
340
  takeUntil(destroy$),
341
341
  switchMap(async (d) => d),
342
342
  ).subscribe(data => {
343
-
343
+
344
344
  data.graphicSelection
345
345
  .on('mouseover', (event, datum) => {
346
346
  // event.stopPropagation()
@@ -79,7 +79,7 @@ interface GroupLabelData {
79
79
  // const groupingLabelClassName = getClassName(pluginName, 'groupingLabel')
80
80
  const defaultTickSize = 6
81
81
 
82
- function createGroupLabelData (groupLabels: string[], tickFormat: string | ((text: any) => string)): GroupLabelData[] {
82
+ function createGroupLabelData (groupLabels: string[], tickFormat: string | ((text: any) => string | d3.NumberValue)): GroupLabelData[] {
83
83
  return groupLabels.map((_text, i) => {
84
84
  const text = parseTickFormatValue(_text, tickFormat)
85
85
  const textArr = typeof text === 'string' ? text.split('\n') : [text]
@@ -106,32 +106,32 @@ function renderAxisLabel ({ selection, groupingLabelClassName, fullParams, axisL
106
106
  const offsetY = fullParams.tickPadding + fullParams.labelOffset[1]
107
107
  let labelX = 0
108
108
  let labelY = 0
109
- if (fullDataFormatter.grid.groupAxis.position === 'bottom') {
109
+ if (fullDataFormatter.groupAxis.position === 'bottom') {
110
110
  labelY = offsetY
111
- if (fullDataFormatter.grid.valueAxis.position === 'left') {
111
+ if (fullDataFormatter.valueAxis.position === 'left') {
112
112
  labelX = offsetX
113
- } else if (fullDataFormatter.grid.valueAxis.position === 'right') {
113
+ } else if (fullDataFormatter.valueAxis.position === 'right') {
114
114
  labelX = - offsetX
115
115
  }
116
- } else if (fullDataFormatter.grid.groupAxis.position === 'top') {
116
+ } else if (fullDataFormatter.groupAxis.position === 'top') {
117
117
  labelY = - offsetY
118
- if (fullDataFormatter.grid.valueAxis.position === 'left') {
118
+ if (fullDataFormatter.valueAxis.position === 'left') {
119
119
  labelX = offsetX
120
- } else if (fullDataFormatter.grid.valueAxis.position === 'right') {
120
+ } else if (fullDataFormatter.valueAxis.position === 'right') {
121
121
  labelX = - offsetX
122
122
  }
123
- } else if (fullDataFormatter.grid.groupAxis.position === 'left') {
123
+ } else if (fullDataFormatter.groupAxis.position === 'left') {
124
124
  labelX = - offsetX
125
- if (fullDataFormatter.grid.valueAxis.position === 'bottom') {
125
+ if (fullDataFormatter.valueAxis.position === 'bottom') {
126
126
  labelY = - offsetY
127
- } else if (fullDataFormatter.grid.valueAxis.position === 'top') {
127
+ } else if (fullDataFormatter.valueAxis.position === 'top') {
128
128
  labelY = offsetY
129
129
  }
130
- } else if (fullDataFormatter.grid.groupAxis.position === 'right') {
130
+ } else if (fullDataFormatter.groupAxis.position === 'right') {
131
131
  labelX = offsetX
132
- if (fullDataFormatter.grid.valueAxis.position === 'bottom') {
132
+ if (fullDataFormatter.valueAxis.position === 'bottom') {
133
133
  labelY = - offsetY
134
- } else if (fullDataFormatter.grid.valueAxis.position === 'top') {
134
+ } else if (fullDataFormatter.valueAxis.position === 'top') {
135
135
  labelY = offsetY
136
136
  }
137
137
  }
@@ -162,7 +162,7 @@ function renderAxisLabel ({ selection, groupingLabelClassName, fullParams, axisL
162
162
  // 偏移使用 x, y 而非 transform 才不會受到外層 scale 變形影響
163
163
  .attr('x', labelX)
164
164
  .attr('y', labelY)
165
- .text(d => fullDataFormatter.grid.groupAxis.label)
165
+ .text(d => fullDataFormatter.groupAxis.label)
166
166
  })
167
167
  .attr('transform', d => `translate(${gridAxesSize.width}, 0)`)
168
168
  // .attr('transform', d => `translate(${gridAxesSize.width + d.tickPadding + fullParams.labelOffset[0]}, ${- d.tickPadding - fullParams.labelOffset[1]})`)
@@ -197,16 +197,16 @@ function renderAxis ({ selection, xAxisClassName, fullParams, tickTextAlign, gri
197
197
  // 刻度文字偏移
198
198
  let tickPadding = 0
199
199
  let textX = 0
200
- if (fullDataFormatter.grid.groupAxis.position === 'left') {
200
+ if (fullDataFormatter.groupAxis.position === 'left') {
201
201
  tickPadding = 0
202
202
  textX = - fullParams.tickPadding
203
- } else if (fullDataFormatter.grid.groupAxis.position === 'right') {
203
+ } else if (fullDataFormatter.groupAxis.position === 'right') {
204
204
  tickPadding = 0
205
205
  textX = fullParams.tickPadding
206
- } else if (fullDataFormatter.grid.groupAxis.position === 'bottom') {
206
+ } else if (fullDataFormatter.groupAxis.position === 'bottom') {
207
207
  tickPadding = fullParams.tickPadding
208
208
  textX = 0
209
- } else if (fullDataFormatter.grid.groupAxis.position === 'top') {
209
+ } else if (fullDataFormatter.groupAxis.position === 'top') {
210
210
  tickPadding = - fullParams.tickPadding
211
211
  textX = - 0
212
212
  }
@@ -248,7 +248,7 @@ function renderAxis ({ selection, xAxisClassName, fullParams, tickTextAlign, gri
248
248
  renderTspansOnAxis(d3.select(n[i]), {
249
249
  textArr,
250
250
  textSizePx,
251
- groupAxisPosition: fullDataFormatter.grid.groupAxis.position
251
+ groupAxisPosition: fullDataFormatter.groupAxis.position
252
252
  })
253
253
  })
254
254
  })
@@ -275,7 +275,7 @@ function renderAxis ({ selection, xAxisClassName, fullParams, tickTextAlign, gri
275
275
  .style('transform', textReverseTransformWithRotate)
276
276
 
277
277
  // 抵消掉預設的偏移
278
- // if (fullDataFormatter.grid.groupAxis.position === 'left' || fullDataFormatter.grid.groupAxis.position === 'right') {
278
+ // if (fullDataFormatter.groupAxis.position === 'left' || fullDataFormatter.groupAxis.position === 'right') {
279
279
  xText.attr('dy', 0)
280
280
  // }
281
281
 
@@ -386,7 +386,7 @@ export const createBaseGroupAxis: BasePluginFn<BaseGroupAxisContext> = ((pluginN
386
386
  // const tickTextFormatter$ = fullDataFormatter$
387
387
  // .pipe(
388
388
  // map(d => {
389
- // return d.grid.seriesDirection === 'row' ? d.grid.columnLabelFormat : d.grid.rowLabelFormat
389
+ // return d.seriesDirection === 'row' ? d.columnLabelFormat : d.rowLabelFormat
390
390
  // })
391
391
  // )
392
392
 
@@ -472,12 +472,12 @@ export const createBaseGroupAxis: BasePluginFn<BaseGroupAxisContext> = ((pluginN
472
472
  // ).subscribe(data => {
473
473
  // const groupMin = 0
474
474
  // const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
475
- // const groupScaleDomainMin = data.fullDataFormatter.grid.groupAxis.scaleDomain[0] === 'auto'
476
- // ? groupMin - data.fullDataFormatter.grid.groupAxis.scalePadding
477
- // : data.fullDataFormatter.grid.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.grid.groupAxis.scalePadding
478
- // const groupScaleDomainMax = data.fullDataFormatter.grid.groupAxis.scaleDomain[1] === 'auto'
479
- // ? groupMax + data.fullDataFormatter.grid.groupAxis.scalePadding
480
- // : data.fullDataFormatter.grid.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.grid.groupAxis.scalePadding
475
+ // const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] === 'auto'
476
+ // ? groupMin - data.fullDataFormatter.groupAxis.scalePadding
477
+ // : data.fullDataFormatter.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.groupAxis.scalePadding
478
+ // const groupScaleDomainMax = data.fullDataFormatter.groupAxis.scaleDomain[1] === 'auto'
479
+ // ? groupMax + data.fullDataFormatter.groupAxis.scalePadding
480
+ // : data.fullDataFormatter.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.groupAxis.scalePadding
481
481
 
482
482
  // const groupingLength = data.computedData[0]
483
483
  // ? data.computedData[0].length
@@ -496,7 +496,7 @@ export const createBaseGroupAxis: BasePluginFn<BaseGroupAxisContext> = ((pluginN
496
496
  // })
497
497
 
498
498
 
499
- // const padding = data.fullDataFormatter.grid.groupAxis.scalePadding
499
+ // const padding = data.fullDataFormatter.groupAxis.scalePadding
500
500
 
501
501
  // const groupScale = createLabelToAxisScale({
502
502
  // axisLabels,
@@ -518,13 +518,13 @@ export const createBaseGroupAxis: BasePluginFn<BaseGroupAxisContext> = ((pluginN
518
518
  map(data => {
519
519
  const groupMin = 0
520
520
  const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
521
- // const groupScaleDomainMin = data.fullDataFormatter.grid.groupAxis.scaleDomain[0] === 'auto'
522
- // ? groupMin - data.fullDataFormatter.grid.groupAxis.scalePadding
523
- // : data.fullDataFormatter.grid.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.grid.groupAxis.scalePadding
524
- const groupScaleDomainMin = data.fullDataFormatter.grid.groupAxis.scaleDomain[0] - data.fullDataFormatter.grid.groupAxis.scalePadding
525
- const groupScaleDomainMax = data.fullDataFormatter.grid.groupAxis.scaleDomain[1] === 'max'
526
- ? groupMax + data.fullDataFormatter.grid.groupAxis.scalePadding
527
- : data.fullDataFormatter.grid.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.grid.groupAxis.scalePadding
521
+ // const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] === 'auto'
522
+ // ? groupMin - data.fullDataFormatter.groupAxis.scalePadding
523
+ // : data.fullDataFormatter.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.groupAxis.scalePadding
524
+ const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] - data.fullDataFormatter.groupAxis.scalePadding
525
+ const groupScaleDomainMax = data.fullDataFormatter.groupAxis.scaleDomain[1] === 'max'
526
+ ? groupMax + data.fullDataFormatter.groupAxis.scalePadding
527
+ : data.fullDataFormatter.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.groupAxis.scalePadding
528
528
 
529
529
  return [groupScaleDomainMin, groupScaleDomainMax]
530
530
  }),
@@ -559,20 +559,20 @@ export const createBaseGroupAxis: BasePluginFn<BaseGroupAxisContext> = ((pluginN
559
559
  let textAnchor: 'start' | 'middle' | 'end' = 'middle'
560
560
  let dominantBaseline: 'auto' | 'middle' | 'hanging' = 'hanging'
561
561
 
562
- if (data.fullDataFormatter.grid.groupAxis.position === 'bottom') {
562
+ if (data.fullDataFormatter.groupAxis.position === 'bottom') {
563
563
  textAnchor = data.fullParams.tickTextRotate
564
564
  ? 'end'
565
565
  : 'middle'
566
566
  dominantBaseline = 'hanging'
567
- } else if (data.fullDataFormatter.grid.groupAxis.position === 'top') {
567
+ } else if (data.fullDataFormatter.groupAxis.position === 'top') {
568
568
  textAnchor = data.fullParams.tickTextRotate
569
569
  ? 'start'
570
570
  : 'middle'
571
571
  dominantBaseline = 'auto'
572
- } else if (data.fullDataFormatter.grid.groupAxis.position === 'left') {
572
+ } else if (data.fullDataFormatter.groupAxis.position === 'left') {
573
573
  textAnchor = 'end'
574
574
  dominantBaseline = 'middle'
575
- } else if (data.fullDataFormatter.grid.groupAxis.position === 'right') {
575
+ } else if (data.fullDataFormatter.groupAxis.position === 'right') {
576
576
  textAnchor = 'start'
577
577
  dominantBaseline = 'middle'
578
578
  }
@@ -589,22 +589,22 @@ export const createBaseGroupAxis: BasePluginFn<BaseGroupAxisContext> = ((pluginN
589
589
  let textAnchor: 'start' | 'middle' | 'end' = 'start'
590
590
  let dominantBaseline: 'auto' | 'middle' | 'hanging' = 'hanging'
591
591
 
592
- if (d.grid.groupAxis.position === 'bottom') {
592
+ if (d.groupAxis.position === 'bottom') {
593
593
  dominantBaseline = 'hanging'
594
- } else if (d.grid.groupAxis.position === 'top') {
594
+ } else if (d.groupAxis.position === 'top') {
595
595
  dominantBaseline = 'auto'
596
- } else if (d.grid.groupAxis.position === 'left') {
596
+ } else if (d.groupAxis.position === 'left') {
597
597
  textAnchor = 'end'
598
- } else if (d.grid.groupAxis.position === 'right') {
598
+ } else if (d.groupAxis.position === 'right') {
599
599
  textAnchor = 'start'
600
600
  }
601
- if (d.grid.valueAxis.position === 'left') {
601
+ if (d.valueAxis.position === 'left') {
602
602
  textAnchor = 'start'
603
- } else if (d.grid.valueAxis.position === 'right') {
603
+ } else if (d.valueAxis.position === 'right') {
604
604
  textAnchor = 'end'
605
- } else if (d.grid.valueAxis.position === 'bottom') {
605
+ } else if (d.valueAxis.position === 'bottom') {
606
606
  dominantBaseline = 'auto'
607
- } else if (d.grid.valueAxis.position === 'top') {
607
+ } else if (d.valueAxis.position === 'top') {
608
608
  dominantBaseline = 'hanging'
609
609
  }
610
610
  return {
@@ -98,10 +98,10 @@ const defaultListStyle: ListStyle = {
98
98
  }
99
99
 
100
100
  function getSeriesColor (seriesIndex: number, fullChartParams: ChartParams) {
101
- const colorIndex = seriesIndex < fullChartParams.colors[fullChartParams.colorScheme].series.length
101
+ const colorIndex = seriesIndex < fullChartParams.colors[fullChartParams.colorScheme].label.length
102
102
  ? seriesIndex
103
- : seriesIndex % fullChartParams.colors[fullChartParams.colorScheme].series.length
104
- return fullChartParams.colors[fullChartParams.colorScheme].series[colorIndex]
103
+ : seriesIndex % fullChartParams.colors[fullChartParams.colorScheme].label.length
104
+ return fullChartParams.colors[fullChartParams.colorScheme].label[colorIndex]
105
105
  }
106
106
 
107
107
 
@@ -668,7 +668,7 @@ export const createBaseLegend: BasePluginFn<BaseLegendContext> = (pluginName: st
668
668
  )
669
669
  .attr('x', data.textSizePx * 1.5)
670
670
  .attr('font-size', data.fullChartParams.styles.textSize)
671
- .attr('fill', d => data.fullParams.textColorType === 'series'
671
+ .attr('fill', d => data.fullParams.textColorType === 'label'
672
672
  ? getSeriesColor(d.seriesIndex, data.fullChartParams)
673
673
  : getColor(data.fullParams.textColorType, data.fullChartParams))
674
674
  .text(d => d.text)
@@ -23,7 +23,7 @@ import type {
23
23
  } from '../../lib/core-types'
24
24
  import type { BaseLineAreasParams } from '../../lib/plugins-basic-types'
25
25
  import { getD3TransitionEase } from '../utils/d3Utils'
26
- import { getClassName, getUniID, getMinAndMaxValue } from '../utils/orbchartsUtils'
26
+ import { getClassName, getUniID, getMinMaxValue } from '../utils/orbchartsUtils'
27
27
  import { gridGroupPositionFnObservable } from '../grid/gridObservables'
28
28
  import { gridSelectionsObservable } from '../grid/gridObservables'
29
29
 
@@ -20,19 +20,19 @@ import type {
20
20
  ContainerPositionScaled,
21
21
  Layout,
22
22
  TransformData } from '../../lib/core-types'
23
- import type { BaseBarStackParams } from '../../lib/plugins-basic-types'
23
+ import type { BaseStackedBarParams } from '../../lib/plugins-basic-types'
24
24
  import { getD3TransitionEase } from '../utils/d3Utils'
25
25
  import { getClassName, getUniID } from '../utils/orbchartsUtils'
26
26
  import { gridSelectionsObservable } from '../grid/gridObservables'
27
27
  import { shareReplay } from 'rxjs/operators'
28
28
 
29
- // export interface BaseBarStackParams {
29
+ // export interface BaseStackedBarParams {
30
30
  // barWidth: number
31
31
  // barGroupPadding: number
32
32
  // barRadius: number | boolean
33
33
  // }
34
34
 
35
- interface BaseBarStackContext {
35
+ interface BaseStackedBarContext {
36
36
  selection: d3.Selection<any, unknown, any, unknown>
37
37
  computedData$: Observable<ComputedDataGrid>
38
38
  computedLayoutData$: Observable<ComputedLayoutDataGrid>
@@ -41,7 +41,7 @@ interface BaseBarStackContext {
41
41
  seriesLabels$: Observable<string[]>
42
42
  SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
43
43
  GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
44
- fullParams$: Observable<BaseBarStackParams>
44
+ fullParams$: Observable<BaseStackedBarParams>
45
45
  fullDataFormatter$: Observable<DataFormatterGrid>
46
46
  fullChartParams$: Observable<ChartParams>
47
47
  gridAxesTransform$: Observable<TransformData>
@@ -70,7 +70,7 @@ interface RenderBarParams {
70
70
  zeroY: number
71
71
  groupLabels: string[]
72
72
  // barScale: d3.ScalePoint<string>
73
- params: BaseBarStackParams
73
+ params: BaseStackedBarParams
74
74
  chartParams: ChartParams
75
75
  barWidth: number
76
76
  transformedBarRadius: [number, number][]
@@ -87,7 +87,7 @@ type ClipPathDatum = {
87
87
  height: number;
88
88
  }
89
89
 
90
- // const pluginName = 'BarStack'
90
+ // const pluginName = 'StackedBar'
91
91
  // const rectClassName = getClassName(pluginName, 'rect')
92
92
  // group的delay在動畫中的佔比(剩餘部份的時間為圖形本身的動畫時間,因為delay時間和最後一個group的動畫時間加總為1)
93
93
  const groupDelayProportionOfDuration = 0.3
@@ -97,13 +97,15 @@ function calcBarWidth ({ axisWidth, groupAmount, barGroupPadding = 0 }: {
97
97
  groupAmount: number
98
98
  barGroupPadding: number
99
99
  }) {
100
- const eachGroupWidth = axisWidth / (groupAmount - 1)
100
+ const eachGroupWidth = groupAmount > 1 // 等於 1 時會算出 Infinity
101
+ ? axisWidth / (groupAmount - 1) // -1是因為要扣掉兩側的padding
102
+ : axisWidth
101
103
  const width = eachGroupWidth - barGroupPadding
102
104
  return width > 1 ? width : 1
103
105
 
104
106
  }
105
107
 
106
- // function makeBarScale (barWidth: number, seriesLabels: string[], params: BarStackParams) {
108
+ // function makeBarScale (barWidth: number, seriesLabels: string[], params: StackedBarParams) {
107
109
  // const barHalfWidth = barWidth! / 2
108
110
  // const barGroupWidth = barWidth * seriesLabels.length + params.barPadding! * seriesLabels.length
109
111
  // return d3.scalePoint()
@@ -143,7 +145,7 @@ function renderRectBars ({ graphicGSelection, rectClassName, barData, zeroY, gro
143
145
  .append('rect')
144
146
  .classed(rectClassName, true)
145
147
  .attr('cursor', 'pointer')
146
- .attr('height', d => 0)
148
+ .attr('height', d => 1)
147
149
  },
148
150
  update => update,
149
151
  exit => exit.remove()
@@ -160,7 +162,7 @@ function renderRectBars ({ graphicGSelection, rectClassName, barData, zeroY, gro
160
162
  .ease(getD3TransitionEase(chartParams.transitionEase))
161
163
  .delay((d, i) => d.groupIndex * delayGroup)
162
164
  .attr('y', d => d._barStartY)
163
- .attr('height', d => Math.abs(d._barHeight))
165
+ .attr('height', d => Math.abs(d._barHeight) || 1) // 無值還是給一個 1 的高度
164
166
  })
165
167
 
166
168
  // const barGroup = graphicGSelection
@@ -290,7 +292,7 @@ function highlight ({ selection, ids, fullChartParams }: {
290
292
  }
291
293
 
292
294
 
293
- export const createBaseBarStack: BasePluginFn<BaseBarStackContext> = (pluginName: string, {
295
+ export const createBaseStackedBar: BasePluginFn<BaseStackedBarContext> = (pluginName: string, {
294
296
  selection,
295
297
  computedData$,
296
298
  computedLayoutData$,
@@ -486,13 +488,13 @@ export const createBaseBarStack: BasePluginFn<BaseBarStackContext> = (pluginName
486
488
  map(data => {
487
489
  const groupMin = 0
488
490
  const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
489
- // const groupScaleDomainMin = data.dataFormatter.grid.groupAxis.scaleDomain[0] === 'auto'
490
- // ? groupMin // - data.dataFormatter.grid.groupAxis.scalePadding
491
- // : data.dataFormatter.grid.groupAxis.scaleDomain[0] as number // - data.dataFormatter.grid.groupAxis.scalePadding
492
- const groupScaleDomainMin = data.dataFormatter.grid.groupAxis.scaleDomain[0]
493
- const groupScaleDomainMax = data.dataFormatter.grid.groupAxis.scaleDomain[1] === 'max'
494
- ? groupMax // + data.dataFormatter.grid.groupAxis.scalePadding
495
- : data.dataFormatter.grid.groupAxis.scaleDomain[1] as number // + data.dataFormatter.grid.groupAxis.scalePadding
491
+ // const groupScaleDomainMin = data.dataFormatter.groupAxis.scaleDomain[0] === 'auto'
492
+ // ? groupMin // - data.dataFormatter.groupAxis.scalePadding
493
+ // : data.dataFormatter.groupAxis.scaleDomain[0] as number // - data.dataFormatter.groupAxis.scalePadding
494
+ const groupScaleDomainMin = data.dataFormatter.groupAxis.scaleDomain[0]
495
+ const groupScaleDomainMax = data.dataFormatter.groupAxis.scaleDomain[1] === 'max'
496
+ ? groupMax // + data.dataFormatter.groupAxis.scalePadding
497
+ : data.dataFormatter.groupAxis.scaleDomain[1] as number // + data.dataFormatter.groupAxis.scalePadding
496
498
 
497
499
  return [groupScaleDomainMin, groupScaleDomainMax]
498
500
  })
@@ -259,7 +259,7 @@ export const createBaseTooltip: BasePluginFn<BaseTooltipContext> = (pluginName:
259
259
  textSize: data.fullChartParams.styles.textSize,
260
260
  textSizePx: data.textSizePx,
261
261
  textColor: getColor(data.fullParams.textColorType, data.fullChartParams),
262
- seriesColors: data.fullChartParams.colors[data.fullChartParams.colorScheme].series
262
+ seriesColors: data.fullChartParams.colors[data.fullChartParams.colorScheme].label
263
263
  }
264
264
  })
265
265
  )