@apia/charts 0.1.0
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.
- package/LICENSE.md +21 -0
- package/README.md +1 -0
- package/dist/index.d.ts +207 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2475 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [year] [fullname]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Charts
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as _apia_util from '@apia/util';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
import * as theme_ui_jsx_runtime from 'theme-ui/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
type TApiaChartCoordinate = {
|
|
6
|
+
/**
|
|
7
|
+
* Value shown in the X axis.
|
|
8
|
+
* In the case of pie charts, it defines the name of each slice.
|
|
9
|
+
*/
|
|
10
|
+
key: string;
|
|
11
|
+
/**
|
|
12
|
+
* Value shown in the Y axis, or to determine the size and value of slices of
|
|
13
|
+
* a pie chart.
|
|
14
|
+
*/
|
|
15
|
+
value: string;
|
|
16
|
+
/**
|
|
17
|
+
* Optional value shown only on the slices of pie charts
|
|
18
|
+
*/
|
|
19
|
+
percentage?: string;
|
|
20
|
+
color?: string;
|
|
21
|
+
};
|
|
22
|
+
type TApiaChartColumn = {
|
|
23
|
+
/**
|
|
24
|
+
* Specific color of a column, does not work on pie charts
|
|
25
|
+
*/
|
|
26
|
+
color: string;
|
|
27
|
+
/**
|
|
28
|
+
* Values of each element
|
|
29
|
+
*/
|
|
30
|
+
sets: TApiaChartCoordinate | TApiaChartCoordinate[];
|
|
31
|
+
/**
|
|
32
|
+
* Name of each column.
|
|
33
|
+
*
|
|
34
|
+
* On bars and line based charts, the legend will show this value.
|
|
35
|
+
*
|
|
36
|
+
* On the pie and waterfall charts, a chart will be created for each column.
|
|
37
|
+
*/
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
40
|
+
type TPie = {
|
|
41
|
+
chartType: 'pie2D';
|
|
42
|
+
};
|
|
43
|
+
type TNoPie = {
|
|
44
|
+
chartType: 'barH2D' | 'barV2D' | 'linear' | 'waterfall';
|
|
45
|
+
axisXTitle: string;
|
|
46
|
+
axisYTitle: string;
|
|
47
|
+
};
|
|
48
|
+
type TApiaChartDefinitionBase = {
|
|
49
|
+
/**
|
|
50
|
+
* The colors of the waterfall chart are defined by the bars with positive
|
|
51
|
+
* values and the bars with negative values. So in order to mantain cohesion
|
|
52
|
+
* in the color schema of the chart, this prop establishes the required colors
|
|
53
|
+
* for the chart
|
|
54
|
+
*/
|
|
55
|
+
waterfallColors?: {
|
|
56
|
+
positive: string;
|
|
57
|
+
negative: string;
|
|
58
|
+
total: string;
|
|
59
|
+
stepConnector: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Name of the schema of colors shown in the chart. Pie charts must always include a schema
|
|
63
|
+
*/
|
|
64
|
+
colorSchema: string;
|
|
65
|
+
/**
|
|
66
|
+
* Main data to be parsed and shown in the chart.
|
|
67
|
+
* Depending on the ```chartType``` and the amount of ```column``` objects,
|
|
68
|
+
* the data can be considered differently.
|
|
69
|
+
*
|
|
70
|
+
* Examples:
|
|
71
|
+
* ```
|
|
72
|
+
* const columnsWithSingleColumnObject = columns: {
|
|
73
|
+
* column: {
|
|
74
|
+
* color: 'red',
|
|
75
|
+
* coordinate: [
|
|
76
|
+
* { xValue: '1', yValue: '1' },
|
|
77
|
+
* ...,
|
|
78
|
+
* ],
|
|
79
|
+
* name: 'col1',
|
|
80
|
+
* }
|
|
81
|
+
* };
|
|
82
|
+
* ```
|
|
83
|
+
* ```
|
|
84
|
+
* const columnsWithMultipleColumnObject = columns: {
|
|
85
|
+
* column: [
|
|
86
|
+
* {
|
|
87
|
+
* color: 'red',
|
|
88
|
+
* coordinate: [
|
|
89
|
+
* { xValue: '1', yValue: '1' },
|
|
90
|
+
* ...,
|
|
91
|
+
* ],
|
|
92
|
+
* name: 'col1',
|
|
93
|
+
* },
|
|
94
|
+
* ...,
|
|
95
|
+
* ]
|
|
96
|
+
* };
|
|
97
|
+
*```
|
|
98
|
+
*
|
|
99
|
+
*
|
|
100
|
+
* ***Horizontal and Vertical bars***:
|
|
101
|
+
*
|
|
102
|
+
* ```1 column object```:
|
|
103
|
+
*
|
|
104
|
+
* Each ```coordinate``` is considered an individual separate 'column bar',
|
|
105
|
+
* and the ```colorSchema``` is separated between each ```coordinate``` made
|
|
106
|
+
* 'column bar'.
|
|
107
|
+
*
|
|
108
|
+
*
|
|
109
|
+
* ```Multiple column objects```:
|
|
110
|
+
*
|
|
111
|
+
* Each ```column``` object should have the same amount of coordinates and
|
|
112
|
+
* the coordinates in the same index of the array should have the same
|
|
113
|
+
* ```xValue```
|
|
114
|
+
*
|
|
115
|
+
* Each ```coordinate``` is considered an individual separate 'column bar',
|
|
116
|
+
* but the coordinates of each column are re-accommodated based on their
|
|
117
|
+
* ```xValue``` in order to make groups of columns with the same value on the
|
|
118
|
+
* X axis.
|
|
119
|
+
*
|
|
120
|
+
* In this case there will be 6 groups of columns (based on the length of the
|
|
121
|
+
* coordinate array), each group containing 3 'column bars' (based on the
|
|
122
|
+
* amount of column objects) and the ```colorSchema``` will be distributed
|
|
123
|
+
* inside each group, meaning each column having one single color.
|
|
124
|
+
*
|
|
125
|
+
*
|
|
126
|
+
* ***Linear***:
|
|
127
|
+
*
|
|
128
|
+
* ```N column objects```:
|
|
129
|
+
|
|
130
|
+
*
|
|
131
|
+
* Each ```column``` object is considered a line path, the coordinates being
|
|
132
|
+
* the nodes of said line.
|
|
133
|
+
*
|
|
134
|
+
* ***Pie charts***:
|
|
135
|
+
*
|
|
136
|
+
* ```N column objects```:
|
|
137
|
+
*
|
|
138
|
+
* Each ```column``` object is considered a unique Pie chart, the coordinates
|
|
139
|
+
* being the slices of said pie.
|
|
140
|
+
*
|
|
141
|
+
* ***Waterfall***:
|
|
142
|
+
*
|
|
143
|
+
* ```N column objects```:
|
|
144
|
+
*
|
|
145
|
+
* Each ```column``` object is considered a unique Waterfall chart, the coordinates
|
|
146
|
+
* being bars with the ```yValue``` determining if it goes up or down. Only this
|
|
147
|
+
* type of chart admits negative values on its coordinates.
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
dataSets: {
|
|
151
|
+
data: TApiaChartColumn | TApiaChartColumn[];
|
|
152
|
+
};
|
|
153
|
+
pnl_id?: string;
|
|
154
|
+
showAxisXTitle: boolean;
|
|
155
|
+
showAxisYTitle: boolean;
|
|
156
|
+
showGrid: boolean;
|
|
157
|
+
showLegend: boolean;
|
|
158
|
+
showValues: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Specific for waterfall charts to show the total sum of the values of the
|
|
161
|
+
* chart at the end while each column shows its value. Otherwise the values
|
|
162
|
+
* shown on each bar will represent the current sum of values
|
|
163
|
+
*/
|
|
164
|
+
showTotal?: boolean;
|
|
165
|
+
title: string;
|
|
166
|
+
ratio: {
|
|
167
|
+
height: number;
|
|
168
|
+
width: number;
|
|
169
|
+
maxWidth: number;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
type TApiaPieChartDefinition = TPie & TApiaChartDefinitionBase;
|
|
173
|
+
type TApiaNoPieChartDefinition = TNoPie & TApiaChartDefinitionBase;
|
|
174
|
+
type TApiaChartDefinition = TApiaPieChartDefinition | TApiaNoPieChartDefinition;
|
|
175
|
+
declare function isPieChart(chart: TApiaChartDefinition): chart is TApiaPieChartDefinition;
|
|
176
|
+
type TChartMargin = {
|
|
177
|
+
top: number;
|
|
178
|
+
bottom: number;
|
|
179
|
+
left: number;
|
|
180
|
+
right: number;
|
|
181
|
+
};
|
|
182
|
+
type TChartRendererProps = {
|
|
183
|
+
chart: TApiaChartDefinition;
|
|
184
|
+
margin?: number | TChartMargin;
|
|
185
|
+
disableEvents?: boolean;
|
|
186
|
+
className?: string;
|
|
187
|
+
chartId: string;
|
|
188
|
+
parentRef?: React.MutableRefObject<HTMLElement>;
|
|
189
|
+
outerClassName?: string;
|
|
190
|
+
allowZoom?: boolean;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
declare const ChartRenderer: React$1.FC<{
|
|
194
|
+
currentChart: TApiaChartDefinition;
|
|
195
|
+
chartConfig?: Partial<Omit<TApiaChartDefinition, "columns">> | undefined;
|
|
196
|
+
chartProps?: Partial<TChartRendererProps> | undefined;
|
|
197
|
+
allowScaleChange?: boolean | undefined;
|
|
198
|
+
chartId: string;
|
|
199
|
+
allowZoom?: boolean | undefined;
|
|
200
|
+
} & React$1.RefAttributes<HTMLElement> & {
|
|
201
|
+
id: _apia_util.TId;
|
|
202
|
+
}>;
|
|
203
|
+
|
|
204
|
+
declare const WidgetContainer: () => theme_ui_jsx_runtime.JSX.Element;
|
|
205
|
+
|
|
206
|
+
export { ChartRenderer, TApiaChartDefinition, WidgetContainer, isPieChart };
|
|
207
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|