@orbcharts/plugins-basic 3.0.0-beta.15 → 3.0.0-beta.17

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 (228) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-plugins-basic.es.js +11839 -10485
  3. package/dist/orbcharts-plugins-basic.umd.js +231 -171
  4. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBars.d.ts +3 -3
  5. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBarsTriangle.d.ts +3 -3
  6. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseDots.d.ts +3 -3
  7. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLineAreas.d.ts +3 -3
  8. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLines.d.ts +3 -3
  9. package/dist/src/base/BaseRacingBars.d.ts +23 -0
  10. package/dist/src/base/BaseRacingLabels.d.ts +20 -0
  11. package/dist/src/base/BaseRacingValueLabels.d.ts +20 -0
  12. package/dist/{orbcharts-plugins-basic/src/base/BaseStackedBar.d.ts → src/base/BaseStackedBars.d.ts} +7 -7
  13. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseValueAxis.d.ts +4 -7
  14. package/dist/src/base/BaseXAxis.d.ts +20 -0
  15. package/dist/src/base/BaseYAxis.d.ts +18 -0
  16. package/dist/{orbcharts-plugins-basic/src → src}/grid/defaults.d.ts +3 -3
  17. package/dist/{orbcharts-plugins-basic/src → src}/grid/gridObservables.d.ts +8 -1
  18. package/dist/{orbcharts-plugins-basic/src → src}/grid/index.d.ts +2 -2
  19. package/dist/src/grid/plugins/GroupZoom.d.ts +1 -0
  20. package/dist/src/grid/plugins/StackedBars.d.ts +1 -0
  21. package/dist/src/index.d.ts +7 -1
  22. package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/defaults.d.ts +2 -2
  23. package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/index.d.ts +1 -1
  24. package/dist/src/multiGrid/plugins/MultiStackedBars.d.ts +1 -0
  25. package/dist/src/multiValue/defaults.d.ts +13 -0
  26. package/dist/{orbcharts-plugins-basic/src → src}/multiValue/index.d.ts +5 -1
  27. package/dist/src/multiValue/multiValueObservables.d.ts +56 -0
  28. package/dist/src/multiValue/plugins/RacingBars.d.ts +1 -0
  29. package/dist/src/multiValue/plugins/RacingCounterTexts.d.ts +3 -0
  30. package/dist/src/multiValue/plugins/RacingValueAxis.d.ts +1 -0
  31. package/dist/src/multiValue/plugins/XAxis.d.ts +1 -0
  32. package/dist/src/multiValue/plugins/XYAxes.d.ts +1 -0
  33. package/dist/src/multiValue/plugins/XZoom.d.ts +1 -0
  34. package/dist/{orbcharts-plugins-basic/src → src}/utils/commonUtils.d.ts +1 -0
  35. package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Graphics.d.ts +2 -1
  36. package/lib/core-types.ts +7 -7
  37. package/lib/core.ts +6 -6
  38. package/lib/plugins-basic-types.ts +6 -6
  39. package/package.json +44 -44
  40. package/src/base/BaseBars.ts +765 -765
  41. package/src/base/BaseBarsTriangle.ts +676 -676
  42. package/src/base/BaseDots.ts +464 -464
  43. package/src/base/BaseGroupAxis.ts +691 -679
  44. package/src/base/BaseLegend.ts +684 -684
  45. package/src/base/BaseLineAreas.ts +629 -629
  46. package/src/base/BaseLines.ts +706 -706
  47. package/src/base/BaseRacingBars.ts +552 -0
  48. package/src/base/BaseRacingLabels.ts +396 -0
  49. package/src/base/BaseRacingValueLabels.ts +403 -0
  50. package/src/base/{BaseStackedBar.ts → BaseStackedBars.ts} +782 -782
  51. package/src/base/BaseTooltip.ts +386 -385
  52. package/src/base/BaseValueAxis.ts +600 -583
  53. package/src/base/BaseXAxis.ts +427 -0
  54. package/src/base/BaseYAxis.ts +389 -0
  55. package/src/base/types.ts +2 -2
  56. package/src/const.ts +30 -30
  57. package/src/grid/defaults.ts +213 -250
  58. package/src/grid/gridObservables.ts +612 -554
  59. package/src/grid/index.ts +16 -16
  60. package/src/grid/plugins/Bars.ts +69 -69
  61. package/src/grid/plugins/BarsPN.ts +66 -66
  62. package/src/grid/plugins/BarsTriangle.ts +73 -73
  63. package/src/grid/plugins/Dots.ts +68 -68
  64. package/src/grid/plugins/GridLegend.ts +107 -107
  65. package/src/grid/plugins/GridTooltip.ts +66 -66
  66. package/src/grid/plugins/GroupAux.ts +1120 -1103
  67. package/src/grid/plugins/GroupAxis.ts +73 -97
  68. package/src/grid/plugins/{GridZoom.ts → GroupZoom.ts} +218 -218
  69. package/src/grid/plugins/LineAreas.ts +65 -65
  70. package/src/grid/plugins/Lines.ts +59 -59
  71. package/src/grid/plugins/{StackedBar.ts → StackedBars.ts} +64 -64
  72. package/src/grid/plugins/StackedValueAxis.ts +96 -96
  73. package/src/grid/plugins/ValueAxis.ts +94 -94
  74. package/src/index.ts +6 -6
  75. package/src/multiGrid/defaults.ts +244 -228
  76. package/src/multiGrid/index.ts +14 -14
  77. package/src/multiGrid/multiGridObservables.ts +50 -49
  78. package/src/multiGrid/plugins/MultiBars.ts +108 -108
  79. package/src/multiGrid/plugins/MultiBarsTriangle.ts +114 -114
  80. package/src/multiGrid/plugins/MultiDots.ts +102 -102
  81. package/src/multiGrid/plugins/MultiGridLegend.ts +169 -159
  82. package/src/multiGrid/plugins/MultiGridTooltip.ts +66 -66
  83. package/src/multiGrid/plugins/MultiGroupAxis.ts +137 -137
  84. package/src/multiGrid/plugins/MultiLineAreas.ts +107 -107
  85. package/src/multiGrid/plugins/MultiLines.ts +101 -101
  86. package/src/multiGrid/plugins/{MultiStackedBar.ts → MultiStackedBars.ts} +106 -106
  87. package/src/multiGrid/plugins/MultiStackedValueAxis.ts +134 -134
  88. package/src/multiGrid/plugins/MultiValueAxis.ts +134 -134
  89. package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +300 -299
  90. package/src/multiGrid/plugins/OverlappingValueAxes.ts +300 -300
  91. package/src/multiValue/defaults.ts +388 -166
  92. package/src/multiValue/index.ts +13 -9
  93. package/src/multiValue/multiValueObservables.ts +667 -297
  94. package/src/multiValue/plugins/MultiValueLegend.ts +107 -107
  95. package/src/multiValue/plugins/MultiValueTooltip.ts +66 -66
  96. package/src/multiValue/plugins/OrdinalBubbles.ts +0 -0
  97. package/src/multiValue/plugins/OrdinalXAxis.ts +0 -0
  98. package/src/multiValue/plugins/RacingBars.ts +373 -0
  99. package/src/multiValue/plugins/RacingCounterAxis.ts +0 -0
  100. package/src/multiValue/plugins/RacingCounterTexts.ts +300 -0
  101. package/src/multiValue/plugins/RacingValueAxis.ts +115 -0
  102. package/src/multiValue/plugins/RankingAxis_legacy.ts +109 -0
  103. package/src/multiValue/plugins/Scatter.ts +426 -426
  104. package/src/multiValue/plugins/ScatterBubbles.ts +554 -554
  105. package/src/multiValue/plugins/XAxis.ts +108 -0
  106. package/src/multiValue/plugins/XYAux.ts +682 -681
  107. package/src/multiValue/plugins/XYAxes.ts +194 -684
  108. package/src/multiValue/plugins/XYAxes_legacy.ts +684 -0
  109. package/src/multiValue/plugins/{XYZoom.ts → XZoom.ts} +299 -299
  110. package/src/noneData/defaults.ts +102 -102
  111. package/src/noneData/index.ts +3 -3
  112. package/src/noneData/plugins/Container.ts +27 -27
  113. package/src/noneData/plugins/Tooltip.ts +373 -373
  114. package/src/relationship/defaults.ts +220 -218
  115. package/src/relationship/index.ts +5 -5
  116. package/src/relationship/plugins/ForceDirected.ts +1168 -1168
  117. package/src/relationship/plugins/ForceDirectedBubbles.ts +1403 -1403
  118. package/src/relationship/plugins/RelationshipLegend.ts +100 -100
  119. package/src/relationship/plugins/RelationshipTooltip.ts +66 -66
  120. package/src/relationship/relationshipObservables.ts +49 -49
  121. package/src/series/defaults.ts +221 -230
  122. package/src/series/index.ts +9 -9
  123. package/src/series/plugins/Bubbles.ts +636 -620
  124. package/src/series/plugins/Pie.ts +623 -623
  125. package/src/series/plugins/PieEventTexts.ts +284 -284
  126. package/src/series/plugins/PieLabels.ts +640 -640
  127. package/src/series/plugins/Rose.ts +516 -516
  128. package/src/series/plugins/RoseLabels.ts +600 -600
  129. package/src/series/plugins/SeriesLegend.ts +107 -107
  130. package/src/series/plugins/SeriesTooltip.ts +66 -66
  131. package/src/series/seriesObservables.ts +145 -145
  132. package/src/series/seriesUtils.ts +51 -51
  133. package/src/tree/defaults.ts +102 -100
  134. package/src/tree/index.ts +4 -4
  135. package/src/tree/plugins/TreeLegend.ts +100 -100
  136. package/src/tree/plugins/TreeMap.ts +341 -341
  137. package/src/tree/plugins/TreeTooltip.ts +66 -66
  138. package/src/utils/commonUtils.ts +31 -22
  139. package/src/utils/d3Graphics.ts +176 -174
  140. package/src/utils/d3Utils.ts +92 -92
  141. package/src/utils/observables.ts +14 -14
  142. package/src/utils/orbchartsUtils.ts +129 -129
  143. package/tsconfig.base.json +13 -13
  144. package/tsconfig.json +2 -2
  145. package/vite.config.js +22 -22
  146. package/dist/orbcharts-plugins-basic/src/grid/plugins/GridZoom.d.ts +0 -1
  147. package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +0 -1
  148. package/dist/orbcharts-plugins-basic/src/index.d.ts +0 -7
  149. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +0 -1
  150. package/dist/orbcharts-plugins-basic/src/multiValue/defaults.d.ts +0 -9
  151. package/dist/orbcharts-plugins-basic/src/multiValue/multiValueObservables.d.ts +0 -33
  152. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYZoom.d.ts +0 -1
  153. /package/dist/{orbcharts-plugins-basic/lib → lib}/core-types.d.ts +0 -0
  154. /package/dist/{orbcharts-plugins-basic/lib → lib}/core.d.ts +0 -0
  155. /package/dist/{orbcharts-plugins-basic/lib → lib}/plugins-basic-types.d.ts +0 -0
  156. /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseGroupAxis.d.ts +0 -0
  157. /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLegend.d.ts +0 -0
  158. /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseTooltip.d.ts +0 -0
  159. /package/dist/{orbcharts-plugins-basic/src → src}/base/types.d.ts +0 -0
  160. /package/dist/{orbcharts-plugins-basic/src → src}/const.d.ts +0 -0
  161. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Bars.d.ts +0 -0
  162. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsPN.d.ts +0 -0
  163. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsTriangle.d.ts +0 -0
  164. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Dots.d.ts +0 -0
  165. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridLegend.d.ts +0 -0
  166. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridTooltip.d.ts +0 -0
  167. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAux.d.ts +0 -0
  168. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAxis.d.ts +0 -0
  169. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/LineAreas.d.ts +0 -0
  170. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Lines.d.ts +0 -0
  171. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/StackedValueAxis.d.ts +0 -0
  172. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/ValueAxis.d.ts +0 -0
  173. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/multiGridObservables.d.ts +0 -0
  174. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBars.d.ts +0 -0
  175. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
  176. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiDots.d.ts +0 -0
  177. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
  178. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridTooltip.d.ts +0 -0
  179. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
  180. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
  181. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLines.d.ts +0 -0
  182. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiStackedValueAxis.d.ts +0 -0
  183. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
  184. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +0 -0
  185. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
  186. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueLegend.d.ts +0 -0
  187. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueTooltip.d.ts +0 -0
  188. /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/Ranking.d.ts → src/multiValue/plugins/OrdinalBubbles.d.ts} +0 -0
  189. /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/RankingAxis.d.ts → src/multiValue/plugins/OrdinalXAxis.d.ts} +0 -0
  190. /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Container.d.ts → src/multiValue/plugins/RacingCounterAxis.d.ts} +0 -0
  191. /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Tooltip.d.ts → src/multiValue/plugins/RankingAxis_legacy.d.ts} +0 -0
  192. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/Scatter.d.ts +0 -0
  193. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/ScatterBubbles.d.ts +0 -0
  194. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/XYAux.d.ts +0 -0
  195. /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/XYAxes.d.ts → src/multiValue/plugins/XYAxes_legacy.d.ts} +0 -0
  196. /package/dist/{orbcharts-plugins-basic/src → src}/noneData/defaults.d.ts +0 -0
  197. /package/dist/{orbcharts-plugins-basic/src → src}/noneData/index.d.ts +0 -0
  198. /package/dist/{orbcharts-plugins-basic/src/series/plugins/Waffle.d.ts → src/noneData/plugins/Container.d.ts} +0 -0
  199. /package/{src/multiValue/plugins/Ranking.ts → dist/src/noneData/plugins/Tooltip.d.ts} +0 -0
  200. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/defaults.d.ts +0 -0
  201. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/index.d.ts +0 -0
  202. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/ForceDirected.d.ts +0 -0
  203. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/ForceDirectedBubbles.d.ts +0 -0
  204. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipLegend.d.ts +0 -0
  205. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipTooltip.d.ts +0 -0
  206. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/relationshipObservables.d.ts +0 -0
  207. /package/dist/{orbcharts-plugins-basic/src → src}/series/defaults.d.ts +0 -0
  208. /package/dist/{orbcharts-plugins-basic/src → src}/series/index.d.ts +0 -0
  209. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Bubbles.d.ts +0 -0
  210. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Pie.d.ts +0 -0
  211. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieEventTexts.d.ts +0 -0
  212. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieLabels.d.ts +0 -0
  213. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Rose.d.ts +0 -0
  214. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/RoseLabels.d.ts +0 -0
  215. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesLegend.d.ts +0 -0
  216. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesTooltip.d.ts +0 -0
  217. /package/{src/multiValue/plugins/RankingAxis.ts → dist/src/series/plugins/Waffle.d.ts} +0 -0
  218. /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesObservables.d.ts +0 -0
  219. /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesUtils.d.ts +0 -0
  220. /package/dist/{orbcharts-plugins-basic/src → src}/tree/defaults.d.ts +0 -0
  221. /package/dist/{orbcharts-plugins-basic/src → src}/tree/index.d.ts +0 -0
  222. /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeLegend.d.ts +0 -0
  223. /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeMap.d.ts +0 -0
  224. /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeTooltip.d.ts +0 -0
  225. /package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Utils.d.ts +0 -0
  226. /package/dist/{orbcharts-plugins-basic/src → src}/utils/observables.d.ts +0 -0
  227. /package/dist/{orbcharts-plugins-basic/src → src}/utils/orbchartsUtils.d.ts +0 -0
  228. /package/dist/{orbcharts-plugins-basic/vite.config.d.ts → vite.config.d.ts} +0 -0
