@pagamio/frontend-commons-lib 0.8.230 → 0.8.232
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.
|
@@ -53,11 +53,11 @@ const ChartRenderer = ({ config, loading }) => {
|
|
|
53
53
|
// Flat array: { name, value }[] - convert to series format
|
|
54
54
|
const categories = data.map((d) => d.name);
|
|
55
55
|
const series = [{ name: 'Value', data: data.map((d) => d.value) }];
|
|
56
|
-
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(BarChartV2, { series: series, categories: categories, height: chartHeight, colors: chartColors, horizontal: config.barOptions?.horizontal, stacked: config.barOptions?.stacked, className: config.chartClassName }) }));
|
|
56
|
+
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(BarChartV2, { series: series, categories: categories, height: chartHeight, colors: chartColors, horizontal: config.barOptions?.horizontal, stacked: config.barOptions?.stacked, distributed: config.barOptions?.distributed, options: config.options, className: config.chartClassName }) }));
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
// Series format
|
|
60
|
-
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(BarChartV2, { series: data.series, categories: data.categories, height: chartHeight, colors: chartColors, horizontal: config.barOptions?.horizontal, stacked: config.barOptions?.stacked, className: config.chartClassName }) }));
|
|
60
|
+
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(BarChartV2, { series: data.series, categories: data.categories, height: chartHeight, colors: chartColors, horizontal: config.barOptions?.horizontal, stacked: config.barOptions?.stacked, distributed: config.barOptions?.distributed, options: config.options, className: config.chartClassName }) }));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
case 'donut': {
|
|
@@ -65,17 +65,17 @@ const ChartRenderer = ({ config, loading }) => {
|
|
|
65
65
|
const data = config.data;
|
|
66
66
|
const series = data.map((d) => d.value);
|
|
67
67
|
const labels = data.map((d) => d.name);
|
|
68
|
-
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(DonutChartV2, { series: series, labels: labels, height: chartHeight, colors: chartColors || data.map((d) => d.color).filter(Boolean), showLegend: config.donutOptions?.showLegend, legendPosition: config.donutOptions?.legendPosition, showLabels: config.donutOptions?.showLabels, className: config.chartClassName }) }));
|
|
68
|
+
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(DonutChartV2, { series: series, labels: labels, height: chartHeight, colors: chartColors || data.map((d) => d.color).filter(Boolean), showLegend: config.donutOptions?.showLegend, legendPosition: config.donutOptions?.legendPosition, showLabels: config.donutOptions?.showLabels, options: config.options, className: config.chartClassName }) }));
|
|
69
69
|
}
|
|
70
70
|
case 'line': {
|
|
71
71
|
// Line chart expects series: { name, data }[] and categories: string[]
|
|
72
72
|
const data = config.data;
|
|
73
|
-
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(LineChartV2, { series: data.series, categories: data.categories, height: chartHeight, colors: chartColors, className: config.chartClassName }) }));
|
|
73
|
+
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(LineChartV2, { series: data.series, categories: data.categories, height: chartHeight, colors: chartColors, options: config.options, className: config.chartClassName }) }));
|
|
74
74
|
}
|
|
75
75
|
case 'area': {
|
|
76
76
|
// Area chart expects series: { name, data }[] and categories: string[]
|
|
77
77
|
const data = config.data;
|
|
78
|
-
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(AreaChartV2, { series: data.series, categories: data.categories, height: chartHeight, colors: chartColors, stacked: config.areaOptions?.stacked, className: config.chartClassName }) }));
|
|
78
|
+
return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(AreaChartV2, { series: data.series, categories: data.categories, height: chartHeight, colors: chartColors, stacked: config.areaOptions?.stacked, options: config.options, className: config.chartClassName }) }));
|
|
79
79
|
}
|
|
80
80
|
case 'heatmap': {
|
|
81
81
|
// Heatmap expects series: { name, data: { x, y }[] }[]
|
|
@@ -35,6 +35,8 @@ export interface BarChartV2Props {
|
|
|
35
35
|
stacked?: boolean;
|
|
36
36
|
/** Whether to render as horizontal bar chart */
|
|
37
37
|
horizontal?: boolean;
|
|
38
|
+
/** Whether to distribute colors across bars (for single series with multiple categories) */
|
|
39
|
+
distributed?: boolean;
|
|
38
40
|
/** Chart colors */
|
|
39
41
|
colors?: string[];
|
|
40
42
|
/** Chart height */
|
|
@@ -68,7 +68,7 @@ series: staticSeries, categories: staticCategories,
|
|
|
68
68
|
// Fetch data
|
|
69
69
|
url, query, seriesNameKey = 'name', seriesValueKey = 'value', categoryKey = 'category',
|
|
70
70
|
// Chart options
|
|
71
|
-
stacked = false, horizontal = false, colors, height = 350, options: userOptions,
|
|
71
|
+
stacked = false, horizontal = false, distributed = false, colors, height = 350, options: userOptions,
|
|
72
72
|
// State
|
|
73
73
|
loading: controlledLoading, error: controlledError, emptyMessage, errorMessage,
|
|
74
74
|
// Styling
|
|
@@ -107,6 +107,7 @@ loadingComponent, errorComponent, emptyComponent, }) => {
|
|
|
107
107
|
horizontal,
|
|
108
108
|
borderRadius: 4,
|
|
109
109
|
columnWidth: '60%',
|
|
110
|
+
distributed,
|
|
110
111
|
...userOptions?.plotOptions?.bar,
|
|
111
112
|
},
|
|
112
113
|
},
|
|
@@ -115,7 +116,11 @@ loadingComponent, errorComponent, emptyComponent, }) => {
|
|
|
115
116
|
...userOptions?.xaxis,
|
|
116
117
|
},
|
|
117
118
|
colors: colors ?? userOptions?.colors,
|
|
118
|
-
|
|
119
|
+
legend: {
|
|
120
|
+
show: distributed ? false : userOptions?.legend?.show !== false,
|
|
121
|
+
...userOptions?.legend,
|
|
122
|
+
},
|
|
123
|
+
}), [userOptions, stacked, horizontal, distributed, transformedCategories, colors]);
|
|
119
124
|
return (_jsx(ApexChartWrapper, { type: "bar", series: transformedSeries, options: chartOptions, height: height, loading: isLoading, error: error, isEmpty: isEmpty, onRetry: isFetchMode ? refresh : undefined, emptyMessage: emptyMessage, errorMessage: errorMessage, className: className, containerClassName: containerClassName, loadingClassName: loadingClassName, errorClassName: errorClassName, emptyClassName: emptyClassName, loadingComponent: loadingComponent, errorComponent: errorComponent, emptyComponent: emptyComponent }));
|
|
120
125
|
};
|
|
121
126
|
export { BarChartV2 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.232",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|