@classic-homes/charts-react 0.4.2 → 0.6.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/dist/index.cjs CHANGED
@@ -914,11 +914,16 @@ var LineChart = React6.forwardRef(
914
914
  const series = data.series.map((source, index) => ({
915
915
  name: source.name,
916
916
  type: "line",
917
- data: (0, import_charts_core6.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
918
- position: "top"
919
- }),
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
923
+ ),
920
924
  smooth,
921
- showSymbol,
925
+ // Forecast points show even when the others are hidden (size 0)
926
+ showSymbol: showSymbol || (0, import_charts_core6.forecastStart)(source) !== void 0,
922
927
  symbolSize: showDataPoints ? 6 : 0,
923
928
  connectNulls,
924
929
  stack: stacked ? "Total" : void 0,
@@ -960,7 +965,8 @@ var LineChart = React6.forwardRef(
960
965
  show: showTooltip,
961
966
  formatter: tooltipFormatter,
962
967
  valueFormatter: formatters.tooltip,
963
- getLabel
968
+ getLabel,
969
+ forecastTag: (0, import_charts_core6.forecastTagLookup)(data.series)
964
970
  }
965
971
  ),
966
972
  legend: (0, import_charts_core6.buildLegend)(
@@ -990,12 +996,25 @@ var LineChart = React6.forwardRef(
990
996
  },
991
997
  formatters.axis(yAxisConfig)
992
998
  ),
993
- series: (0, import_charts_core6.withReferenceMarks)(series, referenceLines, referenceBands, {
994
- valueAxis: "y",
995
- format: formatters.format,
996
- color: chartColors.reference,
997
- bandColor: chartColors.referenceBand
998
- })
999
+ series: (0, import_charts_core6.withForecastLines)(
1000
+ (0, import_charts_core6.withReferenceMarks)(
1001
+ (0, import_charts_core6.withGhostSeries)(series, data.series),
1002
+ referenceLines,
1003
+ referenceBands,
1004
+ {
1005
+ valueAxis: "y",
1006
+ format: formatters.format,
1007
+ color: chartColors.reference,
1008
+ bandColor: chartColors.referenceBand
1009
+ }
1010
+ ),
1011
+ data.series,
1012
+ {
1013
+ colors: data.series.map(
1014
+ (s, i) => s.color || chartColors.series[i % chartColors.series.length]
1015
+ )
1016
+ }
1017
+ )
999
1018
  },
1000
1019
  optionOverride
1001
1020
  );
@@ -1176,35 +1195,43 @@ var BarChart = React7.forwardRef(
1176
1195
  const labelPosition = isHorizontal ? "right" : "top";
1177
1196
  const zoomAxis = isHorizontal ? "y" : "x";
1178
1197
  const legendBottom = builtInLegend && (legendConfig?.position ?? "bottom") === "bottom";
1179
- const stackIds = data.series.map(() => stacked ? "Total" : void 0);
1180
- const series = data.series.map((source, index) => ({
1181
- name: source.name,
1182
- type: "bar",
1183
- data: (0, import_charts_core7.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
1184
- position: labelPosition
1185
- }),
1186
- stack: stackIds[index],
1187
- itemStyle: {
1188
- ...source.color && { color: source.color },
1189
- borderRadius: (0, import_charts_core7.barCornerRadius)(isHorizontal, stackIds, index)
1190
- },
1191
- label: (0, import_charts_core7.buildDataLabel)({ show: true, position: labelPosition }, void 0, {
1192
- show: showValues,
1193
- formatter: formatters.label,
1194
- getLabel
1195
- }),
1196
- emphasis: {
1197
- focus: "series"
1198
- }
1199
- }));
1198
+ const stackIds = data.series.map((s) => (0, import_charts_core7.ghostStackId)(stacked ? "Total" : void 0, s));
1199
+ const series = (0, import_charts_core7.withGhostSeries)(
1200
+ data.series.map((source, index) => ({
1201
+ name: source.name,
1202
+ type: "bar",
1203
+ data: (0, import_charts_core7.withForecastBars)(
1204
+ (0, import_charts_core7.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
1205
+ position: labelPosition
1206
+ }),
1207
+ source,
1208
+ source.color || chartColors.series[index % chartColors.series.length]
1209
+ ),
1210
+ stack: stackIds[index],
1211
+ itemStyle: {
1212
+ ...source.color && { color: source.color },
1213
+ borderRadius: (0, import_charts_core7.barCornerRadius)(isHorizontal, stackIds, index)
1214
+ },
1215
+ label: (0, import_charts_core7.buildDataLabel)({ show: true, position: labelPosition }, void 0, {
1216
+ show: showValues,
1217
+ formatter: formatters.label,
1218
+ getLabel
1219
+ }),
1220
+ emphasis: {
1221
+ focus: "series"
1222
+ }
1223
+ })),
1224
+ data.series
1225
+ );
1200
1226
  const format2 = (0, import_charts_core7.resolveValueFormatter)(valueFormat, locale);
