chartjs-chart-sankey 0.14.0 → 0.14.1

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.
@@ -1,148 +0,0 @@
1
- import {
2
- CartesianScaleTypeRegistry,
3
- Chart,
4
- ChartComponent,
5
- Color,
6
- DatasetController,
7
- Element,
8
- FontSpec,
9
- Scriptable,
10
- ScriptableContext,
11
- VisualElement,
12
- } from 'chart.js'
13
-
14
- type AnyObject = Record<string, unknown>
15
-
16
- declare module 'chart.js' {
17
- /* raw data element */
18
- interface SankeyDataPoint {
19
- from: string
20
- to: string
21
- flow: number
22
- }
23
-
24
- /* dataset configuration */
25
- interface SankeyControllerDatasetOptions {
26
- label: string
27
- data: Array<SankeyDataPoint>
28
- colorFrom: (data: ScriptableContext<'sankey'>) => string
29
- colorTo: (data: ScriptableContext<'sankey'>) => string
30
- colorMode: 'gradient' | 'from' | 'to'
31
- hoverColorFrom?: Scriptable<string, ScriptableContext<'sankey'>>
32
- hoverColorTo?: Scriptable<string, ScriptableContext<'sankey'>>
33
- /* Map<node.key, priority_value> */
34
- priority?: Record<string, number>
35
- column?: Record<string, number>
36
- /* Map<node.key, label> */
37
- labels?: Record<string, string>
38
-
39
- modeX?: 'edge' | 'even' /* defaults to 'edge' */
40
- size?: 'min' | 'max' /* defaults to 'max' */
41
- borderWidth?: number /* defaults to 1 */
42
- nodeWidth?: number /* defaults to 10 */
43
- nodePadding?: number /* defaults to 10 (pixels) */
44
- color?: string /* defaults to 'black' */
45
- borderColor?: string /* defaults to 'black' */
46
- font?: FontSpec /* defaults to chart.options.font */
47
- padding?: number /* defaults to font.lineHeight / 2 */
48
-
49
- parsing: { from: string; to: string; flow: string }
50
- }
51
-
52
- type FromToElement = {
53
- addY: number
54
- flow: number
55
- key: string
56
- node: SankeyNode
57
- index: number
58
- }
59
-
60
- type SankeyNode = {
61
- /* unique key of a node */
62
- key: string
63
- /* number of => in-connections */
64
- in: number
65
- /* number of out => connections */
66
- out: number
67
- /* node size, based on size option */
68
- size: number
69
- from: Array<FromToElement>
70
- to: Array<FromToElement>
71
- /* true if x is defined by SankeyControllerDatasetOptions.column map */
72
- column?: boolean
73
- /* priority extracted from the SankeyControllerDatasetOptions.priority map */
74
- priority?: number
75
- y?: number
76
- x?: number
77
- color?: Color
78
- /** internal */
79
- _visited?: number
80
- }
81
-
82
- interface SankeyParsedData {
83
- x: number
84
- y: number
85
- _custom: {
86
- from: SankeyNode
87
- to: SankeyNode
88
- x: number
89
- y: number
90
- height: number
91
- flow: number
92
- }
93
- }
94
-
95
- interface ChartTypeRegistry {
96
- sankey: {
97
- datasetOptions: SankeyControllerDatasetOptions
98
- defaultDataPoint: SankeyDataPoint
99
- parsedDataType: SankeyParsedData
100
- metaExtensions: AnyObject
101
- /* TODO: define sankey chart options */
102
- chartOptions: FlowOptions
103
- scales: keyof CartesianScaleTypeRegistry
104
- }
105
- }
106
- }
107
-
108
- export interface FlowProps {
109
- x: number
110
- y: number
111
- x2: number
112
- y2: number
113
- height: number
114
- width: number
115
- }
116
-
117
- export interface FlowOptions {
118
- alpha: number
119
- colorMode: 'gradient' | 'from' | 'to'
120
- colorFrom: 'string'
121
- colorTo: Color
122
- hoverColorFrom: Color
123
- hoverColorTo: Color
124
- }
125
-
126
- export interface FlowConfig {
127
- x: number
128
- y: number
129
- x2: number
130
- y2: number
131
- height: number
132
- options: FlowOptions
133
- }
134
-
135
- export type SankeyController = DatasetController
136
- export const SankeyController: ChartComponent & {
137
- prototype: SankeyController
138
- new (chart: Chart, datasetIndex: number): SankeyController
139
- }
140
-
141
- export interface Flow<T extends FlowConfig = FlowConfig, O extends FlowOptions = FlowOptions>
142
- extends Element<T, O>,
143
- VisualElement {}
144
-
145
- export const Flow: ChartComponent & {
146
- prototype: Flow
147
- new (cfg: FlowConfig): Flow
148
- }