@apia/charts 2.0.9 → 2.0.10

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 (36) hide show
  1. package/dist/charts/chartJsRenderer/ChartComponent.d.ts +22 -0
  2. package/dist/charts/chartJsRenderer/ChartComponent.d.ts.map +1 -0
  3. package/dist/charts/chartJsRenderer/ChartComponent.js +248 -0
  4. package/dist/charts/chartJsRenderer/ChartComponent.js.map +1 -0
  5. package/dist/charts/types.d.ts +173 -0
  6. package/dist/charts/types.d.ts.map +1 -0
  7. package/dist/index.d.ts +4 -334
  8. package/dist/index.js +2 -1455
  9. package/dist/index.js.map +1 -1
  10. package/dist/widgets/WidgetComponent.d.ts +10 -0
  11. package/dist/widgets/WidgetComponent.d.ts.map +1 -0
  12. package/dist/widgets/WidgetComponent.js +54 -0
  13. package/dist/widgets/WidgetComponent.js.map +1 -0
  14. package/dist/widgets/counter/Counter.js +108 -0
  15. package/dist/widgets/counter/Counter.js.map +1 -0
  16. package/dist/widgets/custom/useCustomWidget.js +64 -0
  17. package/dist/widgets/custom/useCustomWidget.js.map +1 -0
  18. package/dist/widgets/custom/util.js +9 -0
  19. package/dist/widgets/custom/util.js.map +1 -0
  20. package/dist/widgets/oxford/Oxford.js +243 -0
  21. package/dist/widgets/oxford/Oxford.js.map +1 -0
  22. package/dist/widgets/ring/Ring.js +123 -0
  23. package/dist/widgets/ring/Ring.js.map +1 -0
  24. package/dist/widgets/scale/Scale.js +145 -0
  25. package/dist/widgets/scale/Scale.js.map +1 -0
  26. package/dist/widgets/speedMeter/SpeedMeter.js +189 -0
  27. package/dist/widgets/speedMeter/SpeedMeter.js.map +1 -0
  28. package/dist/widgets/tLight/TLight.js +134 -0
  29. package/dist/widgets/tLight/TLight.js.map +1 -0
  30. package/dist/widgets/thermometer/Thermometer.js +146 -0
  31. package/dist/widgets/thermometer/Thermometer.js.map +1 -0
  32. package/dist/widgets/thermometer/util.js +34 -0
  33. package/dist/widgets/thermometer/util.js.map +1 -0
  34. package/dist/widgets/types.d.ts +106 -0
  35. package/dist/widgets/types.d.ts.map +1 -0
  36. package/package.json +3 -3