1201
- const stackedSeries = data.series.map((s) => ({ data: s.data }));
1227
+ const isSolid = (index) => data.series[index].variant !== "ghost";
1228
+ const stackedSeries = data.series.filter((_, index) => isSolid(index)).map((s) => ({ data: s.data }));
1202
1229
  const totalSeries = showTotal ? (0, import_charts_core7.buildStackTotalSeries)(data.categories, stackedSeries, {
1203
1230
  stacked,
1204
1231
  position: labelPosition,
1205
1232
  format: format2
1206
1233
  }) : [];
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))) : [];
1234
+ 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))) : [];
1208
1235
  return (0, import_charts_core7.mergeChartOption)(
1209
1236
  {
1210
1237
  grid: {
@@ -1232,7 +1259,8 @@ var BarChart = React7.forwardRef(
1232
1259
  show: showTooltip,
1233
1260
  formatter: tooltipFormatter,
1234
1261
  valueFormatter: formatters.tooltip,
1235
- getLabel
1262
+ getLabel,
1263
+ forecastTag: (0, import_charts_core7.forecastTagLookup)(data.series)
1236
1264
  }
1237
1265
  ),
1238
1266
  legend: (0, import_charts_core7.buildLegend)(
@@ -1601,9 +1629,12 @@ var AreaChart = React9.forwardRef(
1601
1629
  return {
1602
1630
  name: source.name,
1603
1631
  type: "line",
1604
- data: (0, import_charts_core9.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
1605
- position: "top"
1606
- }),
1632
+ data: (0, import_charts_core9.withForecastPoints)(
1633
+ (0, import_charts_core9.withPointLabels)(plotted[index].data, source.labels, formatters.label, {
1634
+ position: "top"
1635
+ }),
1636
+ source
1637
+ ),
1607
1638
  smooth,
1608
1639
  connectNulls,
1609
1640
  stack: stacked ? "Total" : void 0,
@@ -1623,7 +1654,8 @@ var AreaChart = React9.forwardRef(
1623
1654
  emphasis: {
1624
1655
  focus: "series"
1625
1656
  },
1626
- showSymbol
1657
+ // Forecast points show even when the others are hidden (size 0)
1658
+ ...(0, import_charts_core9.forecastStart)(source) === void 0 ? { showSymbol } : { showSymbol: true, symbolSize: showSymbol ? 4 : 0 }
1627
1659
  };
1628
1660
  });
1629
1661
  return (0, import_charts_core9.mergeChartOption)(
@@ -1653,7 +1685,8 @@ var AreaChart = React9.forwardRef(
1653
1685
  show: showTooltip,
1654
1686
  formatter: tooltipFormatter,
1655
1687
  valueFormatter: formatters.tooltip,
1656
- getLabel
1688
+ getLabel,
1689
+ forecastTag: (0, import_charts_core9.forecastTagLookup)(data.series)
1657
1690
  }
1658
1691
  ),
1659
1692
  legend: (0, import_charts_core9.buildLegend)(
@@ -1680,12 +1713,25 @@ var AreaChart = React9.forwardRef(
1680
1713
  },
1681
1714
  formatters.axis(yAxisConfig)
1682
1715
  ),
1683
- series: (0, import_charts_core9.withReferenceMarks)(series, referenceLines, referenceBands, {
1684
- valueAxis: "y",
1685
- format: formatters.format,
1686
- color: chartColors.reference,
1687
- bandColor: chartColors.referenceBand
1688
- })
1716
+ series: (0, import_charts_core9.withForecastLines)(
1717
+ (0, import_charts_core9.withReferenceMarks)(
1718
+ (0, import_charts_core9.withGhostSeries)(series, data.series),
1719
+ referenceLines,
1720
+ referenceBands,
1721
+ {
1722
+ valueAxis: "y",
1723
+ format: formatters.format,
1724
+ color: chartColors.reference,
1725
+ bandColor: chartColors.referenceBand
1726
+ }
1727
+ ),
1728
+ data.series,
1729
+ {
1730
+ colors: data.series.map(
1731
+ (s, i) => s.color || chartColors.series[i % chartColors.series.length]
1732
+ )
1733
+ }
1734
+ )
1689
1735
  },
1690
1736
  optionOverride
1691
1737
  );
