@sproutsocial/seeds-react-data-viz 0.2.2 → 0.3.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/esm/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  // src/components/AreaChart/AreaChart.tsx
2
- import { memo as memo13 } from "react";
2
+ import { memo as memo14 } from "react";
3
3
  import Highcharts from "highcharts";
4
4
  import { HighchartsReact } from "highcharts-react-official";
5
5
  import highchartsAccessibility from "highcharts/modules/accessibility";
6
+ import highchartsAnnotations from "highcharts/modules/annotations";
6
7
  import styled5 from "styled-components";
7
8
  import { Box as Box9 } from "@sproutsocial/seeds-react-box";
8
9
 
@@ -405,7 +406,8 @@ var AreaChartTooltip = memo12(
405
406
  currency = "USD",
406
407
  numberFormat = "decimal",
407
408
  onClick,
408
- tooltipClickLabel
409
+ tooltipClickLabel,
410
+ xAnnotationDetails
409
411
  }) {
410
412
  const rows = data.map(({ color, icon, name, value }) => {
411
413
  return {
@@ -460,6 +462,7 @@ var AreaChartTooltip = memo12(
460
462
  }
461
463
  ] : [];
462
464
  return /* @__PURE__ */ jsxs3(ChartTooltip, { children: [
465
+ xAnnotationDetails ? xAnnotationDetails() : void 0,
463
466
  /* @__PURE__ */ jsx13(ChartTooltipTitle, { children: tooltipDateFormatter({ x }) }),
464
467
  /* @__PURE__ */ jsx13(
465
468
  ChartTooltipTable,
@@ -475,6 +478,65 @@ var AreaChartTooltip = memo12(
475
478
  }
476
479
  );
477
480
 
481
+ // src/components/ChartXAnnotationMarker/components/ChartXAnnotationMarkerPortal.tsx
482
+ import { memo as memo13, useEffect as useEffect2, useState as useState2, useRef as useRef2 } from "react";
483
+ import { createPortal as createPortal2 } from "react-dom";
484
+ import "highcharts";
485
+ import { Fragment, jsx as jsx14 } from "react/jsx-runtime";
486
+ var ChartXAnnotationMarkerPortal = memo13(
487
+ function ChartXAnnotationMarkerPortal2({
488
+ xAnnotations,
489
+ annotationContext
490
+ }) {
491
+ const annotationContainers = useRef2({});
492
+ const [renderCount, setRenderCount] = useState2(0);
493
+ const forceRender = () => setRenderCount((prev) => prev + 1);
494
+ useEffect2(() => {
495
+ if (annotationContext.labels) {
496
+ const newContainers = {};
497
+ const existingAnnotationContainers = document.querySelectorAll(
498
+ "div[data-annotation-marker='true']"
499
+ );
500
+ existingAnnotationContainers.forEach(
501
+ (annotation) => annotation.setAttribute("data-annotation-marker", "false")
502
+ );
503
+ annotationContext.labels.forEach((label) => {
504
+ const labelElement = label.graphic?.div;
505
+ if (labelElement) {
506
+ labelElement.querySelectorAll("div[data-annotation-marker]").forEach((component) => component.remove());
507
+ const annotationDiv = document.createElement("div");
508
+ annotationDiv.setAttribute("data-annotation-marker", "true");
509
+ labelElement.appendChild(annotationDiv);
510
+ const xValue = label.options?.point?.x;
511
+ newContainers[xValue] = annotationDiv;
512
+ }
513
+ });
514
+ annotationContainers.current = newContainers;
515
+ forceRender();
516
+ requestAnimationFrame(() => {
517
+ document.querySelectorAll("div.highcharts-annotation").forEach((annotationDiv) => {
518
+ const reactAnnotations = annotationDiv.querySelectorAll(
519
+ "div[data-annotation-marker]"
520
+ );
521
+ const hasActiveAnnotations = Array.from(reactAnnotations).some(
522
+ (div) => div.getAttribute("data-annotation-marker") === "true"
523
+ );
524
+ if (!hasActiveAnnotations) {
525
+ annotationDiv.remove();
526
+ }
527
+ });
528
+ });
529
+ }
530
+ }, [annotationContext.labels, xAnnotations]);
531
+ return /* @__PURE__ */ jsx14(Fragment, { children: Object.entries(annotationContainers.current).map(
532
+ ([xValue, container]) => {
533
+ const annotationComponent = xAnnotations?.[Number(xValue)]?.marker;
534
+ return annotationComponent ? createPortal2(annotationComponent(), container) : null;
535
+ }
536
+ ) });
537
+ }
538
+ );
539
+
478
540
  // src/helpers/transformDataToSeries.ts
479
541
  var transformDataToSeries = ({ data }, type) => {
480
542
  return data.map((dataItem, dataIndex) => {
@@ -619,8 +681,7 @@ var yAxisLabelFormatter = ({
619
681
  };
620
682
 
621
683
  // src/hooks/useTimeSeriesChartOptions.ts
622
- import { useState as useState2, useEffect as useEffect2, useCallback } from "react";
623
- import "highcharts";
684
+ import { useState as useState3, useCallback, useMemo } from "react";
624
685
 
625
686
  // src/constants/chartOptions.ts
626
687
  import _ from "lodash";
@@ -653,6 +714,16 @@ var baseChartOptions = {
653
714
  };
654
715
  var TIME_SERIES_CHART_HEIGHT = 275;
655
716
  var timeSeriesChartOptions = _.merge({}, baseChartOptions, {
717
+ annotations: [
718
+ {
719
+ draggable: "",
720
+ labelOptions: {
721
+ useHTML: true,
722
+ padding: 0
723
+ // removes "left" property padding created by highcharts so that label is centered
724
+ }
725
+ }
726
+ ],
656
727
  chart: {
657
728
  // events.click is set at the component level because of the optional onClick prop
658
729
  height: TIME_SERIES_CHART_HEIGHT,
@@ -661,6 +732,7 @@ var timeSeriesChartOptions = _.merge({}, baseChartOptions, {
661
732
  plotOptions: {
662
733
  series: {
663
734
  animation: false,
735
+ clip: false,
664
736
  marker: {
665
737
  enabled: false,
666
738
  states: {
@@ -730,26 +802,55 @@ var donutChartOptions = _.merge({}, baseChartOptions, {
730
802
  });
731
803
 
732
804
  // src/hooks/useTimeSeriesChartOptions.ts
805
+ import { merge } from "lodash";
733
806
  var useTimeSeriesChartOptions = ({
807
+ xAnnotations,
734
808
  data,
735
809
  numberLocale,
736
810
  seriesType,
737
811
  textLocale,
738
812
  currency = "USD",
813
+ disableTooltips = false,
739
814
  numberFormat = "decimal",
740
815
  yAxisLabelFormatter: yAxisLabelFormatter2,
741
816
  onClick,
742
817
  timeFormat = "12"
743
818
  }) => {
744
- const [options, setOptions] = useState2(
745
- seriesType === "areaspline" ? areaChartOptions : lineChartOptions
746
- );
747
- const [chart, setChart] = useState2(null);
819
+ const [chart, setChart] = useState3(null);
748
820
  const callback = useCallback((chartInstance) => {
749
821
  setChart(chartInstance);
750
822
  }, []);
751
- useEffect2(() => {
752
- setOptions({
823
+ function attachTooltipEventListeners(series, tooltipId) {
824
+ const handleFocus = (point) => point.series.chart.tooltip.refresh(point);
825
+ const handleBlur = (point) => point.series.chart.tooltip.hide(0);
826
+ series.flatMap((item) => item.data).forEach((point) => {
827
+ const pointElement = point?.graphic?.element;
828
+ if (pointElement) {
829
+ pointElement.setAttribute("aria-describedby", tooltipId);
830
+ pointElement.addEventListener("focus", () => handleFocus(point));
831
+ pointElement.addEventListener("blur", () => handleBlur(point));
832
+ }
833
+ });
834
+ }
835
+ const formattedXAnnotations = (annotations) => {
836
+ if (annotations) {
837
+ return Object.entries(annotations).map(([x]) => ({
838
+ point: {
839
+ x: Number(x),
840
+ // Convert key (which is a string) to a number
841
+ y: 0,
842
+ xAxis: 0,
843
+ yAxis: 0
844
+ },
845
+ text: " "
846
+ // space is necessary because empty string reverts to showing default label
847
+ }));
848
+ }
849
+ };
850
+ const chartMarginTop = xAnnotations ? 24 : null;
851
+ const baseChartOptions2 = seriesType === "areaspline" ? areaChartOptions : lineChartOptions;
852
+ const options = useMemo(() => {
853
+ return merge({}, baseChartOptions2, {
753
854
  accessibility: {
754
855
  point: {
755
856
  descriptionFormatter: function() {
@@ -757,24 +858,20 @@ var useTimeSeriesChartOptions = ({
757
858
  }
758
859
  }
759
860
  },
861
+ annotations: [
862
+ {
863
+ labels: xAnnotations ? formattedXAnnotations(xAnnotations) : void 0
864
+ }
865
+ ],
760
866
  chart: {
867
+ marginTop: chartMarginTop,
761
868
  events: {
762
869
  click: onClick ? function() {
763
870
  return onClick({ x: this?.hoverPoint?.x });
764
871
  } : void 0,
765
- render: function() {
766
- const allPoints = this.series.flatMap((series) => series.data);
872
+ load: function() {
767
873
  const tooltipId = generateChartTooltipPortalId(this.index);
768
- allPoints.forEach((point) => {
769
- const pointElement = point?.graphic?.element;
770
- pointElement?.setAttribute("aria-describedby", tooltipId);
771
- pointElement?.addEventListener("focus", () => {
772
- point.series.chart.tooltip.refresh(point);
773
- });
774
- pointElement?.addEventListener("blur", () => {
775
- point.series.chart.tooltip.hide(0);
776
- });
777
- });
874
+ attachTooltipEventListeners(this.series, tooltipId);
778
875
  }
779
876
  }
780
877
  },
@@ -795,6 +892,9 @@ var useTimeSeriesChartOptions = ({
795
892
  }
796
893
  },
797
894
  series: transformDataToSeries({ data }, seriesType),
895
+ tooltip: {
896
+ enabled: !disableTooltips
897
+ },
798
898
  xAxis: {
799
899
  labels: {
800
900
  formatter: function() {
@@ -827,6 +927,7 @@ var useTimeSeriesChartOptions = ({
827
927
  }
828
928
  });
829
929
  }, [
930
+ baseChartOptions2,
830
931
  currency,
831
932
  data,
832
933
  numberFormat,
@@ -835,6 +936,7 @@ var useTimeSeriesChartOptions = ({
835
936
  seriesType,
836
937
  textLocale,
837
938
  timeFormat,
939
+ xAnnotations,
838
940
  yAxisLabelFormatter2
839
941
  ]);
840
942
  return { options, chart, callback };
@@ -873,9 +975,19 @@ var baseChartStyles = css2`
873
975
  }).join("\n")}
874
976
 
875
977
  // set overall chart background color
876
- .highcharts-background {
978
+ .highcharts-background {
877
979
  fill: ${({ theme: theme14 }) => theme14.colors.container.background.base};
878
980
  }
981
+
982
+ g.highcharts-annotation-label {
983
+ display: none;
984
+ }
985
+
986
+ div.highcharts-annotation-label {
987
+ top: 0 !important;
988
+ transform: translateX(-50%); // centers the label on the targeted axis point
989
+ pointer-events: none; // prevents tooltip hover from being interrupted by this element since it renders after on the dom
990
+ }
879
991
  `;
880
992
  var timeSeriesChartStyles = css2`
881
993
  ${baseChartStyles}
@@ -985,16 +1097,17 @@ var donutChartStyles = css2`
985
1097
 
986
1098
  // src/components/AreaChart/AreaChart.tsx
987
1099
  import { theme as theme7 } from "@sproutsocial/seeds-react-theme";
988
- import { Fragment, jsx as jsx14, jsxs as jsxs4 } from "react/jsx-runtime";
1100
+ import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs4 } from "react/jsx-runtime";
989
1101
  highchartsAccessibility(Highcharts);
1102
+ highchartsAnnotations(Highcharts);
990
1103
  var StyledBox3 = styled5(Box9)`
991
1104
  ${areaChartStyles}
992
1105
  `;
993
- var AreaChart = memo13(function AreaChart2(props) {
1106
+ var AreaChart = memo14(function AreaChart2(props) {
994
1107
  const { data } = props;
995
- return data.length === 0 ? null : /* @__PURE__ */ jsx14(AreaChartWithData, { ...props });
1108
+ return data.length === 0 ? null : /* @__PURE__ */ jsx15(AreaChartWithData, { ...props });
996
1109
  });
997
- var AreaChartWithData = memo13(function AreaChartWithData2({
1110
+ var AreaChartWithData = memo14(function AreaChartWithData2({
998
1111
  data,
999
1112
  invalidNumberLabel,
1000
1113
  numberLocale = "en-us",
@@ -1003,29 +1116,33 @@ var AreaChartWithData = memo13(function AreaChartWithData2({
1003
1116
  tooltipTotalLabel,
1004
1117
  // optional
1005
1118
  currency = "USD",
1119
+ disableTooltips = false,
1006
1120
  numberFormat = "decimal",
1007
1121
  tooltip,
1008
1122
  yAxisLabelFormatter: yAxisLabelFormatter2,
1009
1123
  onClick,
1010
1124
  tooltipClickLabel,
1011
- timeFormat = "12"
1125
+ timeFormat = "12",
1126
+ xAnnotations
1012
1127
  }) {
1013
1128
  const { options, chart, callback } = useTimeSeriesChartOptions({
1014
1129
  currency,
1015
1130
  data,
1131
+ disableTooltips,
1016
1132
  numberFormat,
1017
1133
  numberLocale,
1018
1134
  seriesType: "areaspline",
1019
1135
  textLocale,
1020
1136
  yAxisLabelFormatter: yAxisLabelFormatter2,
1021
1137
  onClick,
1022
- timeFormat
1138
+ timeFormat,
1139
+ xAnnotations
1023
1140
  });
1024
1141
  const colors = data.map(
1025
1142
  (series, index) => series.styles?.color ?? theme7.colors.DATAVIZ_COLORS_LIST[index]
1026
1143
  );
1027
- return /* @__PURE__ */ jsxs4(Fragment, { children: [
1028
- /* @__PURE__ */ jsx14(GlobalChartStyleOverrides, {}),
1144
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
1145
+ /* @__PURE__ */ jsx15(GlobalChartStyleOverrides, {}),
1029
1146
  /* @__PURE__ */ jsxs4(
1030
1147
  StyledBox3,
1031
1148
  {
@@ -1033,7 +1150,7 @@ var AreaChartWithData = memo13(function AreaChartWithData2({
1033
1150
  $hasOnClick: Boolean(onClick),
1034
1151
  bg: "container.background.base",
1035
1152
  children: [
1036
- /* @__PURE__ */ jsx14(
1153
+ /* @__PURE__ */ jsx15(
1037
1154
  HighchartsReact,
1038
1155
  {
1039
1156
  highcharts: Highcharts,
@@ -1041,7 +1158,14 @@ var AreaChartWithData = memo13(function AreaChartWithData2({
1041
1158
  callback
1042
1159
  }
1043
1160
  ),
1044
- chart ? /* @__PURE__ */ jsx14(
1161
+ chart && chart.annotations?.length ? /* @__PURE__ */ jsx15(
1162
+ ChartXAnnotationMarkerPortal,
1163
+ {
1164
+ xAnnotations,
1165
+ annotationContext: chart.annotations?.[0]
1166
+ }
1167
+ ) : null,
1168
+ chart && !disableTooltips ? /* @__PURE__ */ jsx15(
1045
1169
  ChartTooltipPortal,
1046
1170
  {
1047
1171
  chart,
@@ -1052,7 +1176,8 @@ var AreaChartWithData = memo13(function AreaChartWithData2({
1052
1176
  });
1053
1177
  const x = context.x;
1054
1178
  const total = context.total;
1055
- return tooltip ? tooltip({ data: tooltipData, total, x }) : /* @__PURE__ */ jsx14(
1179
+ const xAnnotationDetails = xAnnotations?.[x]?.details;
1180
+ return tooltip ? tooltip({ data: tooltipData, total, x }) : /* @__PURE__ */ jsx15(
1056
1181
  AreaChartTooltip,
1057
1182
  {
1058
1183
  currency,
@@ -1066,13 +1191,14 @@ var AreaChartWithData = memo13(function AreaChartWithData2({
1066
1191
  total,
1067
1192
  x,
1068
1193
  onClick,
1069
- tooltipClickLabel
1194
+ tooltipClickLabel,
1195
+ xAnnotationDetails
1070
1196
  }
1071
1197
  );
1072
1198
  }
1073
1199
  }
1074
1200
  ) : null,
1075
- /* @__PURE__ */ jsx14(Box9, { mt: 350, children: /* @__PURE__ */ jsx14(AreaChartLegend, { data }) })
1201
+ /* @__PURE__ */ jsx15(Box9, { mt: 350, children: /* @__PURE__ */ jsx15(AreaChartLegend, { data }) })
1076
1202
  ]
1077
1203
  }
1078
1204
  )
@@ -1080,7 +1206,7 @@ var AreaChartWithData = memo13(function AreaChartWithData2({
1080
1206
  });
1081
1207
 
1082
1208
  // src/components/DonutChart/DonutChart.tsx
1083
- import { memo as memo16, useState as useState3, useEffect as useEffect3, useCallback as useCallback2 } from "react";
1209
+ import { memo as memo17, useState as useState4, useEffect as useEffect3, useCallback as useCallback2 } from "react";
1084
1210
  import Highcharts2 from "highcharts";
1085
1211
  import { HighchartsReact as HighchartsReact2 } from "highcharts-react-official";
1086
1212
  import highchartsAccessibility2 from "highcharts/modules/accessibility";
@@ -1088,31 +1214,31 @@ import styled6 from "styled-components";
1088
1214
  import { Box as Box11 } from "@sproutsocial/seeds-react-box";
1089
1215
 
1090
1216
  // src/components/DonutChart/components/DonutChartLegend.tsx
1091
- import { memo as memo14 } from "react";
1217
+ import { memo as memo15 } from "react";
1092
1218
  import { theme as theme8 } from "@sproutsocial/seeds-react-theme";
1093
- import { jsx as jsx15 } from "react/jsx-runtime";
1219
+ import { jsx as jsx16 } from "react/jsx-runtime";
1094
1220
  var getDonutChartLegendLabels = ({
1095
1221
  data
1096
1222
  }) => {
1097
1223
  return data.map((slice, index) => ({
1098
- content: /* @__PURE__ */ jsx15(ChartLegendLabelContentWithIcon, { icon: slice.icon, children: slice.name }),
1224
+ content: /* @__PURE__ */ jsx16(ChartLegendLabelContentWithIcon, { icon: slice.icon, children: slice.name }),
1099
1225
  color: slice.styles?.color || theme8.colors.DATAVIZ_COLORS_LIST[index]
1100
1226
  }));
1101
1227
  };
1102
- var DonutChartLegend = memo14(
1228
+ var DonutChartLegend = memo15(
1103
1229
  function DonutChartLegend2({ data }) {
1104
- return /* @__PURE__ */ jsx15(ChartLegend, { legendLabels: getDonutChartLegendLabels({ data }) });
1230
+ return /* @__PURE__ */ jsx16(ChartLegend, { legendLabels: getDonutChartLegendLabels({ data }) });
1105
1231
  }
1106
1232
  );
1107
1233
 
1108
1234
  // src/components/DonutChart/components/DonutChartTooltip.tsx
1109
- import { memo as memo15 } from "react";
1235
+ import { memo as memo16 } from "react";
1110
1236
  import { Box as Box10 } from "@sproutsocial/seeds-react-box";
1111
1237
  import { Duration as Duration2 } from "@sproutsocial/seeds-react-duration";
1112
1238
  import { Numeral as Numeral2 } from "@sproutsocial/seeds-react-numeral";
1113
1239
  import { Text as Text5 } from "@sproutsocial/seeds-react-text";
1114
- import { jsx as jsx16, jsxs as jsxs5 } from "react/jsx-runtime";
1115
- var DonutChartTooltip = memo15(
1240
+ import { jsx as jsx17, jsxs as jsxs5 } from "react/jsx-runtime";
1241
+ var DonutChartTooltip = memo16(
1116
1242
  function DonutChartTooltip2({
1117
1243
  color,
1118
1244
  name,
@@ -1128,11 +1254,11 @@ var DonutChartTooltip = memo15(
1128
1254
  {
1129
1255
  cells: [
1130
1256
  {
1131
- content: /* @__PURE__ */ jsx16(ChartLegendLabel, { color, children: /* @__PURE__ */ jsx16(ChartLegendLabelContentWithIcon, { icon, children: /* @__PURE__ */ jsx16(Text5, { "aria-label": `${name}: `, children: name }) }) })
1257
+ content: /* @__PURE__ */ jsx17(ChartLegendLabel, { color, children: /* @__PURE__ */ jsx17(ChartLegendLabelContentWithIcon, { icon, children: /* @__PURE__ */ jsx17(Text5, { "aria-label": `${name}: `, children: name }) }) })
1132
1258
  },
1133
1259
  {
1134
1260
  content: /* @__PURE__ */ jsxs5(Box10, { display: "inline-flex", alignItems: "center", gap: 350, children: [
1135
- /* @__PURE__ */ jsx16(
1261
+ /* @__PURE__ */ jsx17(
1136
1262
  Numeral2,
1137
1263
  {
1138
1264
  number: percent,
@@ -1141,7 +1267,7 @@ var DonutChartTooltip = memo15(
1141
1267
  locale: numberLocale
1142
1268
  }
1143
1269
  ),
1144
- /* @__PURE__ */ jsx16(Text5, { fontWeight: "semibold", children: numberFormat === "duration" ? /* @__PURE__ */ jsx16(Duration2, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ jsx16(
1270
+ /* @__PURE__ */ jsx17(Text5, { fontWeight: "semibold", children: numberFormat === "duration" ? /* @__PURE__ */ jsx17(Duration2, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ jsx17(
1145
1271
  Numeral2,
1146
1272
  {
1147
1273
  abbreviate: false,
@@ -1157,7 +1283,7 @@ var DonutChartTooltip = memo15(
1157
1283
  ]
1158
1284
  }
1159
1285
  ];
1160
- return /* @__PURE__ */ jsx16(ChartTooltip, { children: /* @__PURE__ */ jsx16(ChartTooltipTable, { rows }) });
1286
+ return /* @__PURE__ */ jsx17(ChartTooltip, { children: /* @__PURE__ */ jsx17(ChartTooltipTable, { rows }) });
1161
1287
  }
1162
1288
  );
1163
1289
 
@@ -1179,28 +1305,29 @@ var transformDonutChartTooltipData = ({
1179
1305
 
1180
1306
  // src/components/DonutChart/DonutChart.tsx
1181
1307
  import { theme as theme10 } from "@sproutsocial/seeds-react-theme";
1182
- import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs6 } from "react/jsx-runtime";
1308
+ import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
1183
1309
  highchartsAccessibility2(Highcharts2);
1184
1310
  var StyledBox4 = styled6(Box11)`
1185
1311
  ${donutChartStyles}
1186
1312
  `;
1187
- var DonutChart = memo16(function DonutChart2(props) {
1313
+ var DonutChart = memo17(function DonutChart2(props) {
1188
1314
  const { data } = props;
1189
- return data.length === 0 ? null : /* @__PURE__ */ jsx17(DonutChartWithData, { ...props });
1315
+ return data.length === 0 ? null : /* @__PURE__ */ jsx18(DonutChartWithData, { ...props });
1190
1316
  });
1191
- var DonutChartWithData = memo16(
1317
+ var DonutChartWithData = memo17(
1192
1318
  function DonutChartWithData2({
1193
1319
  data,
1194
1320
  numberLocale = "en-us",
1195
1321
  textLocale = "en-us",
1196
1322
  // optional
1197
1323
  currency = "USD",
1324
+ disableTooltips = false,
1198
1325
  hideLegend = false,
1199
1326
  numberFormat = "decimal",
1200
1327
  tooltip
1201
1328
  }) {
1202
- const [options, setOptions] = useState3(donutChartOptions);
1203
- const [chart, setChart] = useState3(null);
1329
+ const [options, setOptions] = useState4(donutChartOptions);
1330
+ const [chart, setChart] = useState4(null);
1204
1331
  const callback = useCallback2((chartInstance) => {
1205
1332
  setChart(chartInstance);
1206
1333
  }, []);
@@ -1242,16 +1369,19 @@ var DonutChartWithData = memo16(
1242
1369
  };
1243
1370
  })
1244
1371
  }
1245
- ]
1372
+ ],
1373
+ tooltip: {
1374
+ enabled: !disableTooltips
1375
+ }
1246
1376
  });
1247
1377
  }, [data]);
1248
1378
  const colors = data.map(
1249
1379
  (series, index) => series.styles?.color ?? theme10.colors.DATAVIZ_COLORS_LIST[index] ?? ""
1250
1380
  );
1251
- return /* @__PURE__ */ jsxs6(Fragment2, { children: [
1252
- /* @__PURE__ */ jsx17(GlobalChartStyleOverrides, {}),
1381
+ return /* @__PURE__ */ jsxs6(Fragment3, { children: [
1382
+ /* @__PURE__ */ jsx18(GlobalChartStyleOverrides, {}),
1253
1383
  /* @__PURE__ */ jsxs6(StyledBox4, { $colors: colors, bg: "container.background.base", children: [
1254
- /* @__PURE__ */ jsx17(
1384
+ /* @__PURE__ */ jsx18(
1255
1385
  HighchartsReact2,
1256
1386
  {
1257
1387
  highcharts: Highcharts2,
@@ -1259,13 +1389,13 @@ var DonutChartWithData = memo16(
1259
1389
  callback
1260
1390
  }
1261
1391
  ),
1262
- chart ? /* @__PURE__ */ jsx17(
1392
+ chart && !disableTooltips ? /* @__PURE__ */ jsx18(
1263
1393
  ChartTooltipPortal,
1264
1394
  {
1265
1395
  chart,
1266
1396
  renderContent: (context) => {
1267
1397
  const { color, icon, name, percent, value } = transformDonutChartTooltipData({ context, data });
1268
- return tooltip ? tooltip({ color, icon, name, percent, value }) : /* @__PURE__ */ jsx17(
1398
+ return tooltip ? tooltip({ color, icon, name, percent, value }) : /* @__PURE__ */ jsx18(
1269
1399
  DonutChartTooltip,
1270
1400
  {
1271
1401
  color,
@@ -1282,21 +1412,21 @@ var DonutChartWithData = memo16(
1282
1412
  }
1283
1413
  }
1284
1414
  ) : null,
1285
- hideLegend ? null : /* @__PURE__ */ jsx17(Box11, { mt: 350, children: /* @__PURE__ */ jsx17(DonutChartLegend, { data }) })
1415
+ hideLegend ? null : /* @__PURE__ */ jsx18(Box11, { mt: 350, children: /* @__PURE__ */ jsx18(DonutChartLegend, { data }) })
1286
1416
  ] })
1287
1417
  ] });
1288
1418
  }
1289
1419
  );
1290
1420
 
1291
1421
  // src/components/DonutChart/components/DonutChartLegendTable.tsx
1292
- import { memo as memo17 } from "react";
1422
+ import { memo as memo18 } from "react";
1293
1423
  import { Box as Box12 } from "@sproutsocial/seeds-react-box";
1294
1424
  import { Duration as Duration3 } from "@sproutsocial/seeds-react-duration";
1295
1425
  import { Numeral as Numeral3 } from "@sproutsocial/seeds-react-numeral";
1296
1426
  import { Text as Text6 } from "@sproutsocial/seeds-react-text";
1297
1427
  import { theme as theme11 } from "@sproutsocial/seeds-react-theme";
1298
- import { jsx as jsx18, jsxs as jsxs7 } from "react/jsx-runtime";
1299
- var DonutChartLegendTable = memo17(
1428
+ import { jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
1429
+ var DonutChartLegendTable = memo18(
1300
1430
  function DonutChartLegendTable2({
1301
1431
  data,
1302
1432
  numberLocale = "en-us",
@@ -1316,11 +1446,11 @@ var DonutChartLegendTable = memo17(
1316
1446
  return {
1317
1447
  cells: [
1318
1448
  {
1319
- content: /* @__PURE__ */ jsx18(ChartLegendLabel, { color, children: /* @__PURE__ */ jsx18(ChartLegendLabelContentWithIcon, { icon, children: name }) })
1449
+ content: /* @__PURE__ */ jsx19(ChartLegendLabel, { color, children: /* @__PURE__ */ jsx19(ChartLegendLabelContentWithIcon, { icon, children: name }) })
1320
1450
  },
1321
1451
  {
1322
1452
  content: /* @__PURE__ */ jsxs7(Box12, { display: "inline-flex", alignItems: "center", gap: 350, children: [
1323
- /* @__PURE__ */ jsx18(Text6, { color: "text.body", children: /* @__PURE__ */ jsx18(
1453
+ /* @__PURE__ */ jsx19(Text6, { color: "text.body", children: /* @__PURE__ */ jsx19(
1324
1454
  Numeral3,
1325
1455
  {
1326
1456
  abbreviate: false,
@@ -1329,7 +1459,7 @@ var DonutChartLegendTable = memo17(
1329
1459
  number: value / total * 100
1330
1460
  }
1331
1461
  ) }),
1332
- /* @__PURE__ */ jsx18(Text6, { color: "text.body", fontWeight: "semibold", children: numberFormat === "duration" ? /* @__PURE__ */ jsx18(Duration3, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ jsx18(
1462
+ /* @__PURE__ */ jsx19(Text6, { color: "text.body", fontWeight: "semibold", children: numberFormat === "duration" ? /* @__PURE__ */ jsx19(Duration3, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ jsx19(
1333
1463
  Numeral3,
1334
1464
  {
1335
1465
  abbreviate: false,
@@ -1349,10 +1479,10 @@ var DonutChartLegendTable = memo17(
1349
1479
  {
1350
1480
  cells: [
1351
1481
  {
1352
- content: /* @__PURE__ */ jsx18(Text6, { fontWeight: "semibold", color: "text.headline", children: totalLabel })
1482
+ content: /* @__PURE__ */ jsx19(Text6, { fontWeight: "semibold", color: "text.headline", children: totalLabel })
1353
1483
  },
1354
1484
  {
1355
- content: /* @__PURE__ */ jsx18(Text6, { color: "text.body", fontWeight: "bold", children: numberFormat === "duration" ? /* @__PURE__ */ jsx18(Duration3, { locale: textLocale, milliseconds: total }) : /* @__PURE__ */ jsx18(
1485
+ content: /* @__PURE__ */ jsx19(Text6, { color: "text.body", fontWeight: "bold", children: numberFormat === "duration" ? /* @__PURE__ */ jsx19(Duration3, { locale: textLocale, milliseconds: total }) : /* @__PURE__ */ jsx19(
1356
1486
  Numeral3,
1357
1487
  {
1358
1488
  abbreviate: false,
@@ -1368,7 +1498,7 @@ var DonutChartLegendTable = memo17(
1368
1498
  isAppendedRow: true
1369
1499
  }
1370
1500
  ];
1371
- return /* @__PURE__ */ jsx18(
1501
+ return /* @__PURE__ */ jsx19(
1372
1502
  ChartTable,
1373
1503
  {
1374
1504
  rows: [...rows, ...totalRow]
@@ -1378,40 +1508,41 @@ var DonutChartLegendTable = memo17(
1378
1508
  );
1379
1509
 
1380
1510
  // src/components/LineChart/LineChart.tsx
1381
- import { memo as memo20 } from "react";
1511
+ import { memo as memo21 } from "react";
1382
1512
  import Highcharts3 from "highcharts";
1383
1513
  import { HighchartsReact as HighchartsReact3 } from "highcharts-react-official";
1384
1514
  import highchartsAccessibility3 from "highcharts/modules/accessibility";
1515
+ import highchartsAnnotations2 from "highcharts/modules/annotations";
1385
1516
  import styled7 from "styled-components";
1386
1517
  import { Box as Box14 } from "@sproutsocial/seeds-react-box";
1387
1518
 
1388
1519
  // src/components/LineChart/components/LineChartLegend.tsx
1389
- import { memo as memo18 } from "react";
1520
+ import { memo as memo19 } from "react";
1390
1521
  import { theme as theme12 } from "@sproutsocial/seeds-react-theme";
1391
- import { jsx as jsx19 } from "react/jsx-runtime";
1522
+ import { jsx as jsx20 } from "react/jsx-runtime";
1392
1523
  var getLineChartLegendLabels = ({
1393
1524
  data
1394
1525
  }) => {
1395
1526
  return data.map((series, index) => ({
1396
- content: /* @__PURE__ */ jsx19(ChartLegendLabelContentWithIcon, { icon: series.icon, children: series.name }),
1527
+ content: /* @__PURE__ */ jsx20(ChartLegendLabelContentWithIcon, { icon: series.icon, children: series.name }),
1397
1528
  color: series.styles?.color || theme12.colors.DATAVIZ_COLORS_LIST[index]
1398
1529
  }));
1399
1530
  };
1400
- var LineChartLegend = memo18(
1531
+ var LineChartLegend = memo19(
1401
1532
  function LineChartLegend2({ data }) {
1402
- return /* @__PURE__ */ jsx19(ChartLegend, { legendLabels: getLineChartLegendLabels({ data }) });
1533
+ return /* @__PURE__ */ jsx20(ChartLegend, { legendLabels: getLineChartLegendLabels({ data }) });
1403
1534
  }
1404
1535
  );
1405
1536
 
1406
1537
  // src/components/LineChart/components/LineChartTooltip.tsx
1407
- import { memo as memo19 } from "react";
1538
+ import { memo as memo20 } from "react";
1408
1539
  import { Box as Box13 } from "@sproutsocial/seeds-react-box";
1409
1540
  import { Duration as Duration4 } from "@sproutsocial/seeds-react-duration";
1410
1541
  import { Icon as Icon2 } from "@sproutsocial/seeds-react-icon";
1411
1542
  import { Numeral as Numeral4 } from "@sproutsocial/seeds-react-numeral";
1412
1543
  import { Text as Text7 } from "@sproutsocial/seeds-react-text";
1413
- import { jsx as jsx20, jsxs as jsxs8 } from "react/jsx-runtime";
1414
- var LineChartTooltip = memo19(
1544
+ import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
1545
+ var LineChartTooltip = memo20(
1415
1546
  function LineChartTooltip2({
1416
1547
  data,
1417
1548
  invalidNumberLabel,
@@ -1423,16 +1554,17 @@ var LineChartTooltip = memo19(
1423
1554
  currency = "USD",
1424
1555
  numberFormat = "decimal",
1425
1556
  onClick,
1426
- tooltipClickLabel
1557
+ tooltipClickLabel,
1558
+ xAnnotationDetails
1427
1559
  }) {
1428
1560
  const rows = data.map(({ color, icon, name, value }) => {
1429
1561
  return {
1430
1562
  cells: [
1431
1563
  {
1432
- content: /* @__PURE__ */ jsx20(ChartLegendLabel, { color, children: /* @__PURE__ */ jsx20(ChartLegendLabelContentWithIcon, { icon, children: /* @__PURE__ */ jsx20(Text7, { "aria-label": `${name}: `, children: name }) }) })
1564
+ content: /* @__PURE__ */ jsx21(ChartLegendLabel, { color, children: /* @__PURE__ */ jsx21(ChartLegendLabelContentWithIcon, { icon, children: /* @__PURE__ */ jsx21(Text7, { "aria-label": `${name}: `, children: name }) }) })
1433
1565
  },
1434
1566
  {
1435
- content: value === null && invalidNumberLabel ? /* @__PURE__ */ jsx20(Text7, { children: invalidNumberLabel }) : numberFormat === "duration" ? /* @__PURE__ */ jsx20(Duration4, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ jsx20(
1567
+ content: value === null && invalidNumberLabel ? /* @__PURE__ */ jsx21(Text7, { children: invalidNumberLabel }) : numberFormat === "duration" ? /* @__PURE__ */ jsx21(Duration4, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ jsx21(
1436
1568
  Numeral4,
1437
1569
  {
1438
1570
  abbreviate: false,
@@ -1448,11 +1580,12 @@ var LineChartTooltip = memo19(
1448
1580
  };
1449
1581
  });
1450
1582
  return /* @__PURE__ */ jsxs8(ChartTooltip, { children: [
1451
- /* @__PURE__ */ jsx20(ChartTooltipTitle, { children: tooltipDateFormatter({ x }) }),
1452
- /* @__PURE__ */ jsx20(ChartTooltipTable, { rows }),
1453
- onClick && tooltipClickLabel ? /* @__PURE__ */ jsx20(ChartTooltipFooter, { children: typeof tooltipClickLabel === "string" ? /* @__PURE__ */ jsxs8(Box13, { display: "flex", alignItems: "center", gap: 300, children: [
1454
- /* @__PURE__ */ jsx20(Icon2, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
1455
- /* @__PURE__ */ jsx20(Text7, { color: "text.subtext", fontSize: 200, children: tooltipClickLabel })
1583
+ xAnnotationDetails ? xAnnotationDetails() : void 0,
1584
+ /* @__PURE__ */ jsx21(ChartTooltipTitle, { children: tooltipDateFormatter({ x }) }),
1585
+ /* @__PURE__ */ jsx21(ChartTooltipTable, { rows }),
1586
+ onClick && tooltipClickLabel ? /* @__PURE__ */ jsx21(ChartTooltipFooter, { children: typeof tooltipClickLabel === "string" ? /* @__PURE__ */ jsxs8(Box13, { display: "flex", alignItems: "center", gap: 300, children: [
1587
+ /* @__PURE__ */ jsx21(Icon2, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
1588
+ /* @__PURE__ */ jsx21(Text7, { color: "text.subtext", fontSize: 200, children: tooltipClickLabel })
1456
1589
  ] }) : tooltipClickLabel }) : null
1457
1590
  ] });
1458
1591
  }
@@ -1460,16 +1593,17 @@ var LineChartTooltip = memo19(
1460
1593
 
1461
1594
  // src/components/LineChart/LineChart.tsx
1462
1595
  import { theme as theme13 } from "@sproutsocial/seeds-react-theme";
1463
- import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
1596
+ import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
1464
1597
  highchartsAccessibility3(Highcharts3);
1598
+ highchartsAnnotations2(Highcharts3);
1465
1599
  var StyledBox5 = styled7(Box14)`
1466
1600
  ${lineChartStyles}
1467
1601
  `;
1468
- var LineChart = memo20(function LineChart2(props) {
1602
+ var LineChart = memo21(function LineChart2(props) {
1469
1603
  const { data } = props;
1470
- return data.length === 0 ? null : /* @__PURE__ */ jsx21(LineChartWithData, { ...props });
1604
+ return data.length === 0 ? null : /* @__PURE__ */ jsx22(LineChartWithData, { ...props });
1471
1605
  });
1472
- var LineChartWithData = memo20(function LineChartWithData2({
1606
+ var LineChartWithData = memo21(function LineChartWithData2({
1473
1607
  data,
1474
1608
  invalidNumberLabel,
1475
1609
  numberLocale = "en-us",
@@ -1477,23 +1611,27 @@ var LineChartWithData = memo20(function LineChartWithData2({
1477
1611
  tooltipDateFormatter,
1478
1612
  // optional
1479
1613
  currency = "USD",
1614
+ disableTooltips = false,
1480
1615
  numberFormat = "decimal",
1481
1616
  tooltip,
1482
1617
  yAxisLabelFormatter: yAxisLabelFormatter2,
1483
1618
  onClick,
1484
1619
  tooltipClickLabel,
1485
- timeFormat = "12"
1620
+ timeFormat = "12",
1621
+ xAnnotations
1486
1622
  }) {
1487
1623
  const { options, chart, callback } = useTimeSeriesChartOptions({
1488
1624
  currency,
1489
1625
  data,
1626
+ disableTooltips,
1490
1627
  numberFormat,
1491
1628
  numberLocale,
1492
1629
  seriesType: "spline",
1493
1630
  textLocale,
1494
1631
  yAxisLabelFormatter: yAxisLabelFormatter2,
1495
1632
  onClick,
1496
- timeFormat
1633
+ timeFormat,
1634
+ xAnnotations
1497
1635
  });
1498
1636
  const { colors, patterns } = data.reduce(
1499
1637
  (acc, item, index) => {
@@ -1508,8 +1646,8 @@ var LineChartWithData = memo20(function LineChartWithData2({
1508
1646
  patterns: []
1509
1647
  }
1510
1648
  );
1511
- return /* @__PURE__ */ jsxs9(Fragment3, { children: [
1512
- /* @__PURE__ */ jsx21(GlobalChartStyleOverrides, {}),
1649
+ return /* @__PURE__ */ jsxs9(Fragment4, { children: [
1650
+ /* @__PURE__ */ jsx22(GlobalChartStyleOverrides, {}),
1513
1651
  /* @__PURE__ */ jsxs9(
1514
1652
  StyledBox5,
1515
1653
  {
@@ -1518,7 +1656,7 @@ var LineChartWithData = memo20(function LineChartWithData2({
1518
1656
  $hasOnClick: Boolean(onClick),
1519
1657
  bg: "container.background.base",
1520
1658
  children: [
1521
- /* @__PURE__ */ jsx21(
1659
+ /* @__PURE__ */ jsx22(
1522
1660
  HighchartsReact3,
1523
1661
  {
1524
1662
  highcharts: Highcharts3,
@@ -1526,7 +1664,14 @@ var LineChartWithData = memo20(function LineChartWithData2({
1526
1664
  callback
1527
1665
  }
1528
1666
  ),
1529
- chart ? /* @__PURE__ */ jsx21(
1667
+ chart && chart.annotations?.length ? /* @__PURE__ */ jsx22(
1668
+ ChartXAnnotationMarkerPortal,
1669
+ {
1670
+ xAnnotations,
1671
+ annotationContext: chart.annotations?.[0]
1672
+ }
1673
+ ) : null,
1674
+ chart && !disableTooltips ? /* @__PURE__ */ jsx22(
1530
1675
  ChartTooltipPortal,
1531
1676
  {
1532
1677
  chart,
@@ -1536,7 +1681,8 @@ var LineChartWithData = memo20(function LineChartWithData2({
1536
1681
  data
1537
1682
  });
1538
1683
  const x = context.x;
1539
- return tooltip ? tooltip({ data: tooltipData, x }) : /* @__PURE__ */ jsx21(
1684
+ const xAnnotationDetails = xAnnotations?.[x]?.details;
1685
+ return tooltip ? tooltip({ data: tooltipData, x }) : /* @__PURE__ */ jsx22(
1540
1686
  LineChartTooltip,
1541
1687
  {
1542
1688
  currency,
@@ -1546,15 +1692,16 @@ var LineChartWithData = memo20(function LineChartWithData2({
1546
1692
  numberLocale,
1547
1693
  textLocale,
1548
1694
  tooltipDateFormatter,
1549
- x,
1550
1695
  onClick,
1551
- tooltipClickLabel
1696
+ tooltipClickLabel,
1697
+ x,
1698
+ xAnnotationDetails
1552
1699
  }
1553
1700
  );
1554
1701
  }
1555
1702
  }
1556
1703
  ) : null,
1557
- /* @__PURE__ */ jsx21(Box14, { mt: 350, children: /* @__PURE__ */ jsx21(LineChartLegend, { data }) })
1704
+ /* @__PURE__ */ jsx22(Box14, { mt: 350, children: /* @__PURE__ */ jsx22(LineChartLegend, { data }) })
1558
1705
  ]
1559
1706
  }
1560
1707
  )