chartjs-chart-sankey 0.13.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,126 +0,0 @@
1
- import {
2
- Chart,
3
- ChartComponent,
4
- CartesianScaleTypeRegistry,
5
- DatasetController,
6
- Element,
7
- FontSpec,
8
- Scriptable,
9
- ScriptableContext,
10
- VisualElement
11
- } from 'chart.js';
12
-
13
- type AnyObject = Record<string, unknown>;
14
-
15
- declare module 'chart.js' {
16
-
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
- size?: 'min' | 'max' /* defaults to max */
40
- borderWidth?: number /* defaults to 1 */
41
- nodeWidth?: number /* defaults to 10 */
42
- color?: string /* defaults to 'black' */
43
- borderColor?: string /* defaults to 'black' */
44
- font?: FontSpec /* defaults to chart.options.font */
45
- padding?: number /* defaults to font.lineHeight / 2 */
46
- }
47
-
48
- type FromToElement = {
49
- addY: number
50
- flow: number
51
- key: string
52
- node: SankeyNode
53
- }
54
-
55
- type SankeyNode = {
56
- /* unique key of a node */
57
- key: string
58
- /* number of => in-connections */
59
- in: number
60
- /* number of out => connections */
61
- out: number
62
- from: Array<FromToElement>
63
- to: Array<FromToElement>
64
- /* true if x is defined by SankeyControllerDatasetOptions.column map */
65
- column?: boolean
66
- /* priority extracted from the SankeyControllerDatasetOptions.priority map */
67
- priority?: number
68
- y?: number
69
- x?: number
70
- }
71
-
72
- interface SankeyParsedData {
73
- x: number
74
- y: number
75
- _custom: {
76
- from: SankeyNode,
77
- to: SankeyNode
78
- x: number
79
- y: number
80
- height: number,
81
- }
82
- }
83
-
84
- interface ChartTypeRegistry {
85
- sankey: {
86
- datasetOptions: SankeyControllerDatasetOptions;
87
- defaultDataPoint: SankeyDataPoint;
88
- parsedDataType: SankeyParsedData;
89
- metaExtensions: AnyObject
90
- /* TODO: define sankey chart options */
91
- chartOptions: AnyObject;
92
- scales: keyof CartesianScaleTypeRegistry;
93
- };
94
- }
95
- }
96
-
97
- export interface FlowOptions {
98
- colorMode: 'gradient' | 'from' | 'to';
99
- colorFrom: string
100
- colorTo: string
101
- }
102
-
103
- export interface FlowConfig {
104
- x: number;
105
- y: number;
106
- x2: number;
107
- y2: number;
108
- height: number;
109
- options: FlowOptions
110
- }
111
-
112
- export type SankeyController = DatasetController
113
- export const SankeyController: ChartComponent & {
114
- prototype: SankeyController;
115
- new(chart: Chart, datasetIndex: number): SankeyController;
116
- };
117
-
118
- export interface Flow<
119
- T extends FlowConfig = FlowConfig,
120
- O extends FlowOptions = FlowOptions
121
- > extends Element<T, O>, VisualElement {}
122
-
123
- export const Flow: ChartComponent & {
124
- prototype: Flow;
125
- new(cfg: FlowConfig): Flow;
126
- };