@@ -0,0 +1,389 @@
1
+ import * as d3 from 'd3'
2
+ import {
3
+ Observable,
4
+ Subject,
5
+ combineLatest,
6
+ takeUntil,
7
+ map,
8
+ distinctUntilChanged,
9
+ switchMap,
10
+ shareReplay
11
+ } from 'rxjs'
12
+ import type {
13
+ ColorType,
14
+ ChartParams,
15
+ ComputedDatumMultiValue,
16
+ ComputedDataMultiValue,
17
+ ComputedXYDatumMultiValue,
18
+ ContainerPositionScaled,
19
+ ContainerSize,
20
+ DataFormatterMultiValue,
21
+ DefinePluginConfig,
22
+ TransformData,
23
+ Layout
24
+ } from '../../lib/core-types'
25
+ import {
26
+ createValueToAxisScale,
27
+ } from '../../lib/core'
28
+ import type { BaseYAxisParams
29
+ } from '../../lib/plugins-basic-types'
30
+ import type { BasePluginFn } from './types'
31
+ // import { DEFAULT_X_Y_AXES_PARAMS } from '../defaults'
32
+ // import { LAYER_INDEX_OF_AXIS } from '../const'
33
+ import { getColor, getDatumColor, getClassName, getUniID } from '../utils/orbchartsUtils'
34
+ import { parseTickFormatValue } from '../utils/d3Utils'
35
+ import { multiValueContainerSelectionsObservable } from '../multiValue/multiValueObservables'
36
+
37
+ interface BaseYAxisContext {
38
+ selection: d3.Selection<any, unknown, any, unknown>
39
+ computedData$: Observable<ComputedDataMultiValue>
40
+ // filteredMinMaxValue$: Observable<[number, number]>
41
+ fullParams$: Observable<BaseYAxisParams>
42
+ fullDataFormatter$: Observable<DataFormatterMultiValue>
43
+ fullChartParams$: Observable<ChartParams>
44
+ isCategorySeprate$: Observable<boolean>
45
+ containerPosition$: Observable<ContainerPositionScaled[]>
46
+ containerSize$: Observable<ContainerSize>
47
+ // layout$: Observable<Layout>
48
+ // filteredXYMinMaxData$: Observable<{
49
+ // datumList: ComputedXYDatumMultiValue[];
50
+ // minXDatum: ComputedXYDatumMultiValue | null;
51
+ // maxXDatum: ComputedXYDatumMultiValue | null;
52
+ // minYDatum: ComputedXYDatumMultiValue | null;
53
+ // maxYDatum: ComputedXYDatumMultiValue | null;
54
+ // }>
55
+ yScale$: Observable<d3.ScaleLinear<number, number>>
56
+ // xyMinMax$: Observable<{
57
+ // minX: number;
58
+ // maxX: number;
59
+ // minY: number;
60
+ // maxY: number;
61
+ // }>
62
+ }
63
+
64
+ // interface TextAlign {
65
+ // textAnchor: "start" | "middle" | "end"
66
+ // dominantBaseline: "middle" | "auto" | "hanging"
67
+ // }
68
+
69
+ const defaultTickSize = 6
70
+
71
+ const yTickTextAnchor = 'end'
72
+ const yTickDominantBaseline = 'middle'
73
+ const yAxisLabelAnchor = 'end'
74
+ const yAxisLabelDominantBaseline = 'auto'
75
+
76
+ function renderYAxisLabel ({ selection, yLabelClassName, fullParams, containerSize, fullDataFormatter, fullChartParams }: {
77
+ selection: d3.Selection<SVGGElement, any, any, any>,
78
+ yLabelClassName: string
79
+ fullParams: BaseYAxisParams
80
+ // axisLabelAlign: TextAlign
81
+ containerSize: { width: number, height: number }
82
+ fullDataFormatter: DataFormatterMultiValue,
83
+ fullChartParams: ChartParams
84
+ // textReverseTransform: string,
85
+ }) {
86
+ const offsetX = fullParams.tickPadding - fullParams.labelOffset[0]
87
+ const offsetY = fullParams.tickPadding + fullParams.labelOffset[1]
88
+ let labelX = - offsetX
89
+ let labelY = - offsetY
90
+
91
+ const axisLabelSelection = selection
92
+ .selectAll<SVGGElement, BaseYAxisParams>(`g.${yLabelClassName}`)
93
+ .data([fullParams])
94
+ .join('g')
95
+ .classed(yLabelClassName, true)
96
+ .each((d, i, g) => {
97
+ const text = d3.select(g[i])
98
+ .selectAll<SVGTextElement, BaseYAxisParams>(`text`)
99
+ .data([d])
100
+ .join(
101
+ enter => {
102
+ return enter
103
+ .append('text')
104
+ .style('font-weight', 'bold')
105
+ },
106
+ update => update,
107
+ exit => exit.remove()
108
+ )
109
+ .attr('text-anchor', yAxisLabelAnchor)
110
+ .attr('dominant-baseline', yAxisLabelDominantBaseline)
111
+ .attr('font-size', fullChartParams.styles.textSize)
112
+ .style('fill', getColor(fullParams.labelColorType, fullChartParams))
113
+ // .style('transform', textReverseTransform)
114
+ // 偏移使用 x, y 而非 transform 才不會受到外層 scale 變形影響
115
+ .attr('x', labelX)
116
+ .attr('y', labelY)
117
+ .text(d => fullDataFormatter.yAxis.label)
118
+ })
119
+ // .attr('transform', d => `translate(0, ${layout.height})`)
120
+ }
121
+
122
+ function renderYAxis ({ selection, yAxisClassName, fullParams, containerSize, fullDataFormatter, fullChartParams, yScale }: {
123
+ selection: d3.Selection<SVGGElement, any, any, any>,
124
+ yAxisClassName: string
125
+ fullParams: BaseYAxisParams
126
+ // tickTextAlign: TextAlign
127
+ containerSize: ContainerSize
128
+ fullDataFormatter: DataFormatterMultiValue,
129
+ fullChartParams: ChartParams
130
+ yScale: d3.ScaleLinear<number, number>
131
+ // textReverseTransform: string,
132
+ // xyMinMax: {
133
+ // minX: number;
134
+ // maxX: number;
135
+ // minY: number;
136
+ // maxY: number;
137
+ // }
138
+ }) {
139
+
140
+ const yAxisSelection = selection
141
+ .selectAll<SVGGElement, BaseYAxisParams>(`g.${yAxisClassName}`)
142
+ .data([fullParams])
143
+ .join('g')
144
+ .classed(yAxisClassName, true)
145
+
146
+ // const _yScale = d3.scaleLinear()
147
+ // .domain([0, 150])
148
+ // .range([416.5, 791.349])
149
+
150
+ // 刻度文字偏移
151
+ let tickPadding = fullParams.tickPadding
152
+
153
+ // 設定Y軸刻度
154
+ const yAxis = d3.axisLeft(yScale)
155
+ .scale(yScale)
156
+ .ticks(fullParams.ticks) // 刻度分段數量
157
+ .tickFormat(d => parseTickFormatValue(d, fullParams.tickFormat))
158
+ .tickSize(fullParams.tickFullLine == true
159
+ ? -containerSize.width
160
+ : defaultTickSize)
161
+ .tickPadding(tickPadding)
162
+
163
+ const yAxisEl = yAxisSelection
164
+ .transition()
165
+ .duration(100)
166
+ .ease(d3.easeLinear) // 線性的 - 當托曳或快速變動的時候比較滑順
167
+ .call(yAxis)
168
+
169
+ yAxisEl.selectAll('line')
170
+ .style('fill', 'none')
171
+ .style('stroke', fullParams.tickLineVisible == true ? getColor(fullParams.tickColorType, fullChartParams) : 'none')
172
+ .style('stroke-dasharray', fullParams.tickFullLineDasharray)
173
+ .attr('pointer-events', 'none')
174
+
175
+ yAxisEl.selectAll('path')
176
+ .style('fill', 'none')
177
+ // .style('stroke', this.fullParams.axisLineColor!)
178
+ .style('stroke', fullParams.axisLineVisible == true ? getColor(fullParams.axisLineColorType, fullChartParams) : 'none')
179
+ .style('shape-rendering', 'crispEdges')
180
+
181
+ // const yText = yAxisEl.selectAll('text')
182
+ const yText = yAxisSelection.selectAll('text')
183
+ // .style('font-family', 'sans-serif')
184
+ .attr('font-size', fullChartParams.styles.textSize)
185
+ .style('color', getColor(fullParams.tickTextColorType, fullChartParams))
186
+ .attr('text-anchor', yTickTextAnchor)
187
+ .attr('dominant-baseline', yTickDominantBaseline)
188
+ // .attr('dy', 0)
189
+ .attr('x', - tickPadding)
190
+ .attr('dy', 0)
191
+ // yText.style('transform', textReverseTransform)
192
+
193
+ // // 抵消掉預設的偏移
194
+ // if (fullDataFormatter.grid.valueAxis.position === 'bottom' || fullDataFormatter.grid.valueAxis.position === 'top') {
195
+ // yText.attr('dy', 0)
196
+ // }
197
+
198
+ return yAxisSelection
199
+ }
200
+
201
+ export const createBaseYAxis: BasePluginFn<BaseYAxisContext> = (pluginName: string, {
202
+ selection,
203
+ computedData$,
204
+ fullParams$,
205
+ fullDataFormatter$,
206
+ fullChartParams$,
207
+ isCategorySeprate$,
208
+ containerPosition$,
209
+ containerSize$,
210
+ // layout$,
211
+ // filteredXYMinMaxData$,
212
+ yScale$,
213
+ // xyMinMax$
214
+ }) => {
215
+
216
+ const destroy$ = new Subject()
217
+
218
+ // const containerClassName = getClassName(pluginName, 'container')
219
+ const yAxisGClassName = getClassName(pluginName, 'yAxisG')
220
+ const yAxisClassName = getClassName(pluginName, 'yAxis')
221
+ const yLabelClassName = getClassName(pluginName, 'yLabel')
222
+
223
+ const containerSelection$ = multiValueContainerSelectionsObservable({
224
+ selection,
225
+ pluginName,
226
+ clipPathID: null,
227
+ computedData$,
228
+ containerPosition$,
229
+ isCategorySeprate$,
230
+ }).pipe(
231
+ takeUntil(destroy$),
232
+ )
233
+
234
+ // const containerSelection$ = combineLatest({
235
+ // computedData: computedData$.pipe(
236
+ // distinctUntilChanged((a, b) => {
237
+ // // 只有當series的數量改變時,才重新計算
238
+ // return a.length === b.length
239
+ // }),
240
+ // ),
241
+ // isCategorySeprate: isCategorySeprate$
242
+ // }).pipe(
243
+ // takeUntil(destroy$),
244
+ // switchMap(async (d) => d),
245
+ // map(data => {
246
+ // return data.isCategorySeprate
247
+ // // category分開的時候顯示各別axis
248
+ // ? data.computedData
249
+ // // category合併的時候只顯示第一個axis
250
+ // : [data.computedData[0]]
251
+ // }),
252
+ // map((computedData, i) => {
253
+ // return selection
254
+ // .selectAll<SVGGElement, ComputedDatumMultiValue[]>(`g.${containerClassName}`)
255
+ // .data(computedData, d => d[0] ? d[0].categoryIndex : i)
256
+ // .join('g')
257
+ // .classed(containerClassName, true)
258
+ // })
259
+ // )
260
+
261
+ const axisSelection$ = containerSelection$.pipe(
262
+ takeUntil(destroy$),
263
+ map((containerSelection, i) => {
264
+ return containerSelection
265
+ .selectAll<SVGGElement, ComputedDatumMultiValue[]>(`g.${yAxisGClassName}`)
266
+ .data([yAxisGClassName])
267
+ .join('g')
268
+ .classed(yAxisGClassName, true)
269
+ })
270
+ )
271
+
272
+ // combineLatest({
273
+ // containerSelection: containerSelection$,
274
+ // gridContainerPosition: containerPosition$
275
+ // }).pipe(
276
+ // takeUntil(destroy$),
277
+ // switchMap(async d => d)
278
+ // ).subscribe(data => {
279
+ // data.containerSelection
280
+ // .attr('transform', (d, i) => {
281
+ // const gridContainerPosition = data.gridContainerPosition[i] ?? data.gridContainerPosition[0]
282
+ // const translate = gridContainerPosition.translate
283
+ // const scale = gridContainerPosition.scale
284
+ // // return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
285
+ // return `translate(${translate[0]}, ${translate[1]})`
286
+ // })
287
+ // // .attr('opacity', 0)
288
+ // // .transition()
289
+ // // .attr('opacity', 1)
290
+ // })
291
+
292
+ // const textReverseTransform$ = containerPosition$.pipe(
293
+ // takeUntil(destroy$),
294
+ // switchMap(async (d) => d),
295
+ // map(containerPosition => {
296
+ // // const axesRotateXYReverseValue = `rotateX(${data.gridAxesReverseTransform.rotateX}deg) rotateY(${data.gridAxesReverseTransform.rotateY}deg)`
297
+ // // const axesRotateReverseValue = `rotate(${data.gridAxesReverseTransform.rotate}deg)`
298
+ // const containerScaleReverseValue = `scale(${1 / containerPosition[0].scale[0]}, ${1 / containerPosition[0].scale[1]})`
299
+ // // 抵消最外層scale
300
+ // return `${containerScaleReverseValue}`
301
+ // }),
302
+ // distinctUntilChanged()
303
+ // )
304
+
305
+ // const yScale$: Observable<d3.ScaleLinear<number, number>> = new Observable(subscriber => {
306
+ // combineLatest({
307
+ // fullDataFormatter: fullDataFormatter$,
308
+ // layout: layout$,
309
+ // // xyMinMax: observer.xyMinMax$
310
+ // filteredXYMinMaxData: filteredXYMinMaxData$
311
+ // }).pipe(
312
+ // takeUntil(destroy$),
313
+ // switchMap(async (d) => d),
314
+ // ).subscribe(data => {
315
+ // const valueIndex = data.fullDataFormatter.xAxis.valueIndex
316
+ // if (!data.filteredXYMinMaxData.minYDatum || !data.filteredXYMinMaxData.maxYDatum
317
+ // || data.filteredXYMinMaxData.minYDatum.value[valueIndex] == null || data.filteredXYMinMaxData.maxYDatum.value[valueIndex] == null
318
+ // ) {
319
+ // return
320
+ // }
321
+ // let maxValue = data.filteredXYMinMaxData.maxYDatum.value[valueIndex]
322
+ // let minValue = data.filteredXYMinMaxData.minYDatum.value[valueIndex]
323
+ // if (maxValue === minValue && maxValue === 0) {
324
+ // // 避免最大及最小值同等於 0 造成無法計算scale
325
+ // maxValue = 1
326
+ // }
327
+
328
+ // const yScale: d3.ScaleLinear<number, number> = createValueToAxisScale({
329
+ // maxValue,
330
+ // minValue,
331
+ // axisWidth: data.layout.height,
332
+ // scaleDomain: data.fullDataFormatter.yAxis.scaleDomain,
333
+ // scaleRange: data.fullDataFormatter.yAxis.scaleRange,
334
+ // reverse: true
335
+ // })
336
+
337
+ // subscriber.next(yScale)
338
+ // })
339
+ // })
340
+
341
+
342
+ combineLatest({
343
+ axisSelection: axisSelection$,
344
+ fullParams: fullParams$,
345
+ // tickTextAlign: tickTextAlign$,
346
+ // axisLabelAlign: axisLabelAlign$,
347
+ computedData: computedData$,
348
+ containerSize: containerSize$,
349
+ fullDataFormatter: fullDataFormatter$,
350
+ fullChartParams: fullChartParams$,
351
+ yScale: yScale$,
352
+ // textReverseTransform: textReverseTransform$,
353
+ // xyMinMax: xyMinMax$
354
+ }).pipe(
355
+ takeUntil(destroy$),
356
+ switchMap(async (d) => d),
357
+ ).subscribe(data => {
358
+
359
+ renderYAxis({
360
+ selection: data.axisSelection,
361
+ yAxisClassName,
362
+ fullParams: data.fullParams,
363
+ // tickTextAlign: data.tickTextAlign,
364
+ containerSize: data.containerSize,
365
+ fullDataFormatter: data.fullDataFormatter,
366
+ fullChartParams: data.fullChartParams,
367
+ yScale: data.yScale,
368
+ // textReverseTransform: data.textReverseTransform,
369
+ // xyMinMax: data.xyMinMax
370
+ })
371
+
372
+ renderYAxisLabel({
373
+ selection: data.axisSelection,
374
+ yLabelClassName,
375
+ fullParams: data.fullParams,
376
+ // axisLabelAlign: data.axisLabelAlign,
377
+ containerSize: data.containerSize,
378
+ fullDataFormatter: data.fullDataFormatter,
379
+ fullChartParams: data.fullChartParams,
380
+ // textReverseTransform: data.textReverseTransform,
381
+ })
382
+
383
+ })
384
+
385
+
386
+ return () => {
387
+ destroy$.next(undefined)
388
+ }
389
+ }
package/src/base/types.ts CHANGED
@@ -1,3 +1,3 @@
1
- export interface BasePluginFn<Context> {
2
- (pluginName: string, context: Context): () => void // return unsubscribe function
1
+ export interface BasePluginFn<Context> {
2
+ (pluginName: string, context: Context): () => void // return unsubscribe function
3
3
  }
package/src/const.ts CHANGED
@@ -1,30 +1,30 @@
1
-
2
- // 圖層索引 - 底層(無圖型)
3
- export const LAYER_INDEX_OF_ROOT = 0
4
-
5
- // 圖層索引 - 背景 *預留
6
- export const LAYER_INDEX_OF_BG = 1
7
-
8
- // 圖層索引 - 圖軸
9
- export const LAYER_INDEX_OF_AXIS = 2
10
-
11
- // 圖層索引 - 輔助線、圖軸的輔助資訊
12
- export const LAYER_INDEX_OF_AUX = 3
13
-
14
- // 圖層索引 - 底層圖型
15
- export const LAYER_INDEX_OF_GRAPHIC_GROUND = 4
16
-
17
- // 圖層索引 - 一般圖型
18
- export const LAYER_INDEX_OF_GRAPHIC = 5
19
-
20
- // 圖層索引 - 覆蓋圖型
21
- export const LAYER_INDEX_OF_GRAPHIC_COVER = 6
22
-
23
- // 圖層索引 - 圖型上的標籤文字
24
- export const LAYER_INDEX_OF_LABEL = 7
25
-
26
- // 圖層索引 - 圖例、圖表上的文字
27
- export const LAYER_INDEX_OF_INFO = 8
28
-
29
- // 圖層索引 - Tooltip、事件觸發的覆蓋圖型
30
- export const LAYER_INDEX_OF_TOOLTIP = 9
1
+
2
+ // 圖層索引 - 底層(無圖型)
3
+ export const LAYER_INDEX_OF_ROOT = 0
4
+
5
+ // 圖層索引 - 背景 *預留
6
+ export const LAYER_INDEX_OF_BG = 1
7
+
8
+ // 圖層索引 - 圖軸
9
+ export const LAYER_INDEX_OF_AXIS = 2
10
+
11
+ // 圖層索引 - 輔助線、圖軸的輔助資訊
12
+ export const LAYER_INDEX_OF_AUX = 3
13
+
14
+ // 圖層索引 - 底層圖型
15
+ export const LAYER_INDEX_OF_GRAPHIC_GROUND = 4
16
+
17
+ // 圖層索引 - 一般圖型
18
+ export const LAYER_INDEX_OF_GRAPHIC = 5
19
+
20
+ // 圖層索引 - 覆蓋圖型
21
+ export const LAYER_INDEX_OF_GRAPHIC_COVER = 6
22
+
23
+ // 圖層索引 - 圖型上的標籤文字
24
+ export const LAYER_INDEX_OF_LABEL = 7
25
+
26
+ // 圖層索引 - 圖例、圖表上的文字
27
+ export const LAYER_INDEX_OF_INFO = 8
28
+
29
+ // 圖層索引 - Tooltip、事件觸發的覆蓋圖型
30
+ export const LAYER_INDEX_OF_TOOLTIP = 9