@classic-homes/charts-react 0.5.0 → 0.7.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.
Files changed (3) hide show
  1. package/dist/index.cjs +136 -71
  2. package/dist/index.js +159 -76
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -880,6 +880,7 @@ var LineChart = React6.forwardRef(
880
880
  showDataTable,
881
881
  exportable,
882
882
  patterns,
883
+ selected,
883
884
  onClick,
884
885
  onHover,
885
886
  class: className,
@@ -914,16 +915,21 @@ var LineChart = React6.forwardRef(
914
915
  const series = data.series.map((source, index) => ({
915
916
  name: source.name,
916
917
  type: "line",
917
- data: (0, import_charts_core6.withForecastPoints)(
918
- (0, import_charts_core6.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
919
- position: "top"
920
- }),
921
- source,
922
- showDataPoints ? 6 : 0
918
+ data: (0, import_charts_core6.withSelectedPoints)(
919
+ (0, import_charts_core6.withForecastPoints)(
920
+ (0, import_charts_core6.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
921
+ position: "top"
922
+ }),
923
+ source,
924
+ showDataPoints ? 6 : 0
925
+ ),
926
+ data.categories,
927
+ selected,
928
+ { pointSize: showDataPoints ? 6 : 0, ringColor: chartColors.surface }
923
929
  ),
924
930
  smooth,
925
- // Forecast points show even when the others are hidden (size 0)
926
- showSymbol: showSymbol || (0, import_charts_core6.forecastStart)(source) !== void 0,
931
+ // Forecast and selected points show even when the others are hidden (size 0)
932
+ showSymbol: showSymbol || (0, import_charts_core6.forecastStart)(source) !== void 0 || (0, import_charts_core6.selectionShowsSymbols)(selected),
927
933
  symbolSize: showDataPoints ? 6 : 0,
928
934
  connectNulls,
929
935
  stack: stacked ? "Total" : void 0,
@@ -997,12 +1003,17 @@ var LineChart = React6.forwardRef(
997
1003
  formatters.axis(yAxisConfig)
998
1004
  ),
999
1005
  series: (0, import_charts_core6.withForecastLines)(
1000
- (0, import_charts_core6.withReferenceMarks)(series, referenceLines, referenceBands, {
1001
- valueAxis: "y",
1002
- format: formatters.format,
1003
- color: chartColors.reference,
1004
- bandColor: chartColors.referenceBand
1005
- }),
1006
+ (0, import_charts_core6.withReferenceMarks)(
1007
+ (0, import_charts_core6.withGhostSeries)(series, data.series),
1008
+ referenceLines,
1009
+ referenceBands,
1010
+ {
1011
+ valueAxis: "y",
1012
+ format: formatters.format,
1013
+ color: chartColors.reference,
1014
+ bandColor: chartColors.referenceBand
1015
+ }
1016
+ ),
1006
1017
  data.series,
1007
1018
  {
1008
1019
  colors: data.series.map(
@@ -1015,6 +1026,7 @@ var LineChart = React6.forwardRef(
1015
1026
  );
1016
1027
  }, [
1017
1028
  data,
1029
+ selected,
1018
1030
  isEmpty,
1019
1031
  showTooltip,
1020
1032
  showLegend,
@@ -1055,7 +1067,10 @@ var LineChart = React6.forwardRef(
1055
1067
  onCreated: onReady
1056
1068
  });
1057
1069
  const format = (0, import_charts_core6.resolveValueFormatter)(valueFormat, locale);
1058
- const accessibilityDescription = description || (!isEmpty ? (0, import_charts_core6.generateLineChartDescription)(title, data, format) : void 0);
1070
+ const accessibilityDescription = (0, import_charts_core6.withSelectionDescription)(
1071
+ description || (!isEmpty ? (0, import_charts_core6.generateLineChartDescription)(title, data, format) : void 0),
1072
+ selected
1073
+ );
1059
1074
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1060
1075
  ChartContainer,
1061
1076
  {
@@ -1141,6 +1156,7 @@ var BarChart = React7.forwardRef(
1141
1156
  showDataTable,
1142
1157
  exportable,
1143
1158
  patterns,
1159
+ selected,
1144
1160
  onClick,
1145
1161
  onHover,
1146
1162
  class: className,
@@ -1190,39 +1206,48 @@ var BarChart = React7.forwardRef(
1190
1206
  const labelPosition = isHorizontal ? "right" : "top";
1191
1207
  const zoomAxis = isHorizontal ? "y" : "x";
1192
1208
  const legendBottom = builtInLegend && (legendConfig?.position ?? "bottom") === "bottom";
1193
- const stackIds = data.series.map(() => stacked ? "Total" : void 0);
1194
- const series = data.series.map((source, index) => ({
1195
- name: source.name,
1196
- type: "bar",
1197
- data: (0, import_charts_core7.withForecastBars)(
1198
- (0, import_charts_core7.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
1199
- position: labelPosition
1209
+ const stackIds = data.series.map((s) => (0, import_charts_core7.ghostStackId)(stacked ? "Total" : void 0, s));
1210
+ const series = (0, import_charts_core7.withGhostSeries)(
1211
+ data.series.map((source, index) => ({
1212
+ name: source.name,
1213
+ type: "bar",
1214
+ data: (0, import_charts_core7.withSelectedBars)(
1215
+ (0, import_charts_core7.withForecastBars)(
1216
+ (0, import_charts_core7.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
1217
+ position: labelPosition
1218
+ }),
1219
+ source,
1220
+ source.color || chartColors.series[index % chartColors.series.length]
1221
+ ),
1222
+ data.categories,
1223
+ selected,
1224
+ (0, import_charts_core7.isGhostSeries)(source) ? import_charts_core7.GHOST_BAR_OPACITY : 1
1225
+ ),
1226
+ stack: stackIds[index],
1227
+ itemStyle: {
1228
+ ...source.color && { color: source.color },
1229
+ borderRadius: (0, import_charts_core7.barCornerRadius)(isHorizontal, stackIds, index)
1230
+ },
1231
+ label: (0, import_charts_core7.buildDataLabel)({ show: true, position: labelPosition }, void 0, {
1232
+ show: showValues,
1233
+ formatter: formatters.label,
1234
+ getLabel
1200
1235
  }),
1201
- source,
1202
- source.color || chartColors.series[index % chartColors.series.length]
1203
- ),
1204
- stack: stackIds[index],
1205
- itemStyle: {
1206
- ...source.color && { color: source.color },
1207
- borderRadius: (0, import_charts_core7.barCornerRadius)(isHorizontal, stackIds, index)
1208
- },
1209
- label: (0, import_charts_core7.buildDataLabel)({ show: true, position: labelPosition }, void 0, {
1210
- show: showValues,
1211
- formatter: formatters.label,
1212
- getLabel
1213
- }),
1214
- emphasis: {
1215
- focus: "series"
1216
- }
1217
- }));
1236
+ emphasis: {
1237
+ focus: "series"
1238
+ }
1239
+ })),
1240
+ data.series
1241
+ );
1218
1242
  const format2 = (0, import_charts_core7.resolveValueFormatter)(valueFormat, locale);
1219
- const stackedSeries = data.series.map((s) => ({ data: s.data }));
1243
+ const isSolid = (index) => data.series[index].variant !== "ghost";
1244
+ const stackedSeries = data.series.filter((_, index) => isSolid(index)).map((s) => ({ data: s.data }));
1220
1245
  const totalSeries = showTotal ? (0, import_charts_core7.buildStackTotalSeries)(data.categories, stackedSeries, {
1221
1246
  stacked,
1222
1247
  position: labelPosition,
1223
1248
  format: format2
1224
1249
  }) : [];
1225
- 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))) : [];
1250
+ 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.filter((_, index) => isSolid(index)).flatMap((s) => s.data.map((value) => (0, import_charts_core7.formatValue)(value, formatters.format))) : [];
1226
1251
  return (0, import_charts_core7.mergeChartOption)(
1227
1252
  {
1228
1253
  grid: {
@@ -1280,6 +1305,7 @@ var BarChart = React7.forwardRef(
1280
1305
  );
1281
1306
  }, [
1282
1307
  data,
1308
+ selected,
1283
1309
  isEmpty,
1284
1310
  showTooltip,
1285
1311
  showLegend,
@@ -1318,7 +1344,10 @@ var BarChart = React7.forwardRef(
1318
1344
  onCreated: onReady
1319
1345
  });
1320
1346
  const format = (0, import_charts_core7.resolveValueFormatter)(valueFormat, locale);
1321
- const accessibilityDescription = description || (!isEmpty ? (0, import_charts_core7.generateBarChartDescription)(title, data, format) : void 0);
1347
+ const accessibilityDescription = (0, import_charts_core7.withSelectionDescription)(
1348
+ description || (!isEmpty ? (0, import_charts_core7.generateBarChartDescription)(title, data, format) : void 0),
1349
+ selected
1350
+ );
1322
1351
  const resolvedHeight = isHorizontal ? (0, import_charts_core7.resolveChartHeight)(height, data?.categories?.length ?? 0, {
1323
1352
  rowHeight,
1324
1353
  minHeight,
@@ -1395,6 +1424,7 @@ var PieChart = React8.forwardRef(
1395
1424
  showDataTable,
1396
1425
  exportable,
1397
1426
  patterns,
1427
+ selected,
1398
1428
  onClick,
1399
1429
  class: className,
1400
1430
  ...props
@@ -1444,12 +1474,15 @@ var PieChart = React8.forwardRef(
1444
1474
  type: "pie",
1445
1475
  radius: innerRadius ? [innerRadius, "70%"] : "70%",
1446
1476
  center: (0, import_charts_core8.legendCenter)(legendConfig, showLegend && !customLegend, ["50%", "45%"]),
1447
- data: data.map((item) => ({
1448
- name: item.name,
1449
- value: item.value,
1450
- itemStyle: item.color ? { color: item.color } : void 0,
1451
- label: (0, import_charts_core8.pointLabel)(item.label, labelFormatter, { position: labelPosition })
1452
- })),
1477
+ data: (0, import_charts_core8.withSelectedSlices)(
1478
+ data.map((item) => ({
1479
+ name: item.name,
1480
+ value: item.value,
1481
+ itemStyle: item.color ? { color: item.color } : void 0,
1482
+ label: (0, import_charts_core8.pointLabel)(item.label, labelFormatter, { position: labelPosition })
1483
+ })),
1484
+ selected
1485
+ ),
1453
1486
  label: (0, import_charts_core8.buildDataLabel)(
1454
1487
  {
1455
1488
  show: true,
@@ -1473,6 +1506,7 @@ var PieChart = React8.forwardRef(
1473
1506
  );
1474
1507
  }, [
1475
1508
  data,
1509
+ selected,
1476
1510
  isEmpty,
1477
1511
  showTooltip,
1478
1512
  showLegend,
@@ -1498,7 +1532,10 @@ var PieChart = React8.forwardRef(
1498
1532
  onReady: legend.attach,
1499
1533
  onCreated: onReady
1500
1534
  });
1501
- const accessibilityDescription = description || (!isEmpty ? (0, import_charts_core8.generatePieChartDescription)(title, data, false) : void 0);
1535
+ const accessibilityDescription = (0, import_charts_core8.withSelectionDescription)(
1536
+ description || (!isEmpty ? (0, import_charts_core8.generatePieChartDescription)(title, data, false) : void 0),
1537
+ selected
1538
+ );
1502
1539
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1503
1540
  ChartContainer,
1504
1541
  {
@@ -1584,6 +1621,8 @@ var AreaChart = React9.forwardRef(
1584
1621
  showDataTable,
1585
1622
  exportable,
1586
1623
  patterns,
1624
+ showDataPoints = false,
1625
+ selected,
1587
1626
  onClick,
1588
1627
  onHover,
1589
1628
  class: className,
@@ -1613,18 +1652,25 @@ var AreaChart = React9.forwardRef(
1613
1652
  });
1614
1653
  const plotted = isPercent ? (0, import_charts_core9.toPercentStack)(data.series) : data.series;
1615
1654
  const getLabel = (0, import_charts_core9.seriesLabelLookup)(data.series);
1616
- const showSymbol = showLabels || (0, import_charts_core9.hasPointLabels)(data.series);
1655
+ const showSymbol = showDataPoints || showLabels || (0, import_charts_core9.hasPointLabels)(data.series);
1656
+ const pointSize = showDataPoints ? 6 : showSymbol ? 4 : 0;
1617
1657
  const legendBottom = builtInLegend && (legendConfig?.position ?? "bottom") === "bottom";
1618
1658
  const series = data.series.map((source, index) => {
1619
1659
  const base = source.color || chartColors.series[index % chartColors.series.length];
1620
1660
  return {
1621
1661
  name: source.name,
1622
1662
  type: "line",
1623
- data: (0, import_charts_core9.withForecastPoints)(
1624
- (0, import_charts_core9.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
1625
- position: "top"
1626
- }),
1627
- source
1663
+ data: (0, import_charts_core9.withSelectedPoints)(
1664
+ (0, import_charts_core9.withForecastPoints)(
1665
+ (0, import_charts_core9.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
1666
+ position: "top"
1667
+ }),
1668
+ source,
1669
+ pointSize
1670
+ ),
1671
+ data.categories,
1672
+ selected,
1673
+ { pointSize, ringColor: chartColors.surface }
1628
1674
  ),
1629
1675
  smooth,
1630
1676
  connectNulls,
@@ -1645,8 +1691,9 @@ var AreaChart = React9.forwardRef(
1645
1691
  emphasis: {
1646
1692
  focus: "series"
1647
1693
  },
1648
- // Forecast points show even when the others are hidden (size 0)
1649
- ...(0, import_charts_core9.forecastStart)(source) === void 0 ? { showSymbol } : { showSymbol: true, symbolSize: showSymbol ? 4 : 0 }
1694
+ // Forecast and selected points show even when the others are hidden (size 0)
1695
+ showSymbol: showSymbol || (0, import_charts_core9.forecastStart)(source) !== void 0 || (0, import_charts_core9.selectionShowsSymbols)(selected),
1696
+ symbolSize: pointSize
1650
1697
  };
1651
1698
  });
1652
1699
  return (0, import_charts_core9.mergeChartOption)(
@@ -1705,12 +1752,17 @@ var AreaChart = React9.forwardRef(
1705
1752
  formatters.axis(yAxisConfig)
1706
1753
  ),
1707
1754
  series: (0, import_charts_core9.withForecastLines)(
1708
- (0, import_charts_core9.withReferenceMarks)(series, referenceLines, referenceBands, {
1709
- valueAxis: "y",
1710
- format: formatters.format,
1711
- color: chartColors.reference,
1712
- bandColor: chartColors.referenceBand
1713
- }),
1755
+ (0, import_charts_core9.withReferenceMarks)(
1756
+ (0, import_charts_core9.withGhostSeries)(series, data.series),
1757
+ referenceLines,
1758
+ referenceBands,
1759
+ {
1760
+ valueAxis: "y",
1761
+ format: formatters.format,
1762
+ color: chartColors.reference,
1763
+ bandColor: chartColors.referenceBand
1764
+ }
1765
+ ),
1714
1766
  data.series,
1715
1767
  {
1716
1768
  colors: data.series.map(
@@ -1723,6 +1775,8 @@ var AreaChart = React9.forwardRef(
1723
1775
  );
1724
1776
  }, [
1725
1777
  data,
1778
+ selected,
1779
+ showDataPoints,
1726
1780
  isEmpty,
1727
1781
  showTooltip,
1728
1782
  showLegend,
@@ -1762,7 +1816,10 @@ var AreaChart = React9.forwardRef(
1762
1816
  onCreated: onReady
1763
1817
  });
1764
1818
  const format = (0, import_charts_core9.resolveValueFormatter)(valueFormat, locale);
1765
- const accessibilityDescription = description || (!isEmpty ? (0, import_charts_core9.generateAreaChartDescription)(title, data, format) : void 0);
1819
+ const accessibilityDescription = (0, import_charts_core9.withSelectionDescription)(
1820
+ description || (!isEmpty ? (0, import_charts_core9.generateAreaChartDescription)(title, data, format) : void 0),
1821
+ selected
1822
+ );
1766
1823
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1767
1824
  ChartContainer,
1768
1825
  {
@@ -2103,6 +2160,7 @@ var DonutChart = React11.forwardRef(
2103
2160
  showDataTable,
2104
2161
  exportable,
2105
2162
  patterns,
2163
+ selected,
2106
2164
  onClick,
2107
2165
  class: className,
2108
2166
  ...props
@@ -2199,12 +2257,15 @@ var DonutChart = React11.forwardRef(
2199
2257
  radius: [innerRadius, "70%"],
2200
2258
  center: pieCenter,
2201
2259
  avoidLabelOverlap: true,
2202
- data: data.map((item) => ({
2203
- name: item.name,
2204
- value: item.value,
2205
- itemStyle: item.color ? { color: item.color } : void 0,
2206
- label: (0, import_charts_core11.pointLabel)(item.label, labelFormatter, { position: labelPosition })
2207
- })),
2260
+ data: (0, import_charts_core11.withSelectedSlices)(
2261
+ data.map((item) => ({
2262
+ name: item.name,
2263
+ value: item.value,
2264
+ itemStyle: item.color ? { color: item.color } : void 0,
2265
+ label: (0, import_charts_core11.pointLabel)(item.label, labelFormatter, { position: labelPosition })
2266
+ })),
2267
+ selected
2268
+ ),
2208
2269
  label: (0, import_charts_core11.buildDataLabel)(
2209
2270
  {
2210
2271
  show: true,
@@ -2231,6 +2292,7 @@ var DonutChart = React11.forwardRef(
2231
2292
  );
2232
2293
  }, [
2233
2294
  data,
2295
+ selected,
2234
2296
  isEmpty,
2235
2297
  showTooltip,
2236
2298
  showLegend,
@@ -2259,7 +2321,10 @@ var DonutChart = React11.forwardRef(
2259
2321
  onReady: legend.attach,
2260
2322
  onCreated: onReady
2261
2323
  });
2262
- const accessibilityDescription = description || (!isEmpty ? (0, import_charts_core11.generatePieChartDescription)(title, data, true) : void 0);
2324
+ const accessibilityDescription = (0, import_charts_core11.withSelectionDescription)(
2325
+ description || (!isEmpty ? (0, import_charts_core11.generatePieChartDescription)(title, data, true) : void 0),
2326
+ selected
2327
+ );
2263
2328
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2264
2329
  ChartContainer,
2265
2330
  {
package/dist/index.js CHANGED
@@ -454,8 +454,12 @@ import {
454
454
  THEME_DARK as THEME_DARK2,
455
455
  toPercentStack,
456
456
  withPointLabels,
457
+ withGhostSeries,
457
458
  withReferenceMarks,
458
- withZoomInset
459
+ withZoomInset,
460
+ selectionShowsSymbols,
461
+ withSelectedPoints,
462
+ withSelectionDescription
459
463
  } from "@classic-homes/charts-core";
460
464
 
461
465
  // src/lib/events.ts
@@ -862,6 +866,7 @@ var LineChart = React6.forwardRef(
862
866
  showDataTable,
863
867
  exportable,
864
868
  patterns,
869
+ selected,
865
870
  onClick,
866
871
  onHover,
867
872
  class: className,
@@ -896,16 +901,21 @@ var LineChart = React6.forwardRef(
896
901
  const series = data.series.map((source, index) => ({
897
902
  name: source.name,
898
903
  type: "line",
899
- data: withForecastPoints(
900
- withPointLabels(plotted[index].data, source.labels, formatters.label, {
901
- position: "top"
902
- }),
903
- source,
904
- showDataPoints ? 6 : 0
904
+ data: withSelectedPoints(
905
+ withForecastPoints(
906
+ withPointLabels(plotted[index].data, source.labels, formatters.label, {
907
+ position: "top"
908
+ }),
909
+ source,
910
+ showDataPoints ? 6 : 0
911
+ ),
912
+ data.categories,
913
+ selected,
914
+ { pointSize: showDataPoints ? 6 : 0, ringColor: chartColors.surface }
905
915
  ),
906
916
  smooth,
907
- // Forecast points show even when the others are hidden (size 0)
908
- showSymbol: showSymbol || forecastStart(source) !== void 0,
917
+ // Forecast and selected points show even when the others are hidden (size 0)
918
+ showSymbol: showSymbol || forecastStart(source) !== void 0 || selectionShowsSymbols(selected),
909
919
  symbolSize: showDataPoints ? 6 : 0,
910
920
  connectNulls,
911
921
  stack: stacked ? "Total" : void 0,
@@ -979,12 +989,17 @@ var LineChart = React6.forwardRef(
979
989
  formatters.axis(yAxisConfig)
980
990
  ),
981
991
  series: withForecastLines(
982
- withReferenceMarks(series, referenceLines, referenceBands, {
983
- valueAxis: "y",
984
- format: formatters.format,
985
- color: chartColors.reference,
986
- bandColor: chartColors.referenceBand
987
- }),
992
+ withReferenceMarks(
993
+ withGhostSeries(series, data.series),
994
+ referenceLines,
995
+ referenceBands,
996
+ {
997
+ valueAxis: "y",
998
+ format: formatters.format,
999
+ color: chartColors.reference,
1000
+ bandColor: chartColors.referenceBand
1001
+ }
1002
+ ),
988
1003
  data.series,
989
1004
  {
990
1005
  colors: data.series.map(
@@ -997,6 +1012,7 @@ var LineChart = React6.forwardRef(
997
1012
  );
998
1013
  }, [
999
1014
  data,
1015
+ selected,
1000
1016
  isEmpty,
1001
1017
  showTooltip,
1002
1018
  showLegend,
@@ -1037,7 +1053,10 @@ var LineChart = React6.forwardRef(
1037
1053
  onCreated: onReady
1038
1054
  });
1039
1055
  const format = resolveValueFormatter(valueFormat, locale);
1040
- const accessibilityDescription = description || (!isEmpty ? generateLineChartDescription(title, data, format) : void 0);
1056
+ const accessibilityDescription = withSelectionDescription(
1057
+ description || (!isEmpty ? generateLineChartDescription(title, data, format) : void 0),
1058
+ selected
1059
+ );
1041
1060
  return /* @__PURE__ */ jsx7(
1042
1061
  ChartContainer,
1043
1062
  {
@@ -1091,6 +1110,7 @@ import {
1091
1110
  forecastTagLookup as forecastTagLookup2,
1092
1111
  withForecastBars,
1093
1112
  formatValue,
1113
+ ghostStackId,
1094
1114
  generateBarChartDescription,
1095
1115
  getChartColors as getChartColors2,
1096
1116
  gridInset as gridInset2,
@@ -1101,9 +1121,14 @@ import {
1101
1121
  stackTotals,
1102
1122
  toPercentStack as toPercentStack2,
1103
1123
  withEndLabelInset,
1124
+ withGhostSeries as withGhostSeries2,
1104
1125
  withPointLabels as withPointLabels2,
1105
1126
  withReferenceMarks as withReferenceMarks2,
1106
- withZoomInset as withZoomInset2
1127
+ withZoomInset as withZoomInset2,
1128
+ GHOST_BAR_OPACITY,
1129
+ isGhostSeries,
1130
+ withSelectedBars,
1131
+ withSelectionDescription as withSelectionDescription2
1107
1132
  } from "@classic-homes/charts-core";
1108
1133
  import { jsx as jsx8 } from "react/jsx-runtime";
1109
1134
  echarts4.use([
@@ -1154,6 +1179,7 @@ var BarChart = React7.forwardRef(
1154
1179
  showDataTable,
1155
1180
  exportable,
1156
1181
  patterns,
1182
+ selected,
1157
1183
  onClick,
1158
1184
  onHover,
1159
1185
  class: className,
@@ -1203,39 +1229,48 @@ var BarChart = React7.forwardRef(
1203
1229
  const labelPosition = isHorizontal ? "right" : "top";
1204
1230
  const zoomAxis = isHorizontal ? "y" : "x";
1205
1231
  const legendBottom = builtInLegend && (legendConfig?.position ?? "bottom") === "bottom";
1206
- const stackIds = data.series.map(() => stacked ? "Total" : void 0);
1207
- const series = data.series.map((source, index) => ({
1208
- name: source.name,
1209
- type: "bar",
1210
- data: withForecastBars(
1211
- withPointLabels2(plotted[index].data, source.labels, formatters.label, {
1212
- position: labelPosition
1232
+ const stackIds = data.series.map((s) => ghostStackId(stacked ? "Total" : void 0, s));
1233
+ const series = withGhostSeries2(
1234
+ data.series.map((source, index) => ({
1235
+ name: source.name,
1236
+ type: "bar",
1237
+ data: withSelectedBars(
1238
+ withForecastBars(
1239
+ withPointLabels2(plotted[index].data, source.labels, formatters.label, {
1240
+ position: labelPosition
1241
+ }),
1242
+ source,
1243
+ source.color || chartColors.series[index % chartColors.series.length]
1244
+ ),
1245
+ data.categories,
1246
+ selected,
1247
+ isGhostSeries(source) ? GHOST_BAR_OPACITY : 1
1248
+ ),
1249
+ stack: stackIds[index],
1250
+ itemStyle: {
1251
+ ...source.color && { color: source.color },
1252
+ borderRadius: barCornerRadius(isHorizontal, stackIds, index)
1253
+ },
1254
+ label: buildDataLabel2({ show: true, position: labelPosition }, void 0, {
1255
+ show: showValues,
1256
+ formatter: formatters.label,
1257
+ getLabel
1213
1258
  }),
1214
- source,
1215
- source.color || chartColors.series[index % chartColors.series.length]
1216
- ),
1217
- stack: stackIds[index],
1218
- itemStyle: {
1219
- ...source.color && { color: source.color },
1220
- borderRadius: barCornerRadius(isHorizontal, stackIds, index)
1221
- },
1222
- label: buildDataLabel2({ show: true, position: labelPosition }, void 0, {
1223
- show: showValues,
1224
- formatter: formatters.label,
1225
- getLabel
1226
- }),
1227
- emphasis: {
1228
- focus: "series"
1229
- }
1230
- }));
1259
+ emphasis: {
1260
+ focus: "series"
1261
+ }
1262
+ })),
1263
+ data.series
1264
+ );
1231
1265
  const format2 = resolveValueFormatter2(valueFormat, locale);
1232
- const stackedSeries = data.series.map((s) => ({ data: s.data }));
1266
+ const isSolid = (index) => data.series[index].variant !== "ghost";
1267
+ const stackedSeries = data.series.filter((_, index) => isSolid(index)).map((s) => ({ data: s.data }));
1233
1268
  const totalSeries = showTotal ? buildStackTotalSeries(data.categories, stackedSeries, {
1234
1269
  stacked,
1235
1270
  position: labelPosition,
1236
1271
  format: format2
1237
1272
  }) : [];
1238
- 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))) : [];
1273
+ const endLabels = !isHorizontal ? [] : totalSeries.length ? [...stackTotals(stackedSeries, stacked).values()].flat().map((t) => formatValue(t, format2)) : showValues ? plotted.filter((_, index) => isSolid(index)).flatMap((s) => s.data.map((value) => formatValue(value, formatters.format))) : [];
1239
1274
  return mergeChartOption2(
1240
1275
  {
1241
1276
  grid: {
@@ -1293,6 +1328,7 @@ var BarChart = React7.forwardRef(
1293
1328
  );
1294
1329
  }, [
1295
1330
  data,
1331
+ selected,
1296
1332
  isEmpty,
1297
1333
  showTooltip,
1298
1334
  showLegend,
@@ -1331,7 +1367,10 @@ var BarChart = React7.forwardRef(
1331
1367
  onCreated: onReady
1332
1368
  });
1333
1369
  const format = resolveValueFormatter2(valueFormat, locale);
1334
- const accessibilityDescription = description || (!isEmpty ? generateBarChartDescription(title, data, format) : void 0);
1370
+ const accessibilityDescription = withSelectionDescription2(
1371
+ description || (!isEmpty ? generateBarChartDescription(title, data, format) : void 0),
1372
+ selected
1373
+ );
1335
1374
  const resolvedHeight = isHorizontal ? resolveChartHeight(height, data?.categories?.length ?? 0, {
1336
1375
  rowHeight,
1337
1376
  minHeight,
@@ -1386,7 +1425,9 @@ import {
1386
1425
  mergeChartOption as mergeChartOption3,
1387
1426
  pointLabel,
1388
1427
  resolveValueFormatter as resolveValueFormatter3,
1389
- sliceTable
1428
+ sliceTable,
1429
+ withSelectedSlices,
1430
+ withSelectionDescription as withSelectionDescription3
1390
1431
  } from "@classic-homes/charts-core";
1391
1432
  import { jsx as jsx9 } from "react/jsx-runtime";
1392
1433
  echarts5.use([EChartsPieChart, TooltipComponent3, LegendComponent3, TitleComponent3, CanvasRenderer4]);
@@ -1422,6 +1463,7 @@ var PieChart = React8.forwardRef(
1422
1463
  showDataTable,
1423
1464
  exportable,
1424
1465
  patterns,
1466
+ selected,
1425
1467
  onClick,
1426
1468
  class: className,
1427
1469
  ...props
@@ -1471,12 +1513,15 @@ var PieChart = React8.forwardRef(
1471
1513
  type: "pie",
1472
1514
  radius: innerRadius ? [innerRadius, "70%"] : "70%",
1473
1515
  center: legendCenter(legendConfig, showLegend && !customLegend, ["50%", "45%"]),
1474
- data: data.map((item) => ({
1475
- name: item.name,
1476
- value: item.value,
1477
- itemStyle: item.color ? { color: item.color } : void 0,
1478
- label: pointLabel(item.label, labelFormatter, { position: labelPosition })
1479
- })),
1516
+ data: withSelectedSlices(
1517
+ data.map((item) => ({
1518
+ name: item.name,
1519
+ value: item.value,
1520
+ itemStyle: item.color ? { color: item.color } : void 0,
1521
+ label: pointLabel(item.label, labelFormatter, { position: labelPosition })
1522
+ })),
1523
+ selected
1524
+ ),
1480
1525
  label: buildDataLabel3(
1481
1526
  {
1482
1527
  show: true,
@@ -1500,6 +1545,7 @@ var PieChart = React8.forwardRef(
1500
1545
  );
1501
1546
  }, [
1502
1547
  data,
1548
+ selected,
1503
1549
  isEmpty,
1504
1550
  showTooltip,
1505
1551
  showLegend,
@@ -1525,7 +1571,10 @@ var PieChart = React8.forwardRef(
1525
1571
  onReady: legend.attach,
1526
1572
  onCreated: onReady
1527
1573
  });
1528
- const accessibilityDescription = description || (!isEmpty ? generatePieChartDescription(title, data, false) : void 0);
1574
+ const accessibilityDescription = withSelectionDescription3(
1575
+ description || (!isEmpty ? generatePieChartDescription(title, data, false) : void 0),
1576
+ selected
1577
+ );
1529
1578
  return /* @__PURE__ */ jsx9(
1530
1579
  ChartContainer,
1531
1580
  {
@@ -1589,8 +1638,12 @@ import {
1589
1638
  THEME_DARK as THEME_DARK3,
1590
1639
  toPercentStack as toPercentStack3,
1591
1640
  withPointLabels as withPointLabels3,
1641
+ withGhostSeries as withGhostSeries3,
1592
1642
  withReferenceMarks as withReferenceMarks3,
1593
- withZoomInset as withZoomInset3
1643
+ withZoomInset as withZoomInset3,
1644
+ selectionShowsSymbols as selectionShowsSymbols2,
1645
+ withSelectedPoints as withSelectedPoints2,
1646
+ withSelectionDescription as withSelectionDescription4
1594
1647
  } from "@classic-homes/charts-core";
1595
1648
  import { jsx as jsx10 } from "react/jsx-runtime";
1596
1649
  echarts6.use([
@@ -1641,6 +1694,8 @@ var AreaChart = React9.forwardRef(
1641
1694
  showDataTable,
1642
1695
  exportable,
1643
1696
  patterns,
1697
+ showDataPoints = false,
1698
+ selected,
1644
1699
  onClick,
1645
1700
  onHover,
1646
1701
  class: className,
@@ -1670,18 +1725,25 @@ var AreaChart = React9.forwardRef(
1670
1725
  });
1671
1726
  const plotted = isPercent ? toPercentStack3(data.series) : data.series;
1672
1727
  const getLabel = seriesLabelLookup3(data.series);
1673
- const showSymbol = showLabels || hasPointLabels2(data.series);
1728
+ const showSymbol = showDataPoints || showLabels || hasPointLabels2(data.series);
1729
+ const pointSize = showDataPoints ? 6 : showSymbol ? 4 : 0;
1674
1730
  const legendBottom = builtInLegend && (legendConfig?.position ?? "bottom") === "bottom";
1675
1731
  const series = data.series.map((source, index) => {
1676
1732
  const base = source.color || chartColors.series[index % chartColors.series.length];
1677
1733
  return {
1678
1734
  name: source.name,
1679
1735
  type: "line",
1680
- data: withForecastPoints2(
1681
- withPointLabels3(plotted[index].data, source.labels, formatters.label, {
1682
- position: "top"
1683
- }),
1684
- source
1736
+ data: withSelectedPoints2(
1737
+ withForecastPoints2(
1738
+ withPointLabels3(plotted[index].data, source.labels, formatters.label, {
1739
+ position: "top"
1740
+ }),
1741
+ source,
1742
+ pointSize
1743
+ ),
1744
+ data.categories,
1745
+ selected,
1746
+ { pointSize, ringColor: chartColors.surface }
1685
1747
  ),
1686
1748
  smooth,
1687
1749
  connectNulls,
@@ -1702,8 +1764,9 @@ var AreaChart = React9.forwardRef(
1702
1764
  emphasis: {
1703
1765
  focus: "series"
1704
1766
  },
1705
- // Forecast points show even when the others are hidden (size 0)
1706
- ...forecastStart2(source) === void 0 ? { showSymbol } : { showSymbol: true, symbolSize: showSymbol ? 4 : 0 }
1767
+ // Forecast and selected points show even when the others are hidden (size 0)
1768
+ showSymbol: showSymbol || forecastStart2(source) !== void 0 || selectionShowsSymbols2(selected),
1769
+ symbolSize: pointSize
1707
1770
  };
1708
1771
  });
1709
1772
  return mergeChartOption4(
@@ -1762,12 +1825,17 @@ var AreaChart = React9.forwardRef(
1762
1825
  formatters.axis(yAxisConfig)
1763
1826
  ),
1764
1827
  series: withForecastLines2(
1765
- withReferenceMarks3(series, referenceLines, referenceBands, {
1766
- valueAxis: "y",
1767
- format: formatters.format,
1768
- color: chartColors.reference,
1769
- bandColor: chartColors.referenceBand
1770
- }),
1828
+ withReferenceMarks3(
1829
+ withGhostSeries3(series, data.series),
1830
+ referenceLines,
1831
+ referenceBands,
1832
+ {
1833
+ valueAxis: "y",
1834
+ format: formatters.format,
1835
+ color: chartColors.reference,
1836
+ bandColor: chartColors.referenceBand
1837
+ }
1838
+ ),
1771
1839
  data.series,
1772
1840
  {
1773
1841
  colors: data.series.map(
@@ -1780,6 +1848,8 @@ var AreaChart = React9.forwardRef(
1780
1848
  );
1781
1849
  }, [
1782
1850
  data,
1851
+ selected,
1852
+ showDataPoints,
1783
1853
  isEmpty,
1784
1854
  showTooltip,
1785
1855
  showLegend,
@@ -1819,7 +1889,10 @@ var AreaChart = React9.forwardRef(
1819
1889
  onCreated: onReady
1820
1890
  });
1821
1891
  const format = resolveValueFormatter4(valueFormat, locale);
1822
- const accessibilityDescription = description || (!isEmpty ? generateAreaChartDescription(title, data, format) : void 0);
1892
+ const accessibilityDescription = withSelectionDescription4(
1893
+ description || (!isEmpty ? generateAreaChartDescription(title, data, format) : void 0),
1894
+ selected
1895
+ );
1823
1896
  return /* @__PURE__ */ jsx10(
1824
1897
  ChartContainer,
1825
1898
  {
@@ -2160,7 +2233,9 @@ import {
2160
2233
  pointLabel as pointLabel2,
2161
2234
  resolveValueFormatter as resolveValueFormatter6,
2162
2235
  sliceTable as sliceTable2,
2163
- THEME_DARK as THEME_DARK4
2236
+ THEME_DARK as THEME_DARK4,
2237
+ withSelectedSlices as withSelectedSlices2,
2238
+ withSelectionDescription as withSelectionDescription5
2164
2239
  } from "@classic-homes/charts-core";
2165
2240
  import { jsx as jsx12 } from "react/jsx-runtime";
2166
2241
  echarts8.use([EChartsPieChart2, TooltipComponent6, LegendComponent6, TitleComponent6, CanvasRenderer7]);
@@ -2198,6 +2273,7 @@ var DonutChart = React11.forwardRef(
2198
2273
  showDataTable,
2199
2274
  exportable,
2200
2275
  patterns,
2276
+ selected,
2201
2277
  onClick,
2202
2278
  class: className,
2203
2279
  ...props
@@ -2294,12 +2370,15 @@ var DonutChart = React11.forwardRef(
2294
2370
  radius: [innerRadius, "70%"],
2295
2371
  center: pieCenter,
2296
2372
  avoidLabelOverlap: true,
2297
- data: data.map((item) => ({
2298
- name: item.name,
2299
- value: item.value,
2300
- itemStyle: item.color ? { color: item.color } : void 0,
2301
- label: pointLabel2(item.label, labelFormatter, { position: labelPosition })
2302
- })),
2373
+ data: withSelectedSlices2(
2374
+ data.map((item) => ({
2375
+ name: item.name,
2376
+ value: item.value,
2377
+ itemStyle: item.color ? { color: item.color } : void 0,
2378
+ label: pointLabel2(item.label, labelFormatter, { position: labelPosition })
2379
+ })),
2380
+ selected
2381
+ ),
2303
2382
  label: buildDataLabel6(
2304
2383
  {
2305
2384
  show: true,
@@ -2326,6 +2405,7 @@ var DonutChart = React11.forwardRef(
2326
2405
  );
2327
2406
  }, [
2328
2407
  data,
2408
+ selected,
2329
2409
  isEmpty,
2330
2410
  showTooltip,
2331
2411
  showLegend,
@@ -2354,7 +2434,10 @@ var DonutChart = React11.forwardRef(
2354
2434
  onReady: legend.attach,
2355
2435
  onCreated: onReady
2356
2436
  });
2357
- const accessibilityDescription = description || (!isEmpty ? generatePieChartDescription2(title, data, true) : void 0);
2437
+ const accessibilityDescription = withSelectionDescription5(
2438
+ description || (!isEmpty ? generatePieChartDescription2(title, data, true) : void 0),
2439
+ selected
2440
+ );
2358
2441
  return /* @__PURE__ */ jsx12(
2359
2442
  ChartContainer,
2360
2443
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/charts-react",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "React ECharts components for Classic Theme",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",