@orbcharts/core 3.0.0-alpha.21

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 (166) hide show
  1. package/.gitignore +23 -0
  2. package/LICENSE +201 -0
  3. package/dist/orbcharts-core.es.js +5096 -0
  4. package/dist/orbcharts-core.umd.js +3 -0
  5. package/dist/src/AbstractChart.d.ts +17 -0
  6. package/dist/src/GridChart.d.ts +6 -0
  7. package/dist/src/MultiGridChart.d.ts +6 -0
  8. package/dist/src/MultiValueChart.d.ts +6 -0
  9. package/dist/src/RelationshipChart.d.ts +6 -0
  10. package/dist/src/SeriesChart.d.ts +6 -0
  11. package/dist/src/TreeChart.d.ts +6 -0
  12. package/dist/src/base/createBaseChart.d.ts +3 -0
  13. package/dist/src/base/createBasePlugin.d.ts +3 -0
  14. package/dist/src/defaults.d.ts +37 -0
  15. package/dist/src/defineGridPlugin.d.ts +1 -0
  16. package/dist/src/defineMultiGridPlugin.d.ts +1 -0
  17. package/dist/src/defineMultiValuePlugin.d.ts +1 -0
  18. package/dist/src/defineNoneDataPlugin.d.ts +1 -0
  19. package/dist/src/defineRelationshipPlugin.d.ts +1 -0
  20. package/dist/src/defineSeriesPlugin.d.ts +1 -0
  21. package/dist/src/defineTreePlugin.d.ts +1 -0
  22. package/dist/src/grid/computeGridData.d.ts +3 -0
  23. package/dist/src/grid/createGridContextObserver.d.ts +3 -0
  24. package/dist/src/grid/gridObservables.d.ts +25 -0
  25. package/dist/src/index.d.ts +15 -0
  26. package/dist/src/multiGrid/computeMultiGridData.d.ts +3 -0
  27. package/dist/src/multiGrid/createMultiGridContextObserver.d.ts +3 -0
  28. package/dist/src/multiGrid/multiGridObservables.d.ts +0 -0
  29. package/dist/src/multiValue/computeMultiValueData.d.ts +3 -0
  30. package/dist/src/multiValue/createMultiValueContextObserver.d.ts +3 -0
  31. package/dist/src/multiValue/multiValueObservables.d.ts +0 -0
  32. package/dist/src/relationship/computeRelationshipData.d.ts +3 -0
  33. package/dist/src/relationship/createRelationshipContextObserver.d.ts +3 -0
  34. package/dist/src/relationship/relationshipObservables.d.ts +0 -0
  35. package/dist/src/series/computeSeriesData.d.ts +3 -0
  36. package/dist/src/series/createSeriesContextObserver.d.ts +3 -0
  37. package/dist/src/series/seriesObservables.d.ts +8 -0
  38. package/dist/src/tree/computeTreeData.d.ts +3 -0
  39. package/dist/src/tree/createTreeContextObserver.d.ts +3 -0
  40. package/dist/src/tree/treeObservables.d.ts +0 -0
  41. package/dist/src/types/Axis.d.ts +1 -0
  42. package/dist/src/types/Chart.d.ts +41 -0
  43. package/dist/src/types/ChartParams.d.ts +36 -0
  44. package/dist/src/types/ComputedData.d.ts +28 -0
  45. package/dist/src/types/ComputedDataGrid.d.ts +10 -0
  46. package/dist/src/types/ComputedDataMultiGrid.d.ts +3 -0
  47. package/dist/src/types/ComputedDataMultiValue.d.ts +6 -0
  48. package/dist/src/types/ComputedDataRelationship.d.ts +18 -0
  49. package/dist/src/types/ComputedDataSeries.d.ts +6 -0
  50. package/dist/src/types/ComputedDataTree.d.ts +7 -0
  51. package/dist/src/types/ContextObserver.d.ts +28 -0
  52. package/dist/src/types/ContextObserverGrid.d.ts +18 -0
  53. package/dist/src/types/ContextObserverMultiGrid.d.ts +4 -0
  54. package/dist/src/types/ContextObserverMultiValue.d.ts +4 -0
  55. package/dist/src/types/ContextObserverRelationship.d.ts +4 -0
  56. package/dist/src/types/ContextObserverSeries.d.ts +8 -0
  57. package/dist/src/types/ContextObserverTree.d.ts +4 -0
  58. package/dist/src/types/ContextSubject.d.ts +15 -0
  59. package/dist/src/types/Data.d.ts +19 -0
  60. package/dist/src/types/DataFormatter.d.ts +40 -0
  61. package/dist/src/types/DataFormatterGrid.d.ts +20 -0
  62. package/dist/src/types/DataFormatterMultiGrid.d.ts +16 -0
  63. package/dist/src/types/DataFormatterMultiValue.d.ts +13 -0
  64. package/dist/src/types/DataFormatterRelationship.d.ts +5 -0
  65. package/dist/src/types/DataFormatterSeries.d.ts +10 -0
  66. package/dist/src/types/DataFormatterTree.d.ts +5 -0
  67. package/dist/src/types/DataGrid.d.ts +6 -0
  68. package/dist/src/types/DataMultiGrid.d.ts +6 -0
  69. package/dist/src/types/DataMultiValue.d.ts +6 -0
  70. package/dist/src/types/DataRelationship.d.ts +20 -0
  71. package/dist/src/types/DataSeries.d.ts +6 -0
  72. package/dist/src/types/DataTree.d.ts +13 -0
  73. package/dist/src/types/Event.d.ts +64 -0
  74. package/dist/src/types/Layout.d.ts +8 -0
  75. package/dist/src/types/Padding.d.ts +6 -0
  76. package/dist/src/types/Plugin.d.ts +37 -0
  77. package/dist/src/types/TransformData.d.ts +8 -0
  78. package/dist/src/types/index.d.ts +37 -0
  79. package/dist/src/utils/commonUtils.d.ts +8 -0
  80. package/dist/src/utils/d3Utils.d.ts +25 -0
  81. package/dist/src/utils/index.d.ts +4 -0
  82. package/dist/src/utils/observables.d.ts +14 -0
  83. package/dist/src/utils/orbchartsUtils.d.ts +20 -0
  84. package/dist/vite.config.d.ts +2 -0
  85. package/package.json +40 -0
  86. package/src/AbstractChart.ts +48 -0
  87. package/src/GridChart.ts +21 -0
  88. package/src/MultiGridChart.ts +21 -0
  89. package/src/MultiValueChart.ts +21 -0
  90. package/src/RelationshipChart.ts +21 -0
  91. package/src/SeriesChart.ts +21 -0
  92. package/src/TreeChart.ts +21 -0
  93. package/src/base/createBaseChart.ts +329 -0
  94. package/src/base/createBasePlugin.ts +89 -0
  95. package/src/defaults.ts +229 -0
  96. package/src/defineGridPlugin.ts +3 -0
  97. package/src/defineMultiGridPlugin.ts +3 -0
  98. package/src/defineMultiValuePlugin.ts +3 -0
  99. package/src/defineNoneDataPlugin.ts +4 -0
  100. package/src/defineRelationshipPlugin.ts +3 -0
  101. package/src/defineSeriesPlugin.ts +3 -0
  102. package/src/defineTreePlugin.ts +3 -0
  103. package/src/grid/computeGridData.ts +192 -0
  104. package/src/grid/createGridContextObserver.ts +91 -0
  105. package/src/grid/gridObservables.ts +359 -0
  106. package/src/index.ts +21 -0
  107. package/src/multiGrid/computeMultiGridData.ts +48 -0
  108. package/src/multiGrid/createMultiGridContextObserver.ts +12 -0
  109. package/src/multiGrid/multiGridObservables.ts +0 -0
  110. package/src/multiValue/computeMultiValueData.ts +127 -0
  111. package/src/multiValue/createMultiValueContextObserver.ts +12 -0
  112. package/src/multiValue/multiValueObservables.ts +0 -0
  113. package/src/relationship/computeRelationshipData.ts +101 -0
  114. package/src/relationship/createRelationshipContextObserver.ts +12 -0
  115. package/src/relationship/relationshipObservables.ts +0 -0
  116. package/src/series/computeSeriesData.ts +154 -0
  117. package/src/series/createSeriesContextObserver.ts +33 -0
  118. package/src/series/seriesObservables.ts +23 -0
  119. package/src/tree/computeTreeData.ts +104 -0
  120. package/src/tree/createTreeContextObserver.ts +12 -0
  121. package/src/tree/treeObservables.ts +0 -0
  122. package/src/types/Axis.ts +1 -0
  123. package/src/types/Chart.ts +46 -0
  124. package/src/types/ChartParams.ts +50 -0
  125. package/src/types/ComputedData.ts +66 -0
  126. package/src/types/ComputedDataGrid.ts +12 -0
  127. package/src/types/ComputedDataMultiGrid.ts +3 -0
  128. package/src/types/ComputedDataMultiValue.ts +10 -0
  129. package/src/types/ComputedDataRelationship.ts +20 -0
  130. package/src/types/ComputedDataSeries.ts +8 -0
  131. package/src/types/ComputedDataTree.ts +20 -0
  132. package/src/types/ContextObserver.ts +38 -0
  133. package/src/types/ContextObserverGrid.ts +16 -0
  134. package/src/types/ContextObserverMultiGrid.ts +5 -0
  135. package/src/types/ContextObserverMultiValue.ts +5 -0
  136. package/src/types/ContextObserverRelationship.ts +5 -0
  137. package/src/types/ContextObserverSeries.ts +8 -0
  138. package/src/types/ContextObserverTree.ts +5 -0
  139. package/src/types/ContextSubject.ts +18 -0
  140. package/src/types/Data.ts +45 -0
  141. package/src/types/DataFormatter.ts +99 -0
  142. package/src/types/DataFormatterGrid.ts +40 -0
  143. package/src/types/DataFormatterMultiGrid.ts +23 -0
  144. package/src/types/DataFormatterMultiValue.ts +19 -0
  145. package/src/types/DataFormatterRelationship.ts +23 -0
  146. package/src/types/DataFormatterSeries.ts +26 -0
  147. package/src/types/DataFormatterTree.ts +10 -0
  148. package/src/types/DataGrid.ts +11 -0
  149. package/src/types/DataMultiGrid.ts +7 -0
  150. package/src/types/DataMultiValue.ts +11 -0
  151. package/src/types/DataRelationship.ts +27 -0
  152. package/src/types/DataSeries.ts +11 -0
  153. package/src/types/DataTree.ts +18 -0
  154. package/src/types/Event.ts +114 -0
  155. package/src/types/Layout.ts +12 -0
  156. package/src/types/Padding.ts +6 -0
  157. package/src/types/Plugin.ts +60 -0
  158. package/src/types/TransformData.ts +8 -0
  159. package/src/types/index.ts +37 -0
  160. package/src/utils/commonUtils.ts +50 -0
  161. package/src/utils/d3Utils.ts +87 -0
  162. package/src/utils/index.ts +4 -0
  163. package/src/utils/observables.ts +198 -0
  164. package/src/utils/orbchartsUtils.ts +150 -0
  165. package/tsconfig.json +14 -0
  166. package/vite.config.js +45 -0