package/dist/index.js CHANGED
@@ -440,6 +440,10 @@ import {
440
440
  buildTooltip,
441
441
  categoryTable,
442
442
  chartFormatters,
443
+ forecastStart,
444
+ forecastTagLookup,
445
+ withForecastLines,
446
+ withForecastPoints,
443
447
  generateLineChartDescription,
444
448
  getChartColors,
445
449
  hasPointLabels,
@@ -450,6 +454,7 @@ import {
450
454
  THEME_DARK as THEME_DARK2,
451
455
  toPercentStack,
452
456
  withPointLabels,
457
+ withGhostSeries,
453
458
  withReferenceMarks,
454
459
  withZoomInset
455
460
  } from "@classic-homes/charts-core";
@@ -892,11 +897,16 @@ var LineChart = React6.forwardRef(
892
897
  const series = data.series.map((source, index) => ({
893
898
  name: source.name,
894
899
  type: "line",
895
- data: withPointLabels(plotted[index].data, source.labels, formatters.label, {
896
- position: "top"
897
- }),
900
+ data: withForecastPoints(
901
+ withPointLabels(plotted[index].data, source.labels, formatters.label, {
902
+ position: "top"
903
+ }),
904
+ source,
905
+ showDataPoints ? 6 : 0
906
+ ),
898
907
  smooth,
899
- showSymbol,
908
+ // Forecast points show even when the others are hidden (size 0)
909
+ showSymbol: showSymbol || forecastStart(source) !== void 0,
900
910
  symbolSize: showDataPoints ? 6 : 0,
901
911
  connectNulls,
902
912
  stack: stacked ? "Total" : void 0,
@@ -938,7 +948,8 @@ var LineChart = React6.forwardRef(
938
948
  show: showTooltip,
939
949
  formatter: tooltipFormatter,
940
950
  valueFormatter: formatters.tooltip,
941
- getLabel
951
+ getLabel,
952
+ forecastTag: forecastTagLookup(data.series)
942
953
  }
943
954
  ),
944
955
  legend: buildLegend(
@@ -968,12 +979,25 @@ var LineChart = React6.forwardRef(
968
979
  },
969
980
  formatters.axis(yAxisConfig)
970
981
  ),
971
- series: withReferenceMarks(series, referenceLines, referenceBands, {
972
- valueAxis: "y",
973
- format: formatters.format,
974
- color: chartColors.reference,
975
- bandColor: chartColors.referenceBand
976
- })
982
+ series: withForecastLines(
983
+ withReferenceMarks(
984
+ withGhostSeries(series, data.series),
985
+ referenceLines,
986
+ referenceBands,
987
+ {
988
+ valueAxis: "y",
989
+ format: formatters.format,
990
+ color: chartColors.reference,
991
+ bandColor: chartColors.referenceBand
992
+ }
993
+ ),
994
+ data.series,
995
+ {
996
+ colors: data.series.map(
997
+ (s, i) => s.color || chartColors.series[i % chartColors.series.length]
998
+ )
999
+ }
1000
+ )
977
1001
  },
978
1002
  optionOverride
979
1003
  );
@@ -1070,7 +1094,10 @@ import {
1070
1094
  buildTooltip as buildTooltip2,
1071
1095
  categoryTable as categoryTable2,
1072
1096
  chartFormatters as chartFormatters2,
1097
+ forecastTagLookup as forecastTagLookup2,
1098
+ withForecastBars,
1073
1099
  formatValue,
1100
+ ghostStackId,
1074
1101
  generateBarChartDescription,
1075
1102
  getChartColors as getChartColors2,
1076
1103
  gridInset as gridInset2,
@@ -1081,6 +1108,7 @@ import {
1081
1108
  stackTotals,
1082
1109
  toPercentStack as toPercentStack2,
1083
1110
  withEndLabelInset,
1111
+ withGhostSeries as withGhostSeries2,
1084
1112
  withPointLabels as withPointLabels2,
1085
1113
  withReferenceMarks as withReferenceMarks2,
1086
1114
  withZoomInset as withZoomInset2
@@ -1183,35 +1211,43 @@ var BarChart = React7.forwardRef(
1183
1211
  const labelPosition = isHorizontal ? "right" : "top";
1184
1212
  const zoomAxis = isHorizontal ? "y" : "x";
1185
1213
  const legendBottom = builtInLegend && (legendConfig?.position ?? "bottom") === "bottom";
1186
- const stackIds = data.series.map(() => stacked ? "Total" : void 0);
1187
- const series = data.series.map((source, index) => ({
1188
- name: source.name,
1189
- type: "bar",
1190
- data: withPointLabels2(plotted[index].data, source.labels, formatters.label, {
1191
- position: labelPosition
1192
- }),
1193
- stack: stackIds[index],
1194
- itemStyle: {
1195
- ...source.color && { color: source.color },
1196
- borderRadius: barCornerRadius(isHorizontal, stackIds, index)
1197
- },
1198
- label: buildDataLabel2({ show: true, position: labelPosition }, void 0, {
1199
- show: showValues,
1200
- formatter: formatters.label,
1201
- getLabel
1202
- }),
1203
- emphasis: {
1204
- focus: "series"
1205
- }
1206
- }));
1214
+ const stackIds = data.series.map((s) => ghostStackId(stacked ? "Total" : void 0, s));
1215
+ const series = withGhostSeries2(
1216
+ data.series.map((source, index) => ({
1217
+ name: source.name,
1218
+ type: "bar",
1219
+ data: withForecastBars(
1220
+ withPointLabels2(plotted[index].data, source.labels, formatters.label, {
1221
+ position: labelPosition
1222
+ }),
1223
+ source,
1224
+ source.color || chartColors.series[index % chartColors.series.length]
1225
+ ),
1226
+ stack: stackIds[index],
1227
+ itemStyle: {
1228
+ ...source.color && { color: source.color },
1229
+ borderRadius: barCornerRadius(isHorizontal, stackIds, index)
1230
+ },
1231
+ label: buildDataLabel2({ show: true, position: labelPosition }, void 0, {
1232
+ show: showValues,
1233
+ formatter: formatters.label,
1234
+ getLabel
1235
+ }),
1236
+ emphasis: {
1237
+ focus: "series"
1238
+ }
1239
+ })),
1240
+ data.series
1241
+ );
1207
1242
  const format2 = resolveValueFormatter2(valueFormat, locale);
1208
- 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 }));
1209
1245
  const totalSeries = showTotal ? buildStackTotalSeries(data.categories, stackedSeries, {
1210
1246
  stacked,
1211
1247
  position: labelPosition,
1212
1248
  format: format2
1213
1249
  }) : [];
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))) : [];
1250
+ 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))) : [];
1215
1251
  return mergeChartOption2(
1216
1252
  {
1217
1253
  grid: {
@@ -1239,7 +1275,8 @@ var BarChart = React7.forwardRef(
1239
1275
  show: showTooltip,
1240
1276
  formatter: tooltipFormatter,
1241
1277
  valueFormatter: formatters.tooltip,
1242
- getLabel
1278
+ getLabel,
1279
+ forecastTag: forecastTagLookup2(data.series)
1243
1280
  }
1244
1281
  ),
1245
1282
  legend: buildLegend2(
@@ -1549,6 +1586,10 @@ import {
1549
1586
  buildTooltip as buildTooltip4,
1550
1587
  categoryTable as categoryTable3,
1551
1588
  chartFormatters as chartFormatters3,
1589
+ forecastStart as forecastStart2,
1590
+ forecastTagLookup as forecastTagLookup3,
1591
+ withForecastLines as withForecastLines2,
1592
+ withForecastPoints as withForecastPoints2,
1552
1593
  colorWithAlpha,
1553
1594
  generateAreaChartDescription,
1554
1595
  getChartColors as getChartColors4,
@@ -1560,6 +1601,7 @@ import {
1560
1601
  THEME_DARK as THEME_DARK3,
1561
1602
  toPercentStack as toPercentStack3,
1562
1603
  withPointLabels as withPointLabels3,
1604
+ withGhostSeries as withGhostSeries3,
1563
1605
  withReferenceMarks as withReferenceMarks3,
1564
1606
  withZoomInset as withZoomInset3
1565
1607
  } from "@classic-homes/charts-core";
@@ -1648,9 +1690,12 @@ var AreaChart = React9.forwardRef(
1648
1690
  return {
1649
1691
  name: source.name,
1650
1692
  type: "line",
1651
- data: withPointLabels3(plotted[index].data, source.labels, formatters.label, {
1652
- position: "top"
1653
- }),
1693
+ data: withForecastPoints2(
1694
+ withPointLabels3(plotted[index].data, source.labels, formatters.label, {
1695
+ position: "top"
1696
+ }),
1697
+ source
1698
+ ),
1654
1699
  smooth,
1655
1700
  connectNulls,
1656
1701
  stack: stacked ? "Total" : void 0,
@@ -1670,7 +1715,8 @@ var AreaChart = React9.forwardRef(
1670
1715
  emphasis: {
1671
1716
  focus: "series"
1672
1717
  },
1673
- showSymbol
1718
+ // Forecast points show even when the others are hidden (size 0)
1719
+ ...forecastStart2(source) === void 0 ? { showSymbol } : { showSymbol: true, symbolSize: showSymbol ? 4 : 0 }
1674
1720
  };
1675
1721
  });
1676
1722
  return mergeChartOption4(
@@ -1700,7 +1746,8 @@ var AreaChart = React9.forwardRef(
1700
1746
  show: showTooltip,
1701
1747
  formatter: tooltipFormatter,
1702
1748
  valueFormatter: formatters.tooltip,
1703
- getLabel
1749
+ getLabel,
1750
+ forecastTag: forecastTagLookup3(data.series)
1704
1751
  }
1705
1752
  ),
1706
1753
  legend: buildLegend4(
@@ -1727,12 +1774,25 @@ var AreaChart = React9.forwardRef(
1727
1774
  },
1728
1775
  formatters.axis(yAxisConfig)
1729
1776
  ),
1730
- series: withReferenceMarks3(series, referenceLines, referenceBands, {
1731
- valueAxis: "y",
1732
- format: formatters.format,
1733
- color: chartColors.reference,
1734
- bandColor: chartColors.referenceBand
1735
- })
1777
+ series: withForecastLines2(
1778
+ withReferenceMarks3(
1779
+ withGhostSeries3(series, data.series),
1780
+ referenceLines,
1781
+ referenceBands,
1782
+ {
1783
+ valueAxis: "y",
1784
+ format: formatters.format,
1785
+ color: chartColors.reference,
1786
+ bandColor: chartColors.referenceBand
1787
+ }
1788
+ ),
1789
+ data.series,
1790
+ {
1791
+ colors: data.series.map(
1792
+ (s, i) => s.color || chartColors.series[i % chartColors.series.length]
1793
+ )
1794
+ }
1795
+ )
1736
1796
  },
1737
1797
  optionOverride
1738
1798
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/charts-react",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "React ECharts components for Classic Theme",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",