@@ -0,0 +1,22 @@
1
+ import * as react from 'react';
2
+ import { ChartData } from 'chart.js';
3
+
4
+ type TChartData = {
5
+ chartData: ChartData;
6
+ showLegend?: boolean;
7
+ showValues?: boolean;
8
+ showXAxisValues?: boolean;
9
+ showYAxisValues?: boolean;
10
+ showTable?: boolean;
11
+ type: 'bar' | 'line' | 'scatter' | 'bubble' | 'pie' | 'doughnut' | 'polarArea' | 'radar' | 'waterfall';
12
+ indexAxis?: 'x' | 'y';
13
+ xAxisTitle?: string;
14
+ yAxisTitle?: string;
15
+ id?: string;
16
+ chartId?: string;
17
+ aspectRatio?: number;
18
+ };
19
+ declare const ChartComponent: (props: TChartData) => react.JSX.Element;
20
+
21
+ export { ChartComponent, type TChartData };
22
+ //# sourceMappingURL=ChartComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartComponent.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,248 @@
1
+ import { jsx } from '@apia/theme/jsx-runtime';
2
+ import { arrayOrArray, getValueByPath } from '@apia/util';
3
+ import { Chart, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, BarController, BarElement, PieController, ArcElement, LineController } from 'chart.js';
4
+ import { useMemo } from 'react';
5
+ import { Chart as Chart$1 } from 'react-chartjs-2';
6
+ import { useThemeUI } from '@apia/theme';
7
+
8
+ Chart.register(
9
+ CategoryScale,
10
+ LinearScale,
11
+ PointElement,
12
+ LineElement,
13
+ Title,
14
+ Tooltip,
15
+ Legend,
16
+ BarController,
17
+ BarElement,
18
+ PieController,
19
+ ArcElement,
20
+ LineController
21
+ );
22
+ const ChartComponent = (props) => {
23
+ const actualProps = Object.assign(
24
+ {
25
+ chartData: { datasets: [{ data: [{ x: 0, y: 0 }] }] },
26
+ type: "bar",
27
+ indexAxis: "x",
28
+ showLegend: true,
29
+ showValues: true,
30
+ showXAxisValues: true,
31
+ showYAxisValues: true,
32
+ showTable: true,
33
+ xAxisTitle: "",
34
+ yAxisTitle: "",
35
+ aspectRatio: 2.5
36
+ },
37
+ props
38
+ );
39
+ const { theme } = useThemeUI();
40
+ if (!theme.layout)
41
+ console.error("The layout property is missing in the current theme");
42
+ const data = useMemo(() => {
43
+ const charts = theme.layout?.charts ?? {};
44
+ return {
45
+ datasets: (actualProps.type === "waterfall" ? arrayOrArray(actualProps.chartData.datasets).map((dataset) => {
46
+ let sum = 0;
47
+ const newData = dataset.data.map((dataValue) => {
48
+ if (typeof dataValue === "number") {
49
+ const currentValue = sum;
50
+ sum += dataValue;
51
+ return [currentValue, sum];
52
+ } else {
53
+ return dataValue;
54
+ }
55
+ });
56
+ return {
57
+ ...dataset,
58
+ data: newData
59
+ };
60
+ }) : actualProps.chartData.datasets).map((dataset, datasetIndex) => {
61
+ const isSingle = arrayOrArray(actualProps.chartData.datasets).every(
62
+ (dataset2) => arrayOrArray(dataset2.data).length === 1
63
+ ) || actualProps.type === "pie";
64
+ return {
65
+ ...dataset,
66
+ backgroundColor: dataset.backgroundColor.map((color, i) => {
67
+ let schemaArray = [];
68
+ if (typeof color === "string") {
69
+ if (color in charts) {
70
+ const currentBackgroundStylescheme = {
71
+ schema: getValueByPath(
72
+ theme.colors,
73
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
74
+ charts[color.toLowerCase()]?.schema
75
+ )
76
+ };
77
+ if (typeof currentBackgroundStylescheme.schema === "object" && currentBackgroundStylescheme.schema) {
78
+ if (isSingle) {
79
+ if (actualProps.type === "pie") {
80
+ schemaArray = Object.values(
81
+ currentBackgroundStylescheme.schema
82
+ ).map((varColor) => {
83
+ return window.getComputedStyle(document.documentElement).getPropertyValue(varColor.slice(4, -1));
84
+ });
85
+ } else {
86
+ schemaArray = new Array(6).fill(
87
+ Object.values(currentBackgroundStylescheme.schema)[datasetIndex % 6]
88
+ ).map((varColor) => {
89
+ return window.getComputedStyle(document.documentElement).getPropertyValue(varColor.slice(4, -1));
90
+ });
91
+ }
92
+ } else {
93
+ schemaArray = new Array(6).fill(
94
+ Object.values(currentBackgroundStylescheme.schema).map(
95
+ (varColor) => {
96
+ return window.getComputedStyle(document.documentElement).getPropertyValue(varColor.slice(4, -1));
97
+ }
98
+ )[datasetIndex % 6]
99
+ );
100
+ }
101
+ }
102
+ } else {
103
+ schemaArray = [color, color, color, color, color, color];
104
+ }
105
+ } else {
106
+ return color[datasetIndex % color.length];
107
+ }
108
+ return schemaArray[i % 6];
109
+ }),
110
+ borderColor: dataset.borderColor.map(
111
+ (color, i) => {
112
+ let schemaBorderArray = [];
113
+ if (typeof color === "string") {
114
+ if (color in charts) {
115
+ const currentBorderStylescheme = {
116
+ schema: getValueByPath(
117
+ theme.colors,
118
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
119
+ charts[color.toLowerCase()]?.schema
120
+ )
121
+ };
122
+ if (typeof currentBorderStylescheme.schema === "object" && currentBorderStylescheme.schema) {
123
+ schemaBorderArray = Object.values(
124
+ currentBorderStylescheme.schema
125
+ ).map((varColor) => {
126
+ return window.getComputedStyle(document.documentElement).getPropertyValue(varColor.slice(4, -1));
127
+ });
128
+ }
129
+ } else {
130
+ schemaBorderArray = [
131
+ color,
132
+ color,
133
+ color,
134
+ color,
135
+ color,
136
+ color
137
+ ];
138
+ }
139
+ } else {
140
+ return color[datasetIndex % color.length];
141
+ }
142
+ return schemaBorderArray[i % 6];
143
+ }
144
+ )
145
+ };
146
+ }),
147
+ labels: actualProps.chartData.labels
148
+ };
149
+ }, [
150
+ actualProps.chartData.datasets,
151
+ actualProps.chartData.labels,
152
+ actualProps.type,
153
+ theme.colors,
154
+ theme.layout
155
+ ]);
156
+ const options = useMemo(() => {
157
+ return {
158
+ plugins: {
159
+ legend: { position: "right", display: actualProps.showLegend },
160
+ tooltip: {
161
+ callbacks: {
162
+ label(tooltipItem) {
163
+ const XLabel = tooltipItem.dataset.label ?? "";
164
+ let YValue = tooltipItem.formattedValue;
165
+ if (isNaN(parseFloat(YValue))) {
166
+ const arrayValue = tooltipItem.raw;
167
+ const realValue = arrayValue[1] - arrayValue[0];
168
+ YValue = `${realValue}`;
169
+ }
170
+ let finalString = "";
171
+ if (actualProps.showLegend || actualProps.type === "pie") {
172
+ finalString += XLabel;
173
+ if (actualProps.showValues) {
174
+ finalString += ": " + YValue;
175
+ }
176
+ } else if (actualProps.showValues) {
177
+ finalString += YValue;
178
+ }
179
+ return finalString;
180
+ },
181
+ title(tooltipItems) {
182
+ if (actualProps.type !== "pie" && !actualProps.showXAxisValues && actualProps.indexAxis === "x" || actualProps.type !== "pie" && !actualProps.showYAxisValues && actualProps.indexAxis === "y" || actualProps.type === "pie" && !actualProps.showLegend) {
183
+ return "";
184
+ }
185
+ return tooltipItems[0].label;
186
+ }
187
+ },
188
+ enabled: (actualProps.indexAxis === "y" ? actualProps.showYAxisValues : actualProps.showXAxisValues) || actualProps.showValues || actualProps.showLegend
189
+ }
190
+ },
191
+ aspectRatio: actualProps.aspectRatio,
192
+ indexAxis: actualProps.indexAxis,
193
+ scales: {
194
+ x: {
195
+ display: actualProps.type !== "pie",
196
+ title: {
197
+ display: actualProps.showXAxisValues,
198
+ text: actualProps.indexAxis === "y" ? actualProps.yAxisTitle : actualProps.xAxisTitle
199
+ },
200
+ ticks: {
201
+ display: !!actualProps.showXAxisValues
202
+ },
203
+ grid: {
204
+ display: actualProps.showTable
205
+ }
206
+ },
207
+ y: {
208
+ axis: actualProps.indexAxis === "y" ? "x" : "y",
209
+ display: actualProps.type !== "pie",
210
+ title: {
211
+ display: actualProps.showYAxisValues,
212
+ text: actualProps.indexAxis === "y" ? actualProps.xAxisTitle : actualProps.yAxisTitle
213
+ },
214
+ ticks: {
215
+ display: !!actualProps.showYAxisValues
216
+ },
217
+ grid: {
218
+ display: actualProps.showTable
219
+ }
220
+ }
221
+ }
222
+ };
223
+ }, [
224
+ actualProps.aspectRatio,
225
+ actualProps.indexAxis,
226
+ actualProps.showLegend,
227
+ actualProps.showTable,
228
+ actualProps.showValues,
229
+ actualProps.showXAxisValues,
230
+ actualProps.showYAxisValues,
231
+ actualProps.type,
232
+ actualProps.xAxisTitle,
233
+ actualProps.yAxisTitle
234
+ ]);
235
+ return /* @__PURE__ */ jsx(
236
+ Chart$1,
237
+ {
238
+ id: actualProps.id ?? void 0,
239
+ className: actualProps.chartId ?? "",
240
+ type: actualProps.type === "waterfall" ? "bar" : actualProps.type,
241
+ options,
242
+ data
243
+ }
244
+ );
245
+ };
246
+
247
+ export { ChartComponent };
248
+ //# sourceMappingURL=ChartComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartComponent.js","sources":["../../../src/charts/chartJsRenderer/ChartComponent.tsx"],"sourcesContent":["import { arrayOrArray, getValueByPath } from '@apia/util';\r\nimport {\r\n ChartData,\r\n ChartOptions,\r\n Chart as ChartJS,\r\n CategoryScale,\r\n LinearScale,\r\n PointElement,\r\n LineElement,\r\n Title,\r\n Tooltip,\r\n Legend,\r\n BarController,\r\n BarElement,\r\n PieController,\r\n ArcElement,\r\n ChartTypeRegistry,\r\n TooltipItem,\r\n LineController,\r\n} from 'chart.js';\r\nimport { useMemo } from 'react';\r\nimport { Chart } from 'react-chartjs-2';\r\nimport { ColorModesScale, ThemeUIStyleObject, useThemeUI } from '@apia/theme';\r\nimport { IChartStylesSchemes } from '../types';\r\n\r\nChartJS.register(\r\n CategoryScale,\r\n LinearScale,\r\n PointElement,\r\n LineElement,\r\n Title,\r\n Tooltip,\r\n Legend,\r\n BarController,\r\n BarElement,\r\n PieController,\r\n ArcElement,\r\n LineController,\r\n);\r\n\r\nexport type TChartData = {\r\n chartData: ChartData;\r\n showLegend?: boolean;\r\n showValues?: boolean;\r\n showXAxisValues?: boolean;\r\n showYAxisValues?: boolean;\r\n showTable?: boolean;\r\n type:\r\n | 'bar'\r\n | 'line'\r\n | 'scatter'\r\n | 'bubble'\r\n | 'pie'\r\n | 'doughnut'\r\n | 'polarArea'\r\n | 'radar'\r\n | 'waterfall';\r\n indexAxis?: 'x' | 'y';\r\n xAxisTitle?: string;\r\n yAxisTitle?: string;\r\n id?: string;\r\n chartId?: string;\r\n aspectRatio?: number;\r\n};\r\n\r\nexport type TDataset = {\r\n backgroundColor?: string | string[];\r\n borderColor?: string | string[];\r\n borderWidth?: number;\r\n label?: string;\r\n data: number[] | [number, number][];\r\n}[];\r\n\r\nexport const ChartComponent = (props: TChartData) => {\r\n const actualProps: TChartData = Object.assign(\r\n {\r\n chartData: { datasets: [{ data: [{ x: 0, y: 0 }] }] },\r\n type: 'bar',\r\n indexAxis: 'x',\r\n showLegend: true,\r\n showValues: true,\r\n showXAxisValues: true,\r\n showYAxisValues: true,\r\n showTable: true,\r\n xAxisTitle: '',\r\n yAxisTitle: '',\r\n aspectRatio: 2.5,\r\n },\r\n props,\r\n );\r\n const { theme } = useThemeUI();\r\n\r\n if (!theme.layout)\r\n console.error('The layout property is missing in the current theme');\r\n\r\n const data: ChartData = useMemo(() => {\r\n const charts = ((theme.layout as Record<string, ThemeUIStyleObject>)\r\n ?.charts ?? {}) as IChartStylesSchemes;\r\n return {\r\n datasets: (actualProps.type === 'waterfall'\r\n ? arrayOrArray(actualProps.chartData.datasets).map((dataset) => {\r\n let sum = 0;\r\n const newData = dataset.data.map<[number, number]>((dataValue) => {\r\n if (typeof dataValue === 'number') {\r\n const currentValue = sum;\r\n sum += dataValue;\r\n return [currentValue, sum] as [number, number];\r\n } else {\r\n return dataValue as [number, number];\r\n }\r\n });\r\n\r\n return {\r\n ...dataset,\r\n data: newData,\r\n };\r\n })\r\n : actualProps.chartData.datasets\r\n ).map((dataset, datasetIndex) => {\r\n const isSingle =\r\n arrayOrArray(actualProps.chartData.datasets).every(\r\n (dataset) => arrayOrArray(dataset.data).length === 1,\r\n ) || actualProps.type === 'pie';\r\n\r\n return {\r\n ...dataset,\r\n backgroundColor: (\r\n dataset.backgroundColor as string[] | string[][]\r\n ).map((color, i) => {\r\n let schemaArray: string[] = [];\r\n if (typeof color === 'string') {\r\n if (color in charts) {\r\n const currentBackgroundStylescheme: {\r\n schema: Record<string, string>;\r\n } = {\r\n schema: getValueByPath(\r\n theme.colors as ColorModesScale,\r\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\r\n charts[color.toLowerCase()]?.schema as string,\r\n ) as Record<string, string>,\r\n };\r\n\r\n if (\r\n typeof currentBackgroundStylescheme.schema === 'object' &&\r\n currentBackgroundStylescheme.schema\r\n ) {\r\n if (isSingle) {\r\n if (actualProps.type === 'pie') {\r\n schemaArray = Object.values(\r\n currentBackgroundStylescheme.schema,\r\n ).map((varColor) => {\r\n return window\r\n .getComputedStyle(document.documentElement)\r\n .getPropertyValue(varColor.slice(4, -1));\r\n });\r\n } else {\r\n schemaArray = new Array<string>(6)\r\n .fill(\r\n Object.values(currentBackgroundStylescheme.schema)[\r\n datasetIndex % 6\r\n ],\r\n )\r\n .map((varColor) => {\r\n return window\r\n .getComputedStyle(document.documentElement)\r\n .getPropertyValue(varColor.slice(4, -1));\r\n });\r\n }\r\n } else {\r\n schemaArray = new Array<string>(6).fill(\r\n Object.values(currentBackgroundStylescheme.schema).map(\r\n (varColor) => {\r\n return window\r\n .getComputedStyle(document.documentElement)\r\n .getPropertyValue(varColor.slice(4, -1));\r\n },\r\n )[datasetIndex % 6],\r\n );\r\n }\r\n }\r\n } else {\r\n schemaArray = [color, color, color, color, color, color];\r\n }\r\n } else {\r\n return color[datasetIndex % color.length];\r\n }\r\n\r\n return schemaArray[i % 6];\r\n }),\r\n borderColor: (dataset.borderColor as string[] | string[][]).map(\r\n (color, i) => {\r\n let schemaBorderArray: string[] = [];\r\n if (typeof color === 'string') {\r\n if (color in charts) {\r\n const currentBorderStylescheme: {\r\n schema: Record<string, string>;\r\n } = {\r\n schema: getValueByPath(\r\n theme.colors as ColorModesScale,\r\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\r\n charts[color.toLowerCase()]?.schema as string,\r\n ) as Record<string, string>,\r\n };\r\n\r\n if (\r\n typeof currentBorderStylescheme.schema === 'object' &&\r\n currentBorderStylescheme.schema\r\n ) {\r\n schemaBorderArray = Object.values(\r\n currentBorderStylescheme.schema,\r\n ).map((varColor) => {\r\n return window\r\n .getComputedStyle(document.documentElement)\r\n .getPropertyValue(varColor.slice(4, -1));\r\n });\r\n }\r\n } else {\r\n schemaBorderArray = [\r\n color,\r\n color,\r\n color,\r\n color,\r\n color,\r\n color,\r\n ];\r\n }\r\n } else {\r\n return color[datasetIndex % color.length];\r\n }\r\n return schemaBorderArray[i % 6];\r\n },\r\n ),\r\n };\r\n }),\r\n labels: actualProps.chartData.labels,\r\n };\r\n }, [\r\n actualProps.chartData.datasets,\r\n actualProps.chartData.labels,\r\n actualProps.type,\r\n theme.colors,\r\n theme.layout,\r\n ]);\r\n\r\n const options: ChartOptions = useMemo(() => {\r\n return {\r\n plugins: {\r\n legend: { position: 'right', display: actualProps.showLegend },\r\n tooltip: {\r\n callbacks: {\r\n label(tooltipItem: TooltipItem<keyof ChartTypeRegistry>) {\r\n const XLabel = tooltipItem.dataset.label ?? '';\r\n let YValue = tooltipItem.formattedValue;\r\n if (isNaN(parseFloat(YValue))) {\r\n const arrayValue: [number, number] = tooltipItem.raw as [\r\n number,\r\n number,\r\n ];\r\n const realValue = arrayValue[1] - arrayValue[0];\r\n YValue = `${realValue}`;\r\n }\r\n let finalString = '';\r\n if (actualProps.showLegend || actualProps.type === 'pie') {\r\n finalString += XLabel;\r\n if (actualProps.showValues) {\r\n finalString += ': ' + YValue;\r\n }\r\n } else if (actualProps.showValues) {\r\n finalString += YValue;\r\n }\r\n return finalString;\r\n },\r\n title(tooltipItems: TooltipItem<keyof ChartTypeRegistry>[]) {\r\n if (\r\n (actualProps.type !== 'pie' &&\r\n !actualProps.showXAxisValues &&\r\n actualProps.indexAxis === 'x') ||\r\n (actualProps.type !== 'pie' &&\r\n !actualProps.showYAxisValues &&\r\n actualProps.indexAxis === 'y') ||\r\n (actualProps.type === 'pie' && !actualProps.showLegend)\r\n ) {\r\n return '';\r\n }\r\n return tooltipItems[0].label;\r\n },\r\n },\r\n enabled:\r\n (actualProps.indexAxis === 'y'\r\n ? actualProps.showYAxisValues\r\n : actualProps.showXAxisValues) ||\r\n actualProps.showValues ||\r\n actualProps.showLegend,\r\n },\r\n },\r\n aspectRatio: actualProps.aspectRatio,\r\n indexAxis: actualProps.indexAxis,\r\n scales: {\r\n x: {\r\n display: actualProps.type !== 'pie',\r\n title: {\r\n display: actualProps.showXAxisValues,\r\n text:\r\n actualProps.indexAxis === 'y'\r\n ? actualProps.yAxisTitle\r\n : actualProps.xAxisTitle,\r\n },\r\n ticks: {\r\n display: !!actualProps.showXAxisValues,\r\n },\r\n grid: {\r\n display: actualProps.showTable,\r\n },\r\n },\r\n y: {\r\n axis: (actualProps.indexAxis === 'y' ? 'x' : 'y') as 'x' | 'y' | 'r',\r\n display: actualProps.type !== 'pie',\r\n title: {\r\n display: actualProps.showYAxisValues,\r\n text:\r\n actualProps.indexAxis === 'y'\r\n ? actualProps.xAxisTitle\r\n : actualProps.yAxisTitle,\r\n },\r\n ticks: {\r\n display: !!actualProps.showYAxisValues,\r\n },\r\n grid: {\r\n display: actualProps.showTable,\r\n },\r\n },\r\n },\r\n };\r\n }, [\r\n actualProps.aspectRatio,\r\n actualProps.indexAxis,\r\n actualProps.showLegend,\r\n actualProps.showTable,\r\n actualProps.showValues,\r\n actualProps.showXAxisValues,\r\n actualProps.showYAxisValues,\r\n actualProps.type,\r\n actualProps.xAxisTitle,\r\n actualProps.yAxisTitle,\r\n ]);\r\n\r\n return (\r\n <Chart\r\n id={actualProps.id ?? undefined}\r\n className={actualProps.chartId ?? ''}\r\n type={actualProps.type === 'waterfall' ? 'bar' : actualProps.type}\r\n options={options}\r\n data={data}\r\n />\r\n );\r\n};\r\n"],"names":["ChartJS","dataset","Chart"],"mappings":";;;;;;;AAyBAA,KAAQ,CAAA,QAAA;AAAA,E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SAAA,EAAW,YAAY,OAAW,IAAA,EAAA;AAAA,MAClC,IAAM,EAAA,WAAA,CAAY,IAAS,KAAA,WAAA,GAAc,QAAQ,WAAY,CAAA,IAAA;AAAA,MAC7D,OAAA;AAAA,MACA,IAAA;AAAA,KAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,173 @@
1
+ type TApiaChartCoordinate = {
2
+ /**
3
+ * Value shown in the X axis.
4
+ * In the case of pie charts, it defines the name of each slice.
5
+ */
6
+ key: string;
7
+ /**
8
+ * Value shown in the Y axis, or to determine the size and value of slices of
9
+ * a pie chart.
10
+ */
11
+ value: string;
12
+ /**
13
+ * Optional value shown only on the slices of pie charts
14
+ */
15
+ percentage?: string;
16
+ color?: string;
17
+ };
18
+ type TApiaChartColumn = {
19
+ /**
20
+ * Specific color of a column, does not work on pie charts
21
+ */
22
+ color: string;
23
+ /**
24
+ * Values of each element
25
+ */
26
+ sets: TApiaChartCoordinate | TApiaChartCoordinate[];
27
+ /**
28
+ * Name of each column.
29
+ *
30
+ * On bars and line based charts, the legend will show this value.
31
+ *
32
+ * On the pie and waterfall charts, a chart will be created for each column.
33
+ */
34
+ name: string;
35
+ };
36
+ type TApiaChartDefinition = {
37
+ chartType?: 'barH2D' | 'barV2D' | 'linear' | 'waterfall' | 'pie2D';
38
+ axisXTitle?: string;
39
+ axisYTitle?: string;
40
+ aspectRatio?: number;
41
+ hideSelector?: boolean;
42
+ /**
43
+ * The colors of the waterfall chart are defined by the bars with positive
44
+ * values and the bars with negative values. So in order to mantain cohesion
45
+ * in the color schema of the chart, this prop establishes the required colors
46
+ * for the chart
47
+ */
48
+ waterfallColors?: {
49
+ positive: string;
50
+ negative: string;
51
+ total: string;
52
+ stepConnector: string;
53
+ };
54
+ /**
55
+ * Name of the schema of colors shown in the chart. Pie charts must always include a schema
56
+ */
57
+ colorSchema?: string;
58
+ /**
59
+ * Main data to be parsed and shown in the chart.
60
+ * Depending on the ```chartType``` and the amount of ```column``` objects,
61
+ * the data can be considered differently.
62
+ *
63
+ * Examples:
64
+ * ```
65
+ * const columnsWithSingleColumnObject = columns: {
66
+ * column: {
67
+ * color: 'red',
68
+ * coordinate: [
69
+ * { xValue: '1', yValue: '1' },
70
+ * ...,
71
+ * ],
72
+ * name: 'col1',
73
+ * }
74
+ * };
75
+ * ```
76
+ * ```
77
+ * const columnsWithMultipleColumnObject = columns: {
78
+ * column: [
79
+ * {
80
+ * color: 'red',
81
+ * coordinate: [
82
+ * { xValue: '1', yValue: '1' },
83
+ * ...,
84
+ * ],
85
+ * name: 'col1',
86
+ * },
87
+ * ...,
88
+ * ]
89
+ * };
90
+ *```
91
+ *
92
+ *
93
+ * ***Horizontal and Vertical bars***:
94
+ *
95
+ * ```1 column object```:
96
+ *
97
+ * Each ```coordinate``` is considered an individual separate 'column bar',
98
+ * and the ```colorSchema``` is separated between each ```coordinate``` made
99
+ * 'column bar'.
100
+ *
101
+ *
102
+ * ```Multiple column objects```:
103
+ *
104
+ * Each ```column``` object should have the same amount of coordinates and
105
+ * the coordinates in the same index of the array should have the same
106
+ * ```xValue```
107
+ *
108
+ * Each ```coordinate``` is considered an individual separate 'column bar',
109
+ * but the coordinates of each column are re-accommodated based on their
110
+ * ```xValue``` in order to make groups of columns with the same value on the
111
+ * X axis.
112
+ *
113
+ * In this case there will be 6 groups of columns (based on the length of the
114
+ * coordinate array), each group containing 3 'column bars' (based on the
115
+ * amount of column objects) and the ```colorSchema``` will be distributed
116
+ * inside each group, meaning each column having one single color.
117
+ *
118
+ *
119
+ * ***Linear***:
120
+ *
121
+ * ```N column objects```:
122
+
123
+ *
124
+ * Each ```column``` object is considered a line path, the coordinates being
125
+ * the nodes of said line.
126
+ *
127
+ * ***Pie charts***:
128
+ *
129
+ * ```N column objects```:
130
+ *
131
+ * Each ```column``` object is considered a unique Pie chart, the coordinates
132
+ * being the slices of said pie.
133
+ *
134
+ * ***Waterfall***:
135
+ *
136
+ * ```N column objects```:
137
+ *
138
+ * Each ```column``` object is considered a unique Waterfall chart, the coordinates
139
+ * being bars with the ```yValue``` determining if it goes up or down. Only this
140
+ * type of chart admits negative values on its coordinates.
141
+ *
142
+ */
143
+ dataSets: {
144
+ data: TApiaChartColumn | TApiaChartColumn[];
145
+ };
146
+ margin?: {
147
+ top: number;
148
+ left: number;
149
+ bottom: number;
150
+ right: number;
151
+ } | number;
152
+ pnl_id?: string;
153
+ showAxisXTitle?: boolean;
154
+ showAxisYTitle?: boolean;
155
+ showGrid?: boolean;
156
+ showLegend?: boolean;
157
+ showValues?: boolean;
158
+ /**
159
+ * Specific for waterfall charts to show the total sum of the values of the
160
+ * chart at the end while each column shows its value. Otherwise the values
161
+ * shown on each bar will represent the current sum of values
162
+ */
163
+ showTotal?: boolean;
164
+ title: string;
165
+ ratio: {
166
+ height: number;
167
+ width: number;
168
+ maxWidth: number;
169
+ };
170
+ };
171
+
172
+ export type { TApiaChartColumn, TApiaChartCoordinate, TApiaChartDefinition };
173
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}