@@ -0,0 +1,8 @@
1
+ import { Observable } from 'rxjs'
2
+ import type { ContextObserverBase } from './ContextObserver'
3
+ import type { ComputedDatumSeries } from './ComputedDataSeries'
4
+
5
+ export interface ContextObserverSeries<PluginParams> extends ContextObserverBase<'series', PluginParams> {
6
+ seriesHighlight$: Observable<string[]>
7
+ SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
8
+ }
@@ -0,0 +1,5 @@
1
+ import type { ContextObserverBase } from './ContextObserver'
2
+
3
+ export interface ContextObserverTree<PluginParams> extends ContextObserverBase<'tree', PluginParams> {
4
+
5
+ }
@@ -0,0 +1,18 @@
1
+ import { Observable, Subject, BehaviorSubject } from 'rxjs'
2
+ import type { ChartType } from './Chart'
3
+ import type { EventTypeMap } from './Event'
4
+ import type { ChartParamsPartial } from './ChartParams'
5
+ // import type { Data } from './Data'
6
+ import type { DataFormatterPartialTypeMap } from './DataFormatter'
7
+ import type { DataTypeMap } from './Data'
8
+ import type { DataFormatterTypeMap } from './DataFormatter'
9
+ import type { PluginEntity } from './Plugin'
10
+
11
+ export interface ContextSubject<T extends ChartType> {
12
+ data$: Subject<DataTypeMap<T>>
13
+ dataFormatter$: Subject<DataFormatterPartialTypeMap<T>>
14
+ plugins$: Subject<PluginEntity<T, any, any>[]>
15
+ // pluginParams$: Subject<{[keys: string]: unknown}>
16
+ chartParams$: Subject<ChartParamsPartial>
17
+ event$: Subject<EventTypeMap<T>>
18
+ }
@@ -0,0 +1,45 @@
1
+ import { ChartType } from './Chart'
2
+ import { DataSeries, DataSeriesDatum, DataSeriesValue } from './DataSeries'
3
+ import { DataGrid, DataGridDatum, DataGridValue } from './DataGrid'
4
+ import { DataMultiGrid, DataMultiGridDatum, DataMultiGridValue } from './DataMultiGrid'
5
+ import { DataMultiValue, DataMultiValueDatum, DataMultiValueValue } from './DataMultiValue'
6
+ import { DataTree, DataTreeDatum, DataTreeObj } from './DataTree'
7
+ import { DataRelationship, Node, Edge } from './DataRelationship'
8
+
9
+ // 基本欄位(皆為可選,無填寫則在 formatXX 程式中產生預設值)
10
+ export interface DatumBase {
11
+ id?: string
12
+ label?: string
13
+ tooltipContent?: string
14
+ data?: any // 使用者注入的資料
15
+ }
16
+
17
+ // 需具備value的datum
18
+ export interface DatumValue {
19
+ value: number | null
20
+ }
21
+
22
+ // 透過類型選擇Data
23
+ export type DataTypeMap<T extends ChartType> = T extends 'series' ? DataSeries
24
+ : T extends 'grid' ? DataGrid
25
+ : T extends 'multiGrid' ? DataMultiGrid
26
+ : T extends 'multiValue' ? DataMultiValue
27
+ : T extends 'relationship' ? DataRelationship
28
+ : T extends 'tree' ? DataTree
29
+ : unknown
30
+
31
+ // 透過類型選擇Datum
32
+ export type DatumTypeMap<T extends ChartType> = T extends 'series' ? DataSeriesDatum | DataSeriesValue
33
+ : T extends 'grid' ? DataGridDatum | DataGridValue
34
+ : T extends 'multiGrid' ? DataMultiGridDatum | DataMultiGridValue
35
+ : T extends 'multiValue' ? DataMultiValueDatum | DataMultiValueValue
36
+ : T extends 'relationship' ? Node | Edge
37
+ : T extends 'tree' ? DataTreeDatum | DataTreeObj
38
+ : unknown
39
+
40
+ // export type Data = DataSeries
41
+ // | DataGrid
42
+ // | DataMultiGrid
43
+ // | DataMultiValue
44
+ // | DataTree
45
+ // | DataRelationship
@@ -0,0 +1,99 @@
1
+ import type { ChartType } from './Chart'
2
+ import type { ChartParams } from './ChartParams'
3
+ import type { DataTypeMap, DatumTypeMap } from './Data'
4
+ import type { DataFormatterSeries, DataFormatterSeriesPartial } from './DataFormatterSeries'
5
+ import type { DataFormatterGrid, DataFormatterGridPartial } from './DataFormatterGrid'
6
+ import type { DataFormatterMultiGrid, DataFormatterMultiGridPartial } from './DataFormatterMultiGrid'
7
+ import type { DataFormatterMultiValue, DataFormatterMultiValuePartial } from './DataFormatterMultiValue'
8
+ import type { DataFormatterTree, DataFormatterTreePartial } from './DataFormatterTree'
9
+ import type { DataFormatterRelationship, DataFormatterRelationshipPartial } from './DataFormatterRelationship'
10
+ import type { AxisPosition } from './Axis'
11
+ import type { Layout } from './Layout'
12
+
13
+ // export type DataFormatter = DataFormatterSeries
14
+ // | DataFormatterGrid
15
+ // | DataFormatterMultiGrid
16
+ // | DataFormatterMultiValue
17
+ // | DataFormatterTree
18
+ // | DataFormatterRelationship
19
+
20
+ // export type DataFormatterPartial = DataFormatterSeriesPartial
21
+ // | DataFormatterGridPartial
22
+ // | DataFormatterMultiGridPartial
23
+ // | DataFormatterMultiValuePartial
24
+ // | DataFormatterTreePartial
25
+ // | DataFormatterRelationshipPartial
26
+
27
+ // dataFormatter計算當中會使用的資料
28
+ export interface DataFormatterContext<T extends ChartType> {
29
+ data: DataTypeMap<T>
30
+ dataFormatter: DataFormatterTypeMap<T>
31
+ chartParams: ChartParams
32
+ layout: Layout
33
+ }
34
+
35
+
36
+ // 透過類型選擇DataFormatter
37
+ export type DataFormatterTypeMap<T extends ChartType> = T extends 'series' ? DataFormatterSeries
38
+ : T extends 'grid' ? DataFormatterGrid
39
+ : T extends 'multiGrid' ? DataFormatterMultiGrid
40
+ : T extends 'multiValue' ? DataFormatterMultiValue
41
+ : T extends 'relationship' ? DataFormatterRelationship
42
+ : T extends 'tree' ? DataFormatterTree
43
+ : DataFormatterBase<T>
44
+
45
+ // 透過類型選擇DataFormatter(可選欄位)
46
+ export type DataFormatterPartialTypeMap<T extends ChartType> = T extends 'series' ? DataFormatterSeriesPartial
47
+ : T extends 'grid' ? DataFormatterGridPartial
48
+ : T extends 'multiGrid' ? DataFormatterMultiGridPartial
49
+ : T extends 'multiValue' ? DataFormatterMultiValuePartial
50
+ : T extends 'relationship' ? DataFormatterRelationshipPartial
51
+ : T extends 'tree' ? DataFormatterTreePartial
52
+ : DataFormatterBasePartial<T>
53
+
54
+ // 基本介面
55
+ export interface DataFormatterBase<T extends ChartType> {
56
+ // colors: Colors
57
+ // padding: Padding
58
+ type: T
59
+ visibleFilter: VisibleFilter<T>
60
+ tooltipContentFormat: TooltipContentFormat<T>
61
+ }
62
+
63
+ export type DataFormatterBasePartial<T extends ChartType> = Partial<DataFormatterBase<T>>
64
+
65
+ // 有value
66
+ // export interface DataFormatterValue {
67
+ // valueFormat: ValueFormat
68
+ // }
69
+
70
+ // 有axis
71
+ // export interface DataFormatterAxis {
72
+ // // domainMinValue?: number
73
+ // // domainMaxValue?: number
74
+ // // domainMinRange?: number
75
+ // // domainMaxRange?: number
76
+ // valueDomain: [number | 'auto', number | 'auto']
77
+ // valueRange: [number, number] // 0-1
78
+ // }
79
+
80
+ export interface DataFormatterValueAxis {
81
+ position: AxisPosition
82
+ scaleDomain: [number | 'auto', number | 'auto']
83
+ scaleRange: [number, number]
84
+ label: string
85
+ }
86
+
87
+ export interface DataFormatterGroupAxis {
88
+ position: AxisPosition
89
+ scaleDomain: [number | 'auto', number | 'auto']
90
+ scalePadding: number
91
+ label: string
92
+ }
93
+
94
+
95
+ // export type ValueFormat = string | ((text: d3.NumberValue) => string)
96
+
97
+ export type VisibleFilter<T extends ChartType> = (datum: DatumTypeMap<T>, rowIndex: number, columnIndex: number, context: DataFormatterContext<T>) => boolean | null
98
+
99
+ export type TooltipContentFormat<T extends ChartType> = (datum: DatumTypeMap<T>, rowIndex: number, columnIndex: number, context: DataFormatterContext<T>) => string | null
@@ -0,0 +1,40 @@
1
+ import type { DataGridDatum, DataGridValue } from './DataGrid'
2
+ import type { DataFormatterBase, DataFormatterBasePartial, DataFormatterValueAxis, DataFormatterGroupAxis, DataFormatterContext } from './DataFormatter'
3
+ // import type { AxisPosition } from './Axis'
4
+
5
+ export type SeriesType = 'row' | 'column' // default: 'row'
6
+
7
+ export interface DataFormatterGrid
8
+ extends DataFormatterBase<'grid'> {
9
+ grid: DataFormatterGridGrid
10
+ valueAxis: DataFormatterValueAxis
11
+ groupAxis: DataFormatterGroupAxis
12
+ // visibleGroupRange: [number, number] | null
13
+ colorsPredicate: (datum: DataGridDatum | DataGridValue, rowIndex: number, columnIndex: number, context: DataFormatterContext<'grid'>) => string
14
+ }
15
+
16
+ export type DataFormatterGridPartial = Partial<DataFormatterGrid> | Partial<{
17
+ grid: Partial<DataFormatterGridGrid>
18
+ valueAxis: Partial<DataFormatterValueAxis>
19
+ groupAxis: Partial<DataFormatterGroupAxis>
20
+ }>
21
+
22
+ // grid欄位
23
+ export interface DataFormatterGridGrid {
24
+ // labelFormat: (datum: DataGridDatum) => string
25
+ // rowUnitLabel: string
26
+ rowLabels: string[]
27
+ // rowLabelFormat: string | ((text: any) => string)
28
+ // columnUnitLabel: string
29
+ columnLabels: string[]
30
+ // columnLabelFormat: string | ((text: any) => string)
31
+ seriesType: SeriesType
32
+ }
33
+
34
+ // const test: DataFormatterGridPartial = {
35
+ // type: 'grid',
36
+ // grid: {
37
+ // rowLabels: [],
38
+ // // a: ''
39
+ // }
40
+ // }
@@ -0,0 +1,23 @@
1
+ import { DataGridDatum, DataGridValue } from './DataGrid'
2
+ import { DataFormatterGridGrid } from './DataFormatterGrid'
3
+ import { DataFormatterBase, DataFormatterValueAxis, DataFormatterGroupAxis, DataFormatterContext } from './DataFormatter'
4
+ import { AxisPosition } from './Axis'
5
+
6
+ export interface DataFormatterMultiGrid
7
+ extends DataFormatterBase<'multiGrid'> {
8
+ multiGrid: Array<DataFormatterMultiGridMultiGrid>
9
+ // visibleGroupRange: [number, number] | null
10
+ }
11
+
12
+ export type DataFormatterMultiGridPartial = Partial<DataFormatterMultiGrid> | Partial<{
13
+ multiGrid: Array<Partial<DataFormatterMultiGridMultiGrid>>
14
+ }>
15
+
16
+ // multiGrid欄位
17
+ export interface DataFormatterMultiGridMultiGrid {
18
+ grid: DataFormatterGridGrid
19
+ valueAxis: DataFormatterValueAxis // default: 'left'
20
+ groupAxis: DataFormatterGroupAxis // default: 'bottom'
21
+ colorsPredicate: (datum: DataGridDatum | DataGridValue, rowIndex: number, columnIndex: number, context: DataFormatterContext<'grid'>) => string
22
+ // colors: Colors
23
+ }
@@ -0,0 +1,19 @@
1
+ import { DataMultiValueDatum, DataMultiValue } from './DataMultiValue'
2
+ import { DataFormatterBase, DataFormatterValueAxis } from './DataFormatter'
3
+
4
+ export interface DataFormatterMultiValue
5
+ extends DataFormatterBase<'multiValue'> {
6
+ // labelFormat: (datum: unknown) => string
7
+ multiValue: Array<DataFormatterMultiValueMultiValue>
8
+ xAxis: DataFormatterValueAxis
9
+ yAxis: DataFormatterValueAxis
10
+ }
11
+
12
+ export type DataFormatterMultiValuePartial = Partial<DataFormatterMultiValue> | Partial<{
13
+ multiValue: Array<Partial<DataFormatterMultiValueMultiValue>>
14
+ }>
15
+
16
+ // multiValue欄位
17
+ export interface DataFormatterMultiValueMultiValue {
18
+ unitLabel: string
19
+ }
@@ -0,0 +1,23 @@
1
+ import { Node, Edge, DataRelationship } from './DataRelationship'
2
+ import { DataFormatterBase } from './DataFormatter'
3
+
4
+ export interface DataFormatterRelationship
5
+ extends DataFormatterBase<'relationship'> {
6
+ // node: DataFormatterRelationshipNode
7
+ // edge: DataFormatterRelationshipEdge
8
+ }
9
+
10
+ export type DataFormatterRelationshipPartial = Partial<DataFormatterRelationship> | Partial<{
11
+ // node: Partial<DataFormatterRelationshipNode>
12
+ // edge: Partial<DataFormatterRelationshipEdge>
13
+ }>
14
+
15
+ // export interface DataFormatterRelationshipNode {
16
+ // labelFormat: (node: unknown) => string
17
+ // descriptionFormat: (node: unknown) => string
18
+ // }
19
+
20
+ // export interface DataFormatterRelationshipEdge {
21
+ // labelFormat: (edge: unknown, startNode: unknown, endNode: unknown) => string
22
+ // descriptionFormat: (edge: unknown, startNode: unknown, endNode: unknown) => string
23
+ // }
@@ -0,0 +1,26 @@
1
+ import { DataSeriesDatum, DataSeriesValue, DataSeries } from './DataSeries'
2
+ import { DataFormatterBase, DataFormatterContext } from './DataFormatter'
3
+ // import { ComputedDatumSeries } from './ComputedDataSeries'
4
+
5
+ export interface DataFormatterSeries
6
+ extends DataFormatterBase<'series'> {
7
+ // series: DataFormatterSeriesSeries
8
+ unitLabel: string
9
+ seriesLabels: string[]
10
+ // labelFormat: (datum: DataSeriesDatum) => string
11
+ // mapSeries: (datum: DataSeriesDatum | DataSeriesValue, rowIndex: number, columnIndex: number, context: DataFormatterContext<'series'>) => string
12
+ colorsPredicate: (datum: DataSeriesDatum | DataSeriesValue, rowIndex: number, columnIndex: number, context: DataFormatterContext<'series'>) => string
13
+ sort: ((a: DataSeriesDatum | DataSeriesValue, b: DataSeriesDatum | number) => number) | null
14
+ // colors: Colors
15
+ }
16
+
17
+ export type DataFormatterSeriesPartial = Partial<DataFormatterSeries> | Partial<{
18
+ // series: Partial<DataFormatterSeriesSeries>
19
+ }>
20
+
21
+ // export interface DataFormatterSeriesSeries {
22
+ // unitLabel: string
23
+ // seriesLabels: string[]
24
+ // // labelFormat: (datum: DataSeriesDatum) => string
25
+ // sort: ((computedDatum: ComputedDatumSeries) => number) | null
26
+ // }
@@ -0,0 +1,10 @@
1
+ import { DataTreeDatum, DataTree } from './DataTree'
2
+ import { DataFormatterBase } from './DataFormatter'
3
+
4
+ export interface DataFormatterTree
5
+ extends DataFormatterBase<'tree'> {
6
+ // labelFormat: (datum: unknown) => string
7
+ // descriptionFormat: (datum: unknown) => string
8
+ }
9
+
10
+ export type DataFormatterTreePartial = Partial<DataFormatterTree>
@@ -0,0 +1,11 @@
1
+ import type { DatumBase, DatumValue } from './Data'
2
+
3
+ // export type DataGrid = DataGridDatum[][] | DataGridValue[][]
4
+ export type DataGrid = (DataGridDatum | DataGridValue)[][]
5
+
6
+ export type DataGridValue = number | null
7
+
8
+ export interface DataGridDatum extends DatumBase, DatumValue {
9
+ }
10
+
11
+
@@ -0,0 +1,7 @@
1
+ import type { DataGrid, DataGridDatum, DataGridValue } from './DataGrid'
2
+
3
+ export type DataMultiGrid = DataGrid[]
4
+
5
+ export interface DataMultiGridDatum extends DataGridDatum {}
6
+
7
+ export type DataMultiGridValue = DataGridValue
@@ -0,0 +1,11 @@
1
+ import type { DatumBase, DatumValue } from './Data'
2
+
3
+ // export type DataMultiValue = DataMultiValueDatum[][] | DataMultiValueValue[][]
4
+ export type DataMultiValue = (DataMultiValueDatum | DataMultiValueValue)[][]
5
+
6
+ export type DataMultiValueValue = number
7
+
8
+ export interface DataMultiValueDatum extends DatumBase, DatumValue {
9
+ }
10
+
11
+
@@ -0,0 +1,27 @@
1
+ import type { DatumBase } from './Data'
2
+
3
+ export type DataRelationship = DataRelationshipObj | DataRelationshipList
4
+
5
+ // 物件資料
6
+ export interface DataRelationshipObj {
7
+ nodes: Node[]
8
+ edges: Edge[]
9
+ }
10
+
11
+ // 陣列資料
12
+ export type DataRelationshipList = [
13
+ Node[],
14
+ Edge[]
15
+ ]
16
+
17
+
18
+ export interface Node extends DatumBase {
19
+ id: string
20
+ value?: number
21
+ }
22
+
23
+ export interface Edge extends DatumBase {
24
+ start: string
25
+ end: string
26
+ value?: number
27
+ }
@@ -0,0 +1,11 @@
1
+ import type { DatumBase, DatumValue } from './Data'
2
+
3
+ // export type DataSeries = DataSeriesDatum[][] | DataSeriesDatum[] | DataSeriesValue[][] | DataSeriesValue[]
4
+ export type DataSeries = (DataSeriesDatum | DataSeriesValue)[][] | (DataSeriesDatum | DataSeriesValue)[]
5
+
6
+ export type DataSeriesValue = number | null
7
+
8
+ export interface DataSeriesDatum extends DatumBase, DatumValue {
9
+ }
10
+
11
+
@@ -0,0 +1,18 @@
1
+ import type { DatumBase } from './Data'
2
+
3
+ export type DataTree = DataTreeObj | DataTreeDatum[]
4
+
5
+ // 樹狀結構
6
+ export interface DataTreeObj extends DatumBase {
7
+ id: string
8
+ value?: number
9
+ children?: DataTreeObj[]
10
+ }
11
+
12
+ // 陣列資料
13
+ export interface DataTreeDatum extends DatumBase {
14
+ id: string
15
+ value?: number
16
+ parent?: string
17
+ }
18
+
@@ -0,0 +1,114 @@
1
+ import * as d3 from 'd3'
2
+ import type { ChartType } from './Chart'
3
+ import type { ComputedDatumBase } from './ComputedData'
4
+ import type { ComputedDataSeries, ComputedDatumSeries } from './ComputedDataSeries'
5
+ import type { ComputedDataGrid, ComputedDatumGrid } from './ComputedDataGrid'
6
+ import type { ComputedDataMultiGrid } from './ComputedDataMultiGrid'
7
+ import type { ComputedDataMultiValue, ComputedDatumMultiValue } from './ComputedDataMultiValue'
8
+ import type { ComputedNode } from './ComputedDataRelationship'
9
+ import type { ComputedDataTree } from './ComputedDataTree'
10
+ import type { HighlightTarget } from './ChartParams'
11
+
12
+ export type EventName = 'click'
13
+ | 'mouseover'
14
+ | 'mousemove'
15
+ | 'mouseout'
16
+ | 'dragstart'
17
+ | 'drag'
18
+ | 'dragend'
19
+ | 'resize'
20
+ | 'transitionMove'
21
+ | 'transitionEnd'
22
+ // | 'enterDuration'
23
+
24
+ // export interface Event<EventData = unknown> {
25
+ // eventName: EventName
26
+ // data: EventData
27
+ // }
28
+
29
+ // export interface ShareEvent<EventData = unknown> extends Event<EventData> {
30
+ // pluginName: string
31
+ // }
32
+
33
+ // export interface EventData {
34
+
35
+ // }
36
+
37
+ // 透過類型選擇Event
38
+ export type EventTypeMap<T extends ChartType> = T extends 'series' ? EventSeries
39
+ : T extends 'grid' ? EventGrid
40
+ : T extends 'multiGrid' ? EventMultiGrid
41
+ : T extends 'multiValue' ? EventMultiValue
42
+ : T extends 'relationship' ? EventRelationship
43
+ : T extends 'tree' ? EventTree
44
+ : EventBase
45
+
46
+ export interface EventBase {
47
+ eventName: EventName
48
+ pluginName: string
49
+ // data: EventData
50
+ type: ChartType
51
+ event: MouseEvent | undefined
52
+ highlightTarget: HighlightTarget
53
+ datum: ComputedDatumBase | null
54
+ tween?: number
55
+ }
56
+
57
+ export interface EventSeries extends EventBase {
58
+ type: 'series'
59
+ data: ComputedDataSeries
60
+ series: ComputedDatumSeries[]
61
+ seriesIndex: number
62
+ seriesLabel: string
63
+ datum: ComputedDatumSeries | null
64
+ // highlightTarget: 'series' | 'datum' | 'none'
65
+ // highlightLabel: string | null
66
+ // highlightId: string | null
67
+ }
68
+
69
+ export interface EventGrid extends EventBase {
70
+ type: 'grid'
71
+ data: ComputedDataGrid
72
+ series: ComputedDatumGrid[]
73
+ seriesIndex: number
74
+ seriesLabel: string
75
+ groups: ComputedDatumGrid[]
76
+ groupIndex: number
77
+ groupLabel: string
78
+ datum: ComputedDatumGrid | null
79
+ // highlightTarget: 'series' | 'group' | 'datum' | 'none'
80
+ // highlightLabel: string | null
81
+ // highlightId: string | null
82
+ }
83
+
84
+ export interface EventMultiGrid extends EventBase {
85
+ type: 'multiGrid'
86
+ data: ComputedDataMultiGrid
87
+ gridIndex: number
88
+ series: ComputedDatumGrid[]
89
+ seriesIndex: number
90
+ seriesLabel: string
91
+ group: ComputedDatumGrid[]
92
+ groupIndex: number
93
+ groupLabel: string
94
+ datum: ComputedDatumGrid | null
95
+ // highlightTarget: 'series' | 'group' | 'datum' | 'none'
96
+ // highlightLabel: string | null
97
+ // highlightId: string | null
98
+ }
99
+
100
+ export interface EventMultiValue extends EventBase {
101
+ type: 'multiValue'
102
+ datum: ComputedDatumMultiValue | null
103
+ }
104
+
105
+ export interface EventRelationship extends EventBase {
106
+ type: 'relationship'
107
+ datum: ComputedNode | null
108
+ }
109
+
110
+ export interface EventTree extends EventBase {
111
+ type: 'tree'
112
+ datum: ComputedDataTree | null
113
+ }
114
+
@@ -0,0 +1,12 @@
1
+ import type { Padding } from './Padding'
2
+
3
+ export interface Layout extends Padding {
4
+ width: number
5
+ height: number
6
+ // top: number
7
+ // right: number
8
+ // bottom: number
9
+ // left: number
10
+ rootWidth: number
11
+ rootHeight: number
12
+ }
@@ -0,0 +1,6 @@
1
+ export interface Padding {
2
+ top: number
3
+ right: number
4
+ bottom: number
5
+ left: number
6
+ }
@@ -0,0 +1,60 @@
1
+ import * as d3 from 'd3'
2
+ import { Subject } from 'rxjs'
3
+ import type { ChartType } from './Chart'
4
+ import type { ContextSubject } from './ContextSubject'
5
+ import type { ContextObserverTypeMap } from './ContextObserver'
6
+
7
+ // // 透過類型選擇Plugin
8
+ // export type PluginParamsMap<T extends ChartType, PluginParams> = T extends 'series' ? Plugin<DataSeries, DataFormatterSeries, ComputedDataSeries, PluginParams>
9
+ // : T extends 'grid' ? Plugin<DataGrid, DataFormatterGrid, ComputedDataGrid, PluginParams>
10
+ // : T extends 'multiGrid' ? Plugin<DataMultiGrid, DataFormatterMultiGrid, ComputedDataMultiGrid, PluginParams>
11
+ // : T extends 'multiValue' ? Plugin<DataMultiValue, DataFormatterMultiValue, ComputedDataMultiValue, PluginParams>
12
+ // : T extends 'relationship' ? Plugin<DataRelationship, DataFormatterRelationship, ComputedDataRelationship, PluginParams>
13
+ // : T extends 'tree' ? Plugin<DataTree, DataFormatterTree, ComputedDataTree, PluginParams>
14
+ // : Plugin<unknown, unknown, unknown, unknown>
15
+
16
+ export interface CreateBasePlugin {
17
+ <T extends ChartType>(): DefinePlugin<T>
18
+ }
19
+
20
+ export interface DefinePlugin<T extends ChartType> {
21
+ <PluginName, PluginParams>(name: PluginName , defaultParams: PluginParams): DefinePluginInitFn<T, PluginName, PluginParams>
22
+ }
23
+
24
+ export interface DefinePluginInitFn<T extends ChartType, PluginName, PluginParams> {
25
+ (initFn: PluginInitFn<T, PluginName, PluginParams>): PluginConstructor<T, PluginName, PluginParams>
26
+ }
27
+
28
+ // export interface CreatePlugin<T extends ChartType, PluginName, PluginParams> {
29
+ // (): PluginEntity<T, PluginName, PluginParams>
30
+ // }
31
+
32
+ export interface PluginConstructor<T extends ChartType, PluginName, PluginParams> {
33
+ new (): PluginEntity<T, PluginName, PluginParams>
34
+ }
35
+
36
+ export interface PluginEntity<T extends ChartType, PluginName, PluginParams> {
37
+ params$: Subject<Partial<PluginParams>>
38
+ name: PluginName
39
+ defaultParams: PluginParams
40
+ // presetParams: Partial<PluginParams>
41
+ init: () => void
42
+ destroy: () => void
43
+ setPresetParams: (presetParams: Partial<PluginParams>) => void
44
+ setContext: (pluginContext: PluginContext<T, PluginName, PluginParams>) => void
45
+ }
46
+
47
+ export interface PluginInitFn<T extends ChartType, PluginName, PluginParams> {
48
+ (pluginContext: PluginContext<T, PluginName, PluginParams>): () => void
49
+ }
50
+
51
+ export interface PluginContext<T extends ChartType, PluginName, PluginParams> {
52
+ selection: d3.Selection<any, unknown, any, unknown>
53
+ rootSelection: d3.Selection<any, unknown, any, unknown>
54
+ name: PluginName
55
+ chartType: ChartType, // 這邊的ChartType是由 createChart 時依 chart類別決定的,所以不能使用 pluginContext 本身的類別 T
56
+ // 原本的store
57
+ // selection: d3.Selection<SVGGElement, unknown, HTMLElement, unknown>
58
+ subject: ContextSubject<T>
59
+ observer: ContextObserverTypeMap<T, PluginParams>
60
+ }
@@ -0,0 +1,8 @@
1
+ export interface TransformData {
2
+ translate: [number, number]
3
+ scale: [number, number]
4
+ rotate: number
5
+ rotateX: number
6
+ rotateY: number
7
+ value: string
8
+ }
@@ -0,0 +1,37 @@
1
+ export * from './Axis'
2
+ export * from './Chart'
3
+ export * from './ChartParams'
4
+ export * from './ComputedData'
5
+ export * from './ComputedDataGrid'
6
+ export * from './ComputedDataMultiGrid'
7
+ export * from './ComputedDataMultiValue'
8
+ export * from './ComputedDataRelationship'
9
+ export * from './ComputedDataSeries'
10
+ export * from './ComputedDataTree'
11
+ export * from './ContextObserver'
12
+ export * from './ContextObserverGrid'
13
+ export * from './ContextObserverMultiGrid'
14
+ export * from './ContextObserverMultiValue'
15
+ export * from './ContextObserverRelationship'
16
+ export * from './ContextObserverSeries'
17
+ export * from './ContextObserverTree'
18
+ export * from './ContextSubject'
19
+ export * from './Data'
20
+ export * from './DataFormatter'
21
+ export * from './DataFormatterGrid'
22
+ export * from './DataFormatterMultiGrid'
23
+ export * from './DataFormatterMultiValue'
24
+ export * from './DataFormatterRelationship'
25
+ export * from './DataFormatterSeries'
26
+ export * from './DataFormatterTree'
27
+ export * from './DataGrid'
28
+ export * from './DataMultiGrid'
29
+ export * from './DataMultiValue'
30
+ export * from './DataRelationship'
31
+ export * from './DataSeries'
32
+ export * from './DataTree'
33
+ export * from './Event'
34
+ export * from './Layout'
35
+ export * from './Padding'
36
+ export * from './Plugin'
37
+ export * from './TransformData'