@classic-homes/charts-react 0.3.0 → 0.4.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.
- package/dist/index.cjs +23 -6
- package/dist/index.js +28 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1107,6 +1107,7 @@ var BarChart = React7.forwardRef(
|
|
|
1107
1107
|
orientation = "vertical",
|
|
1108
1108
|
stacked = false,
|
|
1109
1109
|
showValues = false,
|
|
1110
|
+
showTotal = false,
|
|
1110
1111
|
valueFormat,
|
|
1111
1112
|
locale,
|
|
1112
1113
|
labelFormatter,
|
|
@@ -1175,14 +1176,18 @@ var BarChart = React7.forwardRef(
|
|
|
1175
1176
|
const labelPosition = isHorizontal ? "right" : "top";
|
|
1176
1177
|
const zoomAxis = isHorizontal ? "y" : "x";
|
|
1177
1178
|
const legendBottom = builtInLegend && (legendConfig?.position ?? "bottom") === "bottom";
|
|
1179
|
+
const stackIds = data.series.map(() => stacked ? "Total" : void 0);
|
|
1178
1180
|
const series = data.series.map((source, index) => ({
|
|
1179
1181
|
name: source.name,
|
|
1180
1182
|
type: "bar",
|
|
1181
1183
|
data: (0, import_charts_core7.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
|
|
1182
1184
|
position: labelPosition
|
|
1183
1185
|
}),
|
|
1184
|
-
stack:
|
|
1185
|
-
itemStyle:
|
|
1186
|
+
stack: stackIds[index],
|
|
1187
|
+
itemStyle: {
|
|
1188
|
+
...source.color && { color: source.color },
|
|
1189
|
+
borderRadius: (0, import_charts_core7.barCornerRadius)(isHorizontal, stackIds, index)
|
|
1190
|
+
},
|
|
1186
1191
|
label: (0, import_charts_core7.buildDataLabel)({ show: true, position: labelPosition }, void 0, {
|
|
1187
1192
|
show: showValues,
|
|
1188
1193
|
formatter: formatters.label,
|
|
@@ -1192,6 +1197,14 @@ var BarChart = React7.forwardRef(
|
|
|
1192
1197
|
focus: "series"
|
|
1193
1198
|
}
|
|
1194
1199
|
}));
|
|
1200
|
+
const format2 = (0, import_charts_core7.resolveValueFormatter)(valueFormat, locale);
|
|
1201
|
+
const stackedSeries = data.series.map((s) => ({ data: s.data }));
|
|
1202
|
+
const totalSeries = showTotal ? (0, import_charts_core7.buildStackTotalSeries)(data.categories, stackedSeries, {
|
|
1203
|
+
stacked,
|
|
1204
|
+
position: labelPosition,
|
|
1205
|
+
format: format2
|
|
1206
|
+
}) : [];
|
|
1207
|
+
const endLabels = !isHorizontal ? [] : totalSeries.length ? [...(0, import_charts_core7.stackTotals)(stackedSeries, stacked).values()].flat().map((t) => (0, import_charts_core7.formatValue)(t, format2)) : showValues ? plotted.flatMap((s) => s.data.map((value) => (0, import_charts_core7.formatValue)(value, formatters.format))) : [];
|
|
1195
1208
|
return (0, import_charts_core7.mergeChartOption)(
|
|
1196
1209
|
{
|
|
1197
1210
|
grid: {
|
|
@@ -1200,7 +1213,10 @@ var BarChart = React7.forwardRef(
|
|
|
1200
1213
|
bottom: "3%",
|
|
1201
1214
|
containLabel: true,
|
|
1202
1215
|
...(0, import_charts_core7.withZoomInset)(
|
|
1203
|
-
(0, import_charts_core7.
|
|
1216
|
+
(0, import_charts_core7.withEndLabelInset)(
|
|
1217
|
+
(0, import_charts_core7.gridInset)(legendConfig, builtInLegend, xAxisConfig, yAxisConfig),
|
|
1218
|
+
endLabels
|
|
1219
|
+
),
|
|
1204
1220
|
dataZoom,
|
|
1205
1221
|
zoomAxis
|
|
1206
1222
|
)
|
|
@@ -1233,7 +1249,7 @@ var BarChart = React7.forwardRef(
|
|
|
1233
1249
|
isHorizontal ? categoryAxis : valueAxis,
|
|
1234
1250
|
isHorizontal ? yAxisConfig : formatters.axis(yAxisConfig)
|
|
1235
1251
|
),
|
|
1236
|
-
series: (0, import_charts_core7.withReferenceMarks)(series, referenceLines, referenceBands, {
|
|
1252
|
+
series: (0, import_charts_core7.withReferenceMarks)([...series, ...totalSeries], referenceLines, referenceBands, {
|
|
1237
1253
|
valueAxis: isHorizontal ? "x" : "y",
|
|
1238
1254
|
inverse: isHorizontal,
|
|
1239
1255
|
format: formatters.format,
|
|
@@ -1253,6 +1269,7 @@ var BarChart = React7.forwardRef(
|
|
|
1253
1269
|
isPercent,
|
|
1254
1270
|
stacked,
|
|
1255
1271
|
showValues,
|
|
1272
|
+
showTotal,
|
|
1256
1273
|
valueFormat,
|
|
1257
1274
|
locale,
|
|
1258
1275
|
labelFormatter,
|
|
@@ -2651,7 +2668,7 @@ var GaugeChart = React14.forwardRef(
|
|
|
2651
2668
|
animation = true,
|
|
2652
2669
|
splitNumber = 10,
|
|
2653
2670
|
showProgress = true,
|
|
2654
|
-
formatValue,
|
|
2671
|
+
formatValue: formatValue2,
|
|
2655
2672
|
showTooltip = true,
|
|
2656
2673
|
valueFormat,
|
|
2657
2674
|
locale,
|
|
@@ -2674,7 +2691,7 @@ var GaugeChart = React14.forwardRef(
|
|
|
2674
2691
|
() => (0, import_charts_core14.resolveValueFormatter)(valueFormat, locale),
|
|
2675
2692
|
[valueFormat, locale]
|
|
2676
2693
|
);
|
|
2677
|
-
const valueFormatter =
|
|
2694
|
+
const valueFormatter = formatValue2 ?? format;
|
|
2678
2695
|
const option = React14.useMemo(() => {
|
|
2679
2696
|
return (0, import_charts_core14.mergeChartOption)(
|
|
2680
2697
|
{
|
package/dist/index.js
CHANGED
|
@@ -1061,13 +1061,16 @@ import {
|
|
|
1061
1061
|
} from "echarts/components";
|
|
1062
1062
|
import { CanvasRenderer as CanvasRenderer3 } from "echarts/renderers";
|
|
1063
1063
|
import {
|
|
1064
|
+
barCornerRadius,
|
|
1064
1065
|
buildAxis as buildAxis2,
|
|
1065
1066
|
buildDataLabel as buildDataLabel2,
|
|
1066
1067
|
buildDataZoom as buildDataZoom2,
|
|
1067
1068
|
buildLegend as buildLegend2,
|
|
1069
|
+
buildStackTotalSeries,
|
|
1068
1070
|
buildTooltip as buildTooltip2,
|
|
1069
1071
|
categoryTable as categoryTable2,
|
|
1070
1072
|
chartFormatters as chartFormatters2,
|
|
1073
|
+
formatValue,
|
|
1071
1074
|
generateBarChartDescription,
|
|
1072
1075
|
getChartColors as getChartColors2,
|
|
1073
1076
|
gridInset as gridInset2,
|
|
@@ -1075,7 +1078,9 @@ import {
|
|
|
1075
1078
|
resolveChartHeight,
|
|
1076
1079
|
resolveValueFormatter as resolveValueFormatter2,
|
|
1077
1080
|
seriesLabelLookup as seriesLabelLookup2,
|
|
1081
|
+
stackTotals,
|
|
1078
1082
|
toPercentStack as toPercentStack2,
|
|
1083
|
+
withEndLabelInset,
|
|
1079
1084
|
withPointLabels as withPointLabels2,
|
|
1080
1085
|
withReferenceMarks as withReferenceMarks2,
|
|
1081
1086
|
withZoomInset as withZoomInset2
|
|
@@ -1109,6 +1114,7 @@ var BarChart = React7.forwardRef(
|
|
|
1109
1114
|
orientation = "vertical",
|
|
1110
1115
|
stacked = false,
|
|
1111
1116
|
showValues = false,
|
|
1117
|
+
showTotal = false,
|
|
1112
1118
|
valueFormat,
|
|
1113
1119
|
locale,
|
|
1114
1120
|
labelFormatter,
|
|
@@ -1177,14 +1183,18 @@ var BarChart = React7.forwardRef(
|
|
|
1177
1183
|
const labelPosition = isHorizontal ? "right" : "top";
|
|
1178
1184
|
const zoomAxis = isHorizontal ? "y" : "x";
|
|
1179
1185
|
const legendBottom = builtInLegend && (legendConfig?.position ?? "bottom") === "bottom";
|
|
1186
|
+
const stackIds = data.series.map(() => stacked ? "Total" : void 0);
|
|
1180
1187
|
const series = data.series.map((source, index) => ({
|
|
1181
1188
|
name: source.name,
|
|
1182
1189
|
type: "bar",
|
|
1183
1190
|
data: withPointLabels2(plotted[index].data, source.labels, formatters.label, {
|
|
1184
1191
|
position: labelPosition
|
|
1185
1192
|
}),
|
|
1186
|
-
stack:
|
|
1187
|
-
itemStyle:
|
|
1193
|
+
stack: stackIds[index],
|
|
1194
|
+
itemStyle: {
|
|
1195
|
+
...source.color && { color: source.color },
|
|
1196
|
+
borderRadius: barCornerRadius(isHorizontal, stackIds, index)
|
|
1197
|
+
},
|
|
1188
1198
|
label: buildDataLabel2({ show: true, position: labelPosition }, void 0, {
|
|
1189
1199
|
show: showValues,
|
|
1190
1200
|
formatter: formatters.label,
|
|
@@ -1194,6 +1204,14 @@ var BarChart = React7.forwardRef(
|
|
|
1194
1204
|
focus: "series"
|
|
1195
1205
|
}
|
|
1196
1206
|
}));
|
|
1207
|
+
const format2 = resolveValueFormatter2(valueFormat, locale);
|
|
1208
|
+
const stackedSeries = data.series.map((s) => ({ data: s.data }));
|
|
1209
|
+
const totalSeries = showTotal ? buildStackTotalSeries(data.categories, stackedSeries, {
|
|
1210
|
+
stacked,
|
|
1211
|
+
position: labelPosition,
|
|
1212
|
+
format: format2
|
|
1213
|
+
}) : [];
|
|
1214
|
+
const endLabels = !isHorizontal ? [] : totalSeries.length ? [...stackTotals(stackedSeries, stacked).values()].flat().map((t) => formatValue(t, format2)) : showValues ? plotted.flatMap((s) => s.data.map((value) => formatValue(value, formatters.format))) : [];
|
|
1197
1215
|
return mergeChartOption2(
|
|
1198
1216
|
{
|
|
1199
1217
|
grid: {
|
|
@@ -1202,7 +1220,10 @@ var BarChart = React7.forwardRef(
|
|
|
1202
1220
|
bottom: "3%",
|
|
1203
1221
|
containLabel: true,
|
|
1204
1222
|
...withZoomInset2(
|
|
1205
|
-
|
|
1223
|
+
withEndLabelInset(
|
|
1224
|
+
gridInset2(legendConfig, builtInLegend, xAxisConfig, yAxisConfig),
|
|
1225
|
+
endLabels
|
|
1226
|
+
),
|
|
1206
1227
|
dataZoom,
|
|
1207
1228
|
zoomAxis
|
|
1208
1229
|
)
|
|
@@ -1235,7 +1256,7 @@ var BarChart = React7.forwardRef(
|
|
|
1235
1256
|
isHorizontal ? categoryAxis : valueAxis,
|
|
1236
1257
|
isHorizontal ? yAxisConfig : formatters.axis(yAxisConfig)
|
|
1237
1258
|
),
|
|
1238
|
-
series: withReferenceMarks2(series, referenceLines, referenceBands, {
|
|
1259
|
+
series: withReferenceMarks2([...series, ...totalSeries], referenceLines, referenceBands, {
|
|
1239
1260
|
valueAxis: isHorizontal ? "x" : "y",
|
|
1240
1261
|
inverse: isHorizontal,
|
|
1241
1262
|
format: formatters.format,
|
|
@@ -1255,6 +1276,7 @@ var BarChart = React7.forwardRef(
|
|
|
1255
1276
|
isPercent,
|
|
1256
1277
|
stacked,
|
|
1257
1278
|
showValues,
|
|
1279
|
+
showTotal,
|
|
1258
1280
|
valueFormat,
|
|
1259
1281
|
locale,
|
|
1260
1282
|
labelFormatter,
|
|
@@ -2763,7 +2785,7 @@ var GaugeChart = React14.forwardRef(
|
|
|
2763
2785
|
animation = true,
|
|
2764
2786
|
splitNumber = 10,
|
|
2765
2787
|
showProgress = true,
|
|
2766
|
-
formatValue,
|
|
2788
|
+
formatValue: formatValue2,
|
|
2767
2789
|
showTooltip = true,
|
|
2768
2790
|
valueFormat,
|
|
2769
2791
|
locale,
|
|
@@ -2786,7 +2808,7 @@ var GaugeChart = React14.forwardRef(
|
|
|
2786
2808
|
() => resolveValueFormatter9(valueFormat, locale),
|
|
2787
2809
|
[valueFormat, locale]
|
|
2788
2810
|
);
|
|
2789
|
-
const valueFormatter =
|
|
2811
|
+
const valueFormatter = formatValue2 ?? format;
|
|
2790
2812
|
const option = React14.useMemo(() => {
|
|
2791
2813
|
return mergeChartOption9(
|
|
2792
2814
|
{
|