@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 +249 -102
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +258 -111
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -72,10 +72,11 @@ __export(index_exports, {
|
|
|
72
72
|
module.exports = __toCommonJS(index_exports);
|
|
73
73
|
|
|
74
74
|
// src/components/AreaChart/AreaChart.tsx
|
|
75
|
-
var
|
|
75
|
+
var import_react16 = require("react");
|
|
76
76
|
var import_highcharts3 = __toESM(require("highcharts"));
|
|
77
77
|
var import_highcharts_react_official = require("highcharts-react-official");
|
|
78
78
|
var import_accessibility = __toESM(require("highcharts/modules/accessibility"));
|
|
79
|
+
var import_annotations = __toESM(require("highcharts/modules/annotations"));
|
|
79
80
|
var import_styled_components8 = __toESM(require("styled-components"));
|
|
80
81
|
var import_seeds_react_box9 = require("@sproutsocial/seeds-react-box");
|
|
81
82
|
|
|
@@ -478,7 +479,8 @@ var AreaChartTooltip = (0, import_react13.memo)(
|
|
|
478
479
|
currency = "USD",
|
|
479
480
|
numberFormat = "decimal",
|
|
480
481
|
onClick,
|
|
481
|
-
tooltipClickLabel
|
|
482
|
+
tooltipClickLabel,
|
|
483
|
+
xAnnotationDetails
|
|
482
484
|
}) {
|
|
483
485
|
const rows = data.map(({ color, icon, name, value }) => {
|
|
484
486
|
return {
|
|
@@ -533,6 +535,7 @@ var AreaChartTooltip = (0, import_react13.memo)(
|
|
|
533
535
|
}
|
|
534
536
|
] : [];
|
|
535
537
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(ChartTooltip, { children: [
|
|
538
|
+
xAnnotationDetails ? xAnnotationDetails() : void 0,
|
|
536
539
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartTooltipTitle, { children: tooltipDateFormatter({ x }) }),
|
|
537
540
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
538
541
|
ChartTooltipTable,
|
|
@@ -548,6 +551,65 @@ var AreaChartTooltip = (0, import_react13.memo)(
|
|
|
548
551
|
}
|
|
549
552
|
);
|
|
550
553
|
|
|
554
|
+
// src/components/ChartXAnnotationMarker/components/ChartXAnnotationMarkerPortal.tsx
|
|
555
|
+
var import_react14 = require("react");
|
|
556
|
+
var import_react_dom2 = require("react-dom");
|
|
557
|
+
var import_highcharts = require("highcharts");
|
|
558
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
559
|
+
var ChartXAnnotationMarkerPortal = (0, import_react14.memo)(
|
|
560
|
+
function ChartXAnnotationMarkerPortal2({
|
|
561
|
+
xAnnotations,
|
|
562
|
+
annotationContext
|
|
563
|
+
}) {
|
|
564
|
+
const annotationContainers = (0, import_react14.useRef)({});
|
|
565
|
+
const [renderCount, setRenderCount] = (0, import_react14.useState)(0);
|
|
566
|
+
const forceRender = () => setRenderCount((prev) => prev + 1);
|
|
567
|
+
(0, import_react14.useEffect)(() => {
|
|
568
|
+
if (annotationContext.labels) {
|
|
569
|
+
const newContainers = {};
|
|
570
|
+
const existingAnnotationContainers = document.querySelectorAll(
|
|
571
|
+
"div[data-annotation-marker='true']"
|
|
572
|
+
);
|
|
573
|
+
existingAnnotationContainers.forEach(
|
|
574
|
+
(annotation) => annotation.setAttribute("data-annotation-marker", "false")
|
|
575
|
+
);
|
|
576
|
+
annotationContext.labels.forEach((label) => {
|
|
577
|
+
const labelElement = label.graphic?.div;
|
|
578
|
+
if (labelElement) {
|
|
579
|
+
labelElement.querySelectorAll("div[data-annotation-marker]").forEach((component) => component.remove());
|
|
580
|
+
const annotationDiv = document.createElement("div");
|
|
581
|
+
annotationDiv.setAttribute("data-annotation-marker", "true");
|
|
582
|
+
labelElement.appendChild(annotationDiv);
|
|
583
|
+
const xValue = label.options?.point?.x;
|
|
584
|
+
newContainers[xValue] = annotationDiv;
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
annotationContainers.current = newContainers;
|
|
588
|
+
forceRender();
|
|
589
|
+
requestAnimationFrame(() => {
|
|
590
|
+
document.querySelectorAll("div.highcharts-annotation").forEach((annotationDiv) => {
|
|
591
|
+
const reactAnnotations = annotationDiv.querySelectorAll(
|
|
592
|
+
"div[data-annotation-marker]"
|
|
593
|
+
);
|
|
594
|
+
const hasActiveAnnotations = Array.from(reactAnnotations).some(
|
|
595
|
+
(div) => div.getAttribute("data-annotation-marker") === "true"
|
|
596
|
+
);
|
|
597
|
+
if (!hasActiveAnnotations) {
|
|
598
|
+
annotationDiv.remove();
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}, [annotationContext.labels, xAnnotations]);
|
|
604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: Object.entries(annotationContainers.current).map(
|
|
605
|
+
([xValue, container]) => {
|
|
606
|
+
const annotationComponent = xAnnotations?.[Number(xValue)]?.marker;
|
|
607
|
+
return annotationComponent ? (0, import_react_dom2.createPortal)(annotationComponent(), container) : null;
|
|
608
|
+
}
|
|
609
|
+
) });
|
|
610
|
+
}
|
|
611
|
+
);
|
|
612
|
+
|
|
551
613
|
// src/helpers/transformDataToSeries.ts
|
|
552
614
|
var transformDataToSeries = ({ data }, type) => {
|
|
553
615
|
return data.map((dataItem, dataIndex) => {
|
|
@@ -692,8 +754,7 @@ var yAxisLabelFormatter = ({
|
|
|
692
754
|
};
|
|
693
755
|
|
|
694
756
|
// src/hooks/useTimeSeriesChartOptions.ts
|
|
695
|
-
var
|
|
696
|
-
var import_highcharts = require("highcharts");
|
|
757
|
+
var import_react15 = require("react");
|
|
697
758
|
|
|
698
759
|
// src/constants/chartOptions.ts
|
|
699
760
|
var import_lodash = __toESM(require("lodash"));
|
|
@@ -726,6 +787,16 @@ var baseChartOptions = {
|
|
|
726
787
|
};
|
|
727
788
|
var TIME_SERIES_CHART_HEIGHT = 275;
|
|
728
789
|
var timeSeriesChartOptions = import_lodash.default.merge({}, baseChartOptions, {
|
|
790
|
+
annotations: [
|
|
791
|
+
{
|
|
792
|
+
draggable: "",
|
|
793
|
+
labelOptions: {
|
|
794
|
+
useHTML: true,
|
|
795
|
+
padding: 0
|
|
796
|
+
// removes "left" property padding created by highcharts so that label is centered
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
],
|
|
729
800
|
chart: {
|
|
730
801
|
// events.click is set at the component level because of the optional onClick prop
|
|
731
802
|
height: TIME_SERIES_CHART_HEIGHT,
|
|
@@ -734,6 +805,7 @@ var timeSeriesChartOptions = import_lodash.default.merge({}, baseChartOptions, {
|
|
|
734
805
|
plotOptions: {
|
|
735
806
|
series: {
|
|
736
807
|
animation: false,
|
|
808
|
+
clip: false,
|
|
737
809
|
marker: {
|
|
738
810
|
enabled: false,
|
|
739
811
|
states: {
|
|
@@ -803,26 +875,55 @@ var donutChartOptions = import_lodash.default.merge({}, baseChartOptions, {
|
|
|
803
875
|
});
|
|
804
876
|
|
|
805
877
|
// src/hooks/useTimeSeriesChartOptions.ts
|
|
878
|
+
var import_lodash2 = require("lodash");
|
|
806
879
|
var useTimeSeriesChartOptions = ({
|
|
880
|
+
xAnnotations,
|
|
807
881
|
data,
|
|
808
882
|
numberLocale,
|
|
809
883
|
seriesType,
|
|
810
884
|
textLocale,
|
|
811
885
|
currency = "USD",
|
|
886
|
+
disableTooltips = false,
|
|
812
887
|
numberFormat = "decimal",
|
|
813
888
|
yAxisLabelFormatter: yAxisLabelFormatter2,
|
|
814
889
|
onClick,
|
|
815
890
|
timeFormat = "12"
|
|
816
891
|
}) => {
|
|
817
|
-
const [
|
|
818
|
-
|
|
819
|
-
);
|
|
820
|
-
const [chart, setChart] = (0, import_react14.useState)(null);
|
|
821
|
-
const callback = (0, import_react14.useCallback)((chartInstance) => {
|
|
892
|
+
const [chart, setChart] = (0, import_react15.useState)(null);
|
|
893
|
+
const callback = (0, import_react15.useCallback)((chartInstance) => {
|
|
822
894
|
setChart(chartInstance);
|
|
823
895
|
}, []);
|
|
824
|
-
(
|
|
825
|
-
|
|
896
|
+
function attachTooltipEventListeners(series, tooltipId) {
|
|
897
|
+
const handleFocus = (point) => point.series.chart.tooltip.refresh(point);
|
|
898
|
+
const handleBlur = (point) => point.series.chart.tooltip.hide(0);
|
|
899
|
+
series.flatMap((item) => item.data).forEach((point) => {
|
|
900
|
+
const pointElement = point?.graphic?.element;
|
|
901
|
+
if (pointElement) {
|
|
902
|
+
pointElement.setAttribute("aria-describedby", tooltipId);
|
|
903
|
+
pointElement.addEventListener("focus", () => handleFocus(point));
|
|
904
|
+
pointElement.addEventListener("blur", () => handleBlur(point));
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
const formattedXAnnotations = (annotations) => {
|
|
909
|
+
if (annotations) {
|
|
910
|
+
return Object.entries(annotations).map(([x]) => ({
|
|
911
|
+
point: {
|
|
912
|
+
x: Number(x),
|
|
913
|
+
// Convert key (which is a string) to a number
|
|
914
|
+
y: 0,
|
|
915
|
+
xAxis: 0,
|
|
916
|
+
yAxis: 0
|
|
917
|
+
},
|
|
918
|
+
text: " "
|
|
919
|
+
// space is necessary because empty string reverts to showing default label
|
|
920
|
+
}));
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
const chartMarginTop = xAnnotations ? 24 : null;
|
|
924
|
+
const baseChartOptions2 = seriesType === "areaspline" ? areaChartOptions : lineChartOptions;
|
|
925
|
+
const options = (0, import_react15.useMemo)(() => {
|
|
926
|
+
return (0, import_lodash2.merge)({}, baseChartOptions2, {
|
|
826
927
|
accessibility: {
|
|
827
928
|
point: {
|
|
828
929
|
descriptionFormatter: function() {
|
|
@@ -830,24 +931,20 @@ var useTimeSeriesChartOptions = ({
|
|
|
830
931
|
}
|
|
831
932
|
}
|
|
832
933
|
},
|
|
934
|
+
annotations: [
|
|
935
|
+
{
|
|
936
|
+
labels: xAnnotations ? formattedXAnnotations(xAnnotations) : void 0
|
|
937
|
+
}
|
|
938
|
+
],
|
|
833
939
|
chart: {
|
|
940
|
+
marginTop: chartMarginTop,
|
|
834
941
|
events: {
|
|
835
942
|
click: onClick ? function() {
|
|
836
943
|
return onClick({ x: this?.hoverPoint?.x });
|
|
837
944
|
} : void 0,
|
|
838
|
-
|
|
839
|
-
const allPoints = this.series.flatMap((series) => series.data);
|
|
945
|
+
load: function() {
|
|
840
946
|
const tooltipId = generateChartTooltipPortalId(this.index);
|
|
841
|
-
|
|
842
|
-
const pointElement = point?.graphic?.element;
|
|
843
|
-
pointElement?.setAttribute("aria-describedby", tooltipId);
|
|
844
|
-
pointElement?.addEventListener("focus", () => {
|
|
845
|
-
point.series.chart.tooltip.refresh(point);
|
|
846
|
-
});
|
|
847
|
-
pointElement?.addEventListener("blur", () => {
|
|
848
|
-
point.series.chart.tooltip.hide(0);
|
|
849
|
-
});
|
|
850
|
-
});
|
|
947
|
+
attachTooltipEventListeners(this.series, tooltipId);
|
|
851
948
|
}
|
|
852
949
|
}
|
|
853
950
|
},
|
|
@@ -868,6 +965,9 @@ var useTimeSeriesChartOptions = ({
|
|
|
868
965
|
}
|
|
869
966
|
},
|
|
870
967
|
series: transformDataToSeries({ data }, seriesType),
|
|
968
|
+
tooltip: {
|
|
969
|
+
enabled: !disableTooltips
|
|
970
|
+
},
|
|
871
971
|
xAxis: {
|
|
872
972
|
labels: {
|
|
873
973
|
formatter: function() {
|
|
@@ -900,6 +1000,7 @@ var useTimeSeriesChartOptions = ({
|
|
|
900
1000
|
}
|
|
901
1001
|
});
|
|
902
1002
|
}, [
|
|
1003
|
+
baseChartOptions2,
|
|
903
1004
|
currency,
|
|
904
1005
|
data,
|
|
905
1006
|
numberFormat,
|
|
@@ -908,6 +1009,7 @@ var useTimeSeriesChartOptions = ({
|
|
|
908
1009
|
seriesType,
|
|
909
1010
|
textLocale,
|
|
910
1011
|
timeFormat,
|
|
1012
|
+
xAnnotations,
|
|
911
1013
|
yAxisLabelFormatter2
|
|
912
1014
|
]);
|
|
913
1015
|
return { options, chart, callback };
|
|
@@ -946,9 +1048,19 @@ var baseChartStyles = import_styled_components7.css`
|
|
|
946
1048
|
}).join("\n")}
|
|
947
1049
|
|
|
948
1050
|
// set overall chart background color
|
|
949
|
-
|
|
1051
|
+
.highcharts-background {
|
|
950
1052
|
fill: ${({ theme: theme14 }) => theme14.colors.container.background.base};
|
|
951
1053
|
}
|
|
1054
|
+
|
|
1055
|
+
g.highcharts-annotation-label {
|
|
1056
|
+
display: none;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
div.highcharts-annotation-label {
|
|
1060
|
+
top: 0 !important;
|
|
1061
|
+
transform: translateX(-50%); // centers the label on the targeted axis point
|
|
1062
|
+
pointer-events: none; // prevents tooltip hover from being interrupted by this element since it renders after on the dom
|
|
1063
|
+
}
|
|
952
1064
|
`;
|
|
953
1065
|
var timeSeriesChartStyles = import_styled_components7.css`
|
|
954
1066
|
${baseChartStyles}
|
|
@@ -1058,16 +1170,17 @@ var donutChartStyles = import_styled_components7.css`
|
|
|
1058
1170
|
|
|
1059
1171
|
// src/components/AreaChart/AreaChart.tsx
|
|
1060
1172
|
var import_seeds_react_theme8 = require("@sproutsocial/seeds-react-theme");
|
|
1061
|
-
var
|
|
1173
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1062
1174
|
(0, import_accessibility.default)(import_highcharts3.default);
|
|
1175
|
+
(0, import_annotations.default)(import_highcharts3.default);
|
|
1063
1176
|
var StyledBox3 = (0, import_styled_components8.default)(import_seeds_react_box9.Box)`
|
|
1064
1177
|
${areaChartStyles}
|
|
1065
1178
|
`;
|
|
1066
|
-
var AreaChart = (0,
|
|
1179
|
+
var AreaChart = (0, import_react16.memo)(function AreaChart2(props) {
|
|
1067
1180
|
const { data } = props;
|
|
1068
|
-
return data.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1181
|
+
return data.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AreaChartWithData, { ...props });
|
|
1069
1182
|
});
|
|
1070
|
-
var AreaChartWithData = (0,
|
|
1183
|
+
var AreaChartWithData = (0, import_react16.memo)(function AreaChartWithData2({
|
|
1071
1184
|
data,
|
|
1072
1185
|
invalidNumberLabel,
|
|
1073
1186
|
numberLocale = "en-us",
|
|
@@ -1076,37 +1189,41 @@ var AreaChartWithData = (0, import_react15.memo)(function AreaChartWithData2({
|
|
|
1076
1189
|
tooltipTotalLabel,
|
|
1077
1190
|
// optional
|
|
1078
1191
|
currency = "USD",
|
|
1192
|
+
disableTooltips = false,
|
|
1079
1193
|
numberFormat = "decimal",
|
|
1080
1194
|
tooltip,
|
|
1081
1195
|
yAxisLabelFormatter: yAxisLabelFormatter2,
|
|
1082
1196
|
onClick,
|
|
1083
1197
|
tooltipClickLabel,
|
|
1084
|
-
timeFormat = "12"
|
|
1198
|
+
timeFormat = "12",
|
|
1199
|
+
xAnnotations
|
|
1085
1200
|
}) {
|
|
1086
1201
|
const { options, chart, callback } = useTimeSeriesChartOptions({
|
|
1087
1202
|
currency,
|
|
1088
1203
|
data,
|
|
1204
|
+
disableTooltips,
|
|
1089
1205
|
numberFormat,
|
|
1090
1206
|
numberLocale,
|
|
1091
1207
|
seriesType: "areaspline",
|
|
1092
1208
|
textLocale,
|
|
1093
1209
|
yAxisLabelFormatter: yAxisLabelFormatter2,
|
|
1094
1210
|
onClick,
|
|
1095
|
-
timeFormat
|
|
1211
|
+
timeFormat,
|
|
1212
|
+
xAnnotations
|
|
1096
1213
|
});
|
|
1097
1214
|
const colors = data.map(
|
|
1098
1215
|
(series, index) => series.styles?.color ?? import_seeds_react_theme8.theme.colors.DATAVIZ_COLORS_LIST[index]
|
|
1099
1216
|
);
|
|
1100
|
-
return /* @__PURE__ */ (0,
|
|
1101
|
-
/* @__PURE__ */ (0,
|
|
1102
|
-
/* @__PURE__ */ (0,
|
|
1217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1218
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(GlobalChartStyleOverrides, {}),
|
|
1219
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1103
1220
|
StyledBox3,
|
|
1104
1221
|
{
|
|
1105
1222
|
$colors: colors,
|
|
1106
1223
|
$hasOnClick: Boolean(onClick),
|
|
1107
1224
|
bg: "container.background.base",
|
|
1108
1225
|
children: [
|
|
1109
|
-
/* @__PURE__ */ (0,
|
|
1226
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1110
1227
|
import_highcharts_react_official.HighchartsReact,
|
|
1111
1228
|
{
|
|
1112
1229
|
highcharts: import_highcharts3.default,
|
|
@@ -1114,7 +1231,14 @@ var AreaChartWithData = (0, import_react15.memo)(function AreaChartWithData2({
|
|
|
1114
1231
|
callback
|
|
1115
1232
|
}
|
|
1116
1233
|
),
|
|
1117
|
-
chart ? /* @__PURE__ */ (0,
|
|
1234
|
+
chart && chart.annotations?.length ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1235
|
+
ChartXAnnotationMarkerPortal,
|
|
1236
|
+
{
|
|
1237
|
+
xAnnotations,
|
|
1238
|
+
annotationContext: chart.annotations?.[0]
|
|
1239
|
+
}
|
|
1240
|
+
) : null,
|
|
1241
|
+
chart && !disableTooltips ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1118
1242
|
ChartTooltipPortal,
|
|
1119
1243
|
{
|
|
1120
1244
|
chart,
|
|
@@ -1125,7 +1249,8 @@ var AreaChartWithData = (0, import_react15.memo)(function AreaChartWithData2({
|
|
|
1125
1249
|
});
|
|
1126
1250
|
const x = context.x;
|
|
1127
1251
|
const total = context.total;
|
|
1128
|
-
|
|
1252
|
+
const xAnnotationDetails = xAnnotations?.[x]?.details;
|
|
1253
|
+
return tooltip ? tooltip({ data: tooltipData, total, x }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1129
1254
|
AreaChartTooltip,
|
|
1130
1255
|
{
|
|
1131
1256
|
currency,
|
|
@@ -1139,13 +1264,14 @@ var AreaChartWithData = (0, import_react15.memo)(function AreaChartWithData2({
|
|
|
1139
1264
|
total,
|
|
1140
1265
|
x,
|
|
1141
1266
|
onClick,
|
|
1142
|
-
tooltipClickLabel
|
|
1267
|
+
tooltipClickLabel,
|
|
1268
|
+
xAnnotationDetails
|
|
1143
1269
|
}
|
|
1144
1270
|
);
|
|
1145
1271
|
}
|
|
1146
1272
|
}
|
|
1147
1273
|
) : null,
|
|
1148
|
-
/* @__PURE__ */ (0,
|
|
1274
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_seeds_react_box9.Box, { mt: 350, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AreaChartLegend, { data }) })
|
|
1149
1275
|
]
|
|
1150
1276
|
}
|
|
1151
1277
|
)
|
|
@@ -1153,7 +1279,7 @@ var AreaChartWithData = (0, import_react15.memo)(function AreaChartWithData2({
|
|
|
1153
1279
|
});
|
|
1154
1280
|
|
|
1155
1281
|
// src/components/DonutChart/DonutChart.tsx
|
|
1156
|
-
var
|
|
1282
|
+
var import_react19 = require("react");
|
|
1157
1283
|
var import_highcharts4 = __toESM(require("highcharts"));
|
|
1158
1284
|
var import_highcharts_react_official2 = require("highcharts-react-official");
|
|
1159
1285
|
var import_accessibility2 = __toESM(require("highcharts/modules/accessibility"));
|
|
@@ -1161,31 +1287,31 @@ var import_styled_components9 = __toESM(require("styled-components"));
|
|
|
1161
1287
|
var import_seeds_react_box11 = require("@sproutsocial/seeds-react-box");
|
|
1162
1288
|
|
|
1163
1289
|
// src/components/DonutChart/components/DonutChartLegend.tsx
|
|
1164
|
-
var
|
|
1290
|
+
var import_react17 = require("react");
|
|
1165
1291
|
var import_seeds_react_theme9 = require("@sproutsocial/seeds-react-theme");
|
|
1166
|
-
var
|
|
1292
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1167
1293
|
var getDonutChartLegendLabels = ({
|
|
1168
1294
|
data
|
|
1169
1295
|
}) => {
|
|
1170
1296
|
return data.map((slice, index) => ({
|
|
1171
|
-
content: /* @__PURE__ */ (0,
|
|
1297
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChartLegendLabelContentWithIcon, { icon: slice.icon, children: slice.name }),
|
|
1172
1298
|
color: slice.styles?.color || import_seeds_react_theme9.theme.colors.DATAVIZ_COLORS_LIST[index]
|
|
1173
1299
|
}));
|
|
1174
1300
|
};
|
|
1175
|
-
var DonutChartLegend = (0,
|
|
1301
|
+
var DonutChartLegend = (0, import_react17.memo)(
|
|
1176
1302
|
function DonutChartLegend2({ data }) {
|
|
1177
|
-
return /* @__PURE__ */ (0,
|
|
1303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChartLegend, { legendLabels: getDonutChartLegendLabels({ data }) });
|
|
1178
1304
|
}
|
|
1179
1305
|
);
|
|
1180
1306
|
|
|
1181
1307
|
// src/components/DonutChart/components/DonutChartTooltip.tsx
|
|
1182
|
-
var
|
|
1308
|
+
var import_react18 = require("react");
|
|
1183
1309
|
var import_seeds_react_box10 = require("@sproutsocial/seeds-react-box");
|
|
1184
1310
|
var import_seeds_react_duration3 = require("@sproutsocial/seeds-react-duration");
|
|
1185
1311
|
var import_seeds_react_numeral3 = require("@sproutsocial/seeds-react-numeral");
|
|
1186
1312
|
var import_seeds_react_text5 = require("@sproutsocial/seeds-react-text");
|
|
1187
|
-
var
|
|
1188
|
-
var DonutChartTooltip = (0,
|
|
1313
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1314
|
+
var DonutChartTooltip = (0, import_react18.memo)(
|
|
1189
1315
|
function DonutChartTooltip2({
|
|
1190
1316
|
color,
|
|
1191
1317
|
name,
|
|
@@ -1201,11 +1327,11 @@ var DonutChartTooltip = (0, import_react17.memo)(
|
|
|
1201
1327
|
{
|
|
1202
1328
|
cells: [
|
|
1203
1329
|
{
|
|
1204
|
-
content: /* @__PURE__ */ (0,
|
|
1330
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartLegendLabel, { color, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartLegendLabelContentWithIcon, { icon, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_seeds_react_text5.Text, { "aria-label": `${name}: `, children: name }) }) })
|
|
1205
1331
|
},
|
|
1206
1332
|
{
|
|
1207
|
-
content: /* @__PURE__ */ (0,
|
|
1208
|
-
/* @__PURE__ */ (0,
|
|
1333
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_seeds_react_box10.Box, { display: "inline-flex", alignItems: "center", gap: 350, children: [
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1209
1335
|
import_seeds_react_numeral3.Numeral,
|
|
1210
1336
|
{
|
|
1211
1337
|
number: percent,
|
|
@@ -1214,7 +1340,7 @@ var DonutChartTooltip = (0, import_react17.memo)(
|
|
|
1214
1340
|
locale: numberLocale
|
|
1215
1341
|
}
|
|
1216
1342
|
),
|
|
1217
|
-
/* @__PURE__ */ (0,
|
|
1343
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_seeds_react_text5.Text, { fontWeight: "semibold", children: numberFormat === "duration" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_seeds_react_duration3.Duration, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1218
1344
|
import_seeds_react_numeral3.Numeral,
|
|
1219
1345
|
{
|
|
1220
1346
|
abbreviate: false,
|
|
@@ -1230,7 +1356,7 @@ var DonutChartTooltip = (0, import_react17.memo)(
|
|
|
1230
1356
|
]
|
|
1231
1357
|
}
|
|
1232
1358
|
];
|
|
1233
|
-
return /* @__PURE__ */ (0,
|
|
1359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartTooltip, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartTooltipTable, { rows }) });
|
|
1234
1360
|
}
|
|
1235
1361
|
);
|
|
1236
1362
|
|
|
@@ -1252,32 +1378,33 @@ var transformDonutChartTooltipData = ({
|
|
|
1252
1378
|
|
|
1253
1379
|
// src/components/DonutChart/DonutChart.tsx
|
|
1254
1380
|
var import_seeds_react_theme11 = require("@sproutsocial/seeds-react-theme");
|
|
1255
|
-
var
|
|
1381
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1256
1382
|
(0, import_accessibility2.default)(import_highcharts4.default);
|
|
1257
1383
|
var StyledBox4 = (0, import_styled_components9.default)(import_seeds_react_box11.Box)`
|
|
1258
1384
|
${donutChartStyles}
|
|
1259
1385
|
`;
|
|
1260
|
-
var DonutChart = (0,
|
|
1386
|
+
var DonutChart = (0, import_react19.memo)(function DonutChart2(props) {
|
|
1261
1387
|
const { data } = props;
|
|
1262
|
-
return data.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1388
|
+
return data.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DonutChartWithData, { ...props });
|
|
1263
1389
|
});
|
|
1264
|
-
var DonutChartWithData = (0,
|
|
1390
|
+
var DonutChartWithData = (0, import_react19.memo)(
|
|
1265
1391
|
function DonutChartWithData2({
|
|
1266
1392
|
data,
|
|
1267
1393
|
numberLocale = "en-us",
|
|
1268
1394
|
textLocale = "en-us",
|
|
1269
1395
|
// optional
|
|
1270
1396
|
currency = "USD",
|
|
1397
|
+
disableTooltips = false,
|
|
1271
1398
|
hideLegend = false,
|
|
1272
1399
|
numberFormat = "decimal",
|
|
1273
1400
|
tooltip
|
|
1274
1401
|
}) {
|
|
1275
|
-
const [options, setOptions] = (0,
|
|
1276
|
-
const [chart, setChart] = (0,
|
|
1277
|
-
const callback = (0,
|
|
1402
|
+
const [options, setOptions] = (0, import_react19.useState)(donutChartOptions);
|
|
1403
|
+
const [chart, setChart] = (0, import_react19.useState)(null);
|
|
1404
|
+
const callback = (0, import_react19.useCallback)((chartInstance) => {
|
|
1278
1405
|
setChart(chartInstance);
|
|
1279
1406
|
}, []);
|
|
1280
|
-
(0,
|
|
1407
|
+
(0, import_react19.useEffect)(() => {
|
|
1281
1408
|
setOptions({
|
|
1282
1409
|
accessibility: {
|
|
1283
1410
|
point: {
|
|
@@ -1315,16 +1442,19 @@ var DonutChartWithData = (0, import_react18.memo)(
|
|
|
1315
1442
|
};
|
|
1316
1443
|
})
|
|
1317
1444
|
}
|
|
1318
|
-
]
|
|
1445
|
+
],
|
|
1446
|
+
tooltip: {
|
|
1447
|
+
enabled: !disableTooltips
|
|
1448
|
+
}
|
|
1319
1449
|
});
|
|
1320
1450
|
}, [data]);
|
|
1321
1451
|
const colors = data.map(
|
|
1322
1452
|
(series, index) => series.styles?.color ?? import_seeds_react_theme11.theme.colors.DATAVIZ_COLORS_LIST[index] ?? ""
|
|
1323
1453
|
);
|
|
1324
|
-
return /* @__PURE__ */ (0,
|
|
1325
|
-
/* @__PURE__ */ (0,
|
|
1326
|
-
/* @__PURE__ */ (0,
|
|
1327
|
-
/* @__PURE__ */ (0,
|
|
1454
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
1455
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GlobalChartStyleOverrides, {}),
|
|
1456
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(StyledBox4, { $colors: colors, bg: "container.background.base", children: [
|
|
1457
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1328
1458
|
import_highcharts_react_official2.HighchartsReact,
|
|
1329
1459
|
{
|
|
1330
1460
|
highcharts: import_highcharts4.default,
|
|
@@ -1332,13 +1462,13 @@ var DonutChartWithData = (0, import_react18.memo)(
|
|
|
1332
1462
|
callback
|
|
1333
1463
|
}
|
|
1334
1464
|
),
|
|
1335
|
-
chart ? /* @__PURE__ */ (0,
|
|
1465
|
+
chart && !disableTooltips ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1336
1466
|
ChartTooltipPortal,
|
|
1337
1467
|
{
|
|
1338
1468
|
chart,
|
|
1339
1469
|
renderContent: (context) => {
|
|
1340
1470
|
const { color, icon, name, percent, value } = transformDonutChartTooltipData({ context, data });
|
|
1341
|
-
return tooltip ? tooltip({ color, icon, name, percent, value }) : /* @__PURE__ */ (0,
|
|
1471
|
+
return tooltip ? tooltip({ color, icon, name, percent, value }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1342
1472
|
DonutChartTooltip,
|
|
1343
1473
|
{
|
|
1344
1474
|
color,
|
|
@@ -1355,21 +1485,21 @@ var DonutChartWithData = (0, import_react18.memo)(
|
|
|
1355
1485
|
}
|
|
1356
1486
|
}
|
|
1357
1487
|
) : null,
|
|
1358
|
-
hideLegend ? null : /* @__PURE__ */ (0,
|
|
1488
|
+
hideLegend ? null : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_seeds_react_box11.Box, { mt: 350, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DonutChartLegend, { data }) })
|
|
1359
1489
|
] })
|
|
1360
1490
|
] });
|
|
1361
1491
|
}
|
|
1362
1492
|
);
|
|
1363
1493
|
|
|
1364
1494
|
// src/components/DonutChart/components/DonutChartLegendTable.tsx
|
|
1365
|
-
var
|
|
1495
|
+
var import_react20 = require("react");
|
|
1366
1496
|
var import_seeds_react_box12 = require("@sproutsocial/seeds-react-box");
|
|
1367
1497
|
var import_seeds_react_duration4 = require("@sproutsocial/seeds-react-duration");
|
|
1368
1498
|
var import_seeds_react_numeral4 = require("@sproutsocial/seeds-react-numeral");
|
|
1369
1499
|
var import_seeds_react_text6 = require("@sproutsocial/seeds-react-text");
|
|
1370
1500
|
var import_seeds_react_theme12 = require("@sproutsocial/seeds-react-theme");
|
|
1371
|
-
var
|
|
1372
|
-
var DonutChartLegendTable = (0,
|
|
1501
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1502
|
+
var DonutChartLegendTable = (0, import_react20.memo)(
|
|
1373
1503
|
function DonutChartLegendTable2({
|
|
1374
1504
|
data,
|
|
1375
1505
|
numberLocale = "en-us",
|
|
@@ -1389,11 +1519,11 @@ var DonutChartLegendTable = (0, import_react19.memo)(
|
|
|
1389
1519
|
return {
|
|
1390
1520
|
cells: [
|
|
1391
1521
|
{
|
|
1392
|
-
content: /* @__PURE__ */ (0,
|
|
1522
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ChartLegendLabel, { color, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ChartLegendLabelContentWithIcon, { icon, children: name }) })
|
|
1393
1523
|
},
|
|
1394
1524
|
{
|
|
1395
|
-
content: /* @__PURE__ */ (0,
|
|
1396
|
-
/* @__PURE__ */ (0,
|
|
1525
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_seeds_react_box12.Box, { display: "inline-flex", alignItems: "center", gap: 350, children: [
|
|
1526
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_seeds_react_text6.Text, { color: "text.body", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1397
1527
|
import_seeds_react_numeral4.Numeral,
|
|
1398
1528
|
{
|
|
1399
1529
|
abbreviate: false,
|
|
@@ -1402,7 +1532,7 @@ var DonutChartLegendTable = (0, import_react19.memo)(
|
|
|
1402
1532
|
number: value / total * 100
|
|
1403
1533
|
}
|
|
1404
1534
|
) }),
|
|
1405
|
-
/* @__PURE__ */ (0,
|
|
1535
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_seeds_react_text6.Text, { color: "text.body", fontWeight: "semibold", children: numberFormat === "duration" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_seeds_react_duration4.Duration, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1406
1536
|
import_seeds_react_numeral4.Numeral,
|
|
1407
1537
|
{
|
|
1408
1538
|
abbreviate: false,
|
|
@@ -1422,10 +1552,10 @@ var DonutChartLegendTable = (0, import_react19.memo)(
|
|
|
1422
1552
|
{
|
|
1423
1553
|
cells: [
|
|
1424
1554
|
{
|
|
1425
|
-
content: /* @__PURE__ */ (0,
|
|
1555
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_seeds_react_text6.Text, { fontWeight: "semibold", color: "text.headline", children: totalLabel })
|
|
1426
1556
|
},
|
|
1427
1557
|
{
|
|
1428
|
-
content: /* @__PURE__ */ (0,
|
|
1558
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_seeds_react_text6.Text, { color: "text.body", fontWeight: "bold", children: numberFormat === "duration" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_seeds_react_duration4.Duration, { locale: textLocale, milliseconds: total }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1429
1559
|
import_seeds_react_numeral4.Numeral,
|
|
1430
1560
|
{
|
|
1431
1561
|
abbreviate: false,
|
|
@@ -1441,7 +1571,7 @@ var DonutChartLegendTable = (0, import_react19.memo)(
|
|
|
1441
1571
|
isAppendedRow: true
|
|
1442
1572
|
}
|
|
1443
1573
|
];
|
|
1444
|
-
return /* @__PURE__ */ (0,
|
|
1574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1445
1575
|
ChartTable,
|
|
1446
1576
|
{
|
|
1447
1577
|
rows: [...rows, ...totalRow]
|
|
@@ -1451,40 +1581,41 @@ var DonutChartLegendTable = (0, import_react19.memo)(
|
|
|
1451
1581
|
);
|
|
1452
1582
|
|
|
1453
1583
|
// src/components/LineChart/LineChart.tsx
|
|
1454
|
-
var
|
|
1584
|
+
var import_react23 = require("react");
|
|
1455
1585
|
var import_highcharts5 = __toESM(require("highcharts"));
|
|
1456
1586
|
var import_highcharts_react_official3 = require("highcharts-react-official");
|
|
1457
1587
|
var import_accessibility3 = __toESM(require("highcharts/modules/accessibility"));
|
|
1588
|
+
var import_annotations2 = __toESM(require("highcharts/modules/annotations"));
|
|
1458
1589
|
var import_styled_components10 = __toESM(require("styled-components"));
|
|
1459
1590
|
var import_seeds_react_box14 = require("@sproutsocial/seeds-react-box");
|
|
1460
1591
|
|
|
1461
1592
|
// src/components/LineChart/components/LineChartLegend.tsx
|
|
1462
|
-
var
|
|
1593
|
+
var import_react21 = require("react");
|
|
1463
1594
|
var import_seeds_react_theme13 = require("@sproutsocial/seeds-react-theme");
|
|
1464
|
-
var
|
|
1595
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1465
1596
|
var getLineChartLegendLabels = ({
|
|
1466
1597
|
data
|
|
1467
1598
|
}) => {
|
|
1468
1599
|
return data.map((series, index) => ({
|
|
1469
|
-
content: /* @__PURE__ */ (0,
|
|
1600
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ChartLegendLabelContentWithIcon, { icon: series.icon, children: series.name }),
|
|
1470
1601
|
color: series.styles?.color || import_seeds_react_theme13.theme.colors.DATAVIZ_COLORS_LIST[index]
|
|
1471
1602
|
}));
|
|
1472
1603
|
};
|
|
1473
|
-
var LineChartLegend = (0,
|
|
1604
|
+
var LineChartLegend = (0, import_react21.memo)(
|
|
1474
1605
|
function LineChartLegend2({ data }) {
|
|
1475
|
-
return /* @__PURE__ */ (0,
|
|
1606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ChartLegend, { legendLabels: getLineChartLegendLabels({ data }) });
|
|
1476
1607
|
}
|
|
1477
1608
|
);
|
|
1478
1609
|
|
|
1479
1610
|
// src/components/LineChart/components/LineChartTooltip.tsx
|
|
1480
|
-
var
|
|
1611
|
+
var import_react22 = require("react");
|
|
1481
1612
|
var import_seeds_react_box13 = require("@sproutsocial/seeds-react-box");
|
|
1482
1613
|
var import_seeds_react_duration5 = require("@sproutsocial/seeds-react-duration");
|
|
1483
1614
|
var import_seeds_react_icon2 = require("@sproutsocial/seeds-react-icon");
|
|
1484
1615
|
var import_seeds_react_numeral5 = require("@sproutsocial/seeds-react-numeral");
|
|
1485
1616
|
var import_seeds_react_text7 = require("@sproutsocial/seeds-react-text");
|
|
1486
|
-
var
|
|
1487
|
-
var LineChartTooltip = (0,
|
|
1617
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1618
|
+
var LineChartTooltip = (0, import_react22.memo)(
|
|
1488
1619
|
function LineChartTooltip2({
|
|
1489
1620
|
data,
|
|
1490
1621
|
invalidNumberLabel,
|
|
@@ -1496,16 +1627,17 @@ var LineChartTooltip = (0, import_react21.memo)(
|
|
|
1496
1627
|
currency = "USD",
|
|
1497
1628
|
numberFormat = "decimal",
|
|
1498
1629
|
onClick,
|
|
1499
|
-
tooltipClickLabel
|
|
1630
|
+
tooltipClickLabel,
|
|
1631
|
+
xAnnotationDetails
|
|
1500
1632
|
}) {
|
|
1501
1633
|
const rows = data.map(({ color, icon, name, value }) => {
|
|
1502
1634
|
return {
|
|
1503
1635
|
cells: [
|
|
1504
1636
|
{
|
|
1505
|
-
content: /* @__PURE__ */ (0,
|
|
1637
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChartLegendLabel, { color, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChartLegendLabelContentWithIcon, { icon, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_seeds_react_text7.Text, { "aria-label": `${name}: `, children: name }) }) })
|
|
1506
1638
|
},
|
|
1507
1639
|
{
|
|
1508
|
-
content: value === null && invalidNumberLabel ? /* @__PURE__ */ (0,
|
|
1640
|
+
content: value === null && invalidNumberLabel ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_seeds_react_text7.Text, { children: invalidNumberLabel }) : numberFormat === "duration" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_seeds_react_duration5.Duration, { locale: textLocale, milliseconds: value }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1509
1641
|
import_seeds_react_numeral5.Numeral,
|
|
1510
1642
|
{
|
|
1511
1643
|
abbreviate: false,
|
|
@@ -1520,12 +1652,13 @@ var LineChartTooltip = (0, import_react21.memo)(
|
|
|
1520
1652
|
]
|
|
1521
1653
|
};
|
|
1522
1654
|
});
|
|
1523
|
-
return /* @__PURE__ */ (0,
|
|
1524
|
-
|
|
1525
|
-
/* @__PURE__ */ (0,
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
/* @__PURE__ */ (0,
|
|
1655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ChartTooltip, { children: [
|
|
1656
|
+
xAnnotationDetails ? xAnnotationDetails() : void 0,
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChartTooltipTitle, { children: tooltipDateFormatter({ x }) }),
|
|
1658
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChartTooltipTable, { rows }),
|
|
1659
|
+
onClick && tooltipClickLabel ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChartTooltipFooter, { children: typeof tooltipClickLabel === "string" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_seeds_react_box13.Box, { display: "flex", alignItems: "center", gap: 300, children: [
|
|
1660
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_seeds_react_icon2.Icon, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_seeds_react_text7.Text, { color: "text.subtext", fontSize: 200, children: tooltipClickLabel })
|
|
1529
1662
|
] }) : tooltipClickLabel }) : null
|
|
1530
1663
|
] });
|
|
1531
1664
|
}
|
|
@@ -1533,16 +1666,17 @@ var LineChartTooltip = (0, import_react21.memo)(
|
|
|
1533
1666
|
|
|
1534
1667
|
// src/components/LineChart/LineChart.tsx
|
|
1535
1668
|
var import_seeds_react_theme14 = require("@sproutsocial/seeds-react-theme");
|
|
1536
|
-
var
|
|
1669
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1537
1670
|
(0, import_accessibility3.default)(import_highcharts5.default);
|
|
1671
|
+
(0, import_annotations2.default)(import_highcharts5.default);
|
|
1538
1672
|
var StyledBox5 = (0, import_styled_components10.default)(import_seeds_react_box14.Box)`
|
|
1539
1673
|
${lineChartStyles}
|
|
1540
1674
|
`;
|
|
1541
|
-
var LineChart = (0,
|
|
1675
|
+
var LineChart = (0, import_react23.memo)(function LineChart2(props) {
|
|
1542
1676
|
const { data } = props;
|
|
1543
|
-
return data.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1677
|
+
return data.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LineChartWithData, { ...props });
|
|
1544
1678
|
});
|
|
1545
|
-
var LineChartWithData = (0,
|
|
1679
|
+
var LineChartWithData = (0, import_react23.memo)(function LineChartWithData2({
|
|
1546
1680
|
data,
|
|
1547
1681
|
invalidNumberLabel,
|
|
1548
1682
|
numberLocale = "en-us",
|
|
@@ -1550,23 +1684,27 @@ var LineChartWithData = (0, import_react22.memo)(function LineChartWithData2({
|
|
|
1550
1684
|
tooltipDateFormatter,
|
|
1551
1685
|
// optional
|
|
1552
1686
|
currency = "USD",
|
|
1687
|
+
disableTooltips = false,
|
|
1553
1688
|
numberFormat = "decimal",
|
|
1554
1689
|
tooltip,
|
|
1555
1690
|
yAxisLabelFormatter: yAxisLabelFormatter2,
|
|
1556
1691
|
onClick,
|
|
1557
1692
|
tooltipClickLabel,
|
|
1558
|
-
timeFormat = "12"
|
|
1693
|
+
timeFormat = "12",
|
|
1694
|
+
xAnnotations
|
|
1559
1695
|
}) {
|
|
1560
1696
|
const { options, chart, callback } = useTimeSeriesChartOptions({
|
|
1561
1697
|
currency,
|
|
1562
1698
|
data,
|
|
1699
|
+
disableTooltips,
|
|
1563
1700
|
numberFormat,
|
|
1564
1701
|
numberLocale,
|
|
1565
1702
|
seriesType: "spline",
|
|
1566
1703
|
textLocale,
|
|
1567
1704
|
yAxisLabelFormatter: yAxisLabelFormatter2,
|
|
1568
1705
|
onClick,
|
|
1569
|
-
timeFormat
|
|
1706
|
+
timeFormat,
|
|
1707
|
+
xAnnotations
|
|
1570
1708
|
});
|
|
1571
1709
|
const { colors, patterns } = data.reduce(
|
|
1572
1710
|
(acc, item, index) => {
|
|
@@ -1581,9 +1719,9 @@ var LineChartWithData = (0, import_react22.memo)(function LineChartWithData2({
|
|
|
1581
1719
|
patterns: []
|
|
1582
1720
|
}
|
|
1583
1721
|
);
|
|
1584
|
-
return /* @__PURE__ */ (0,
|
|
1585
|
-
/* @__PURE__ */ (0,
|
|
1586
|
-
/* @__PURE__ */ (0,
|
|
1722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
1723
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(GlobalChartStyleOverrides, {}),
|
|
1724
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1587
1725
|
StyledBox5,
|
|
1588
1726
|
{
|
|
1589
1727
|
$colors: colors,
|
|
@@ -1591,7 +1729,7 @@ var LineChartWithData = (0, import_react22.memo)(function LineChartWithData2({
|
|
|
1591
1729
|
$hasOnClick: Boolean(onClick),
|
|
1592
1730
|
bg: "container.background.base",
|
|
1593
1731
|
children: [
|
|
1594
|
-
/* @__PURE__ */ (0,
|
|
1732
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1595
1733
|
import_highcharts_react_official3.HighchartsReact,
|
|
1596
1734
|
{
|
|
1597
1735
|
highcharts: import_highcharts5.default,
|
|
@@ -1599,7 +1737,14 @@ var LineChartWithData = (0, import_react22.memo)(function LineChartWithData2({
|
|
|
1599
1737
|
callback
|
|
1600
1738
|
}
|
|
1601
1739
|
),
|
|
1602
|
-
chart ? /* @__PURE__ */ (0,
|
|
1740
|
+
chart && chart.annotations?.length ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1741
|
+
ChartXAnnotationMarkerPortal,
|
|
1742
|
+
{
|
|
1743
|
+
xAnnotations,
|
|
1744
|
+
annotationContext: chart.annotations?.[0]
|
|
1745
|
+
}
|
|
1746
|
+
) : null,
|
|
1747
|
+
chart && !disableTooltips ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1603
1748
|
ChartTooltipPortal,
|
|
1604
1749
|
{
|
|
1605
1750
|
chart,
|
|
@@ -1609,7 +1754,8 @@ var LineChartWithData = (0, import_react22.memo)(function LineChartWithData2({
|
|
|
1609
1754
|
data
|
|
1610
1755
|
});
|
|
1611
1756
|
const x = context.x;
|
|
1612
|
-
|
|
1757
|
+
const xAnnotationDetails = xAnnotations?.[x]?.details;
|
|
1758
|
+
return tooltip ? tooltip({ data: tooltipData, x }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1613
1759
|
LineChartTooltip,
|
|
1614
1760
|
{
|
|
1615
1761
|
currency,
|
|
@@ -1619,15 +1765,16 @@ var LineChartWithData = (0, import_react22.memo)(function LineChartWithData2({
|
|
|
1619
1765
|
numberLocale,
|
|
1620
1766
|
textLocale,
|
|
1621
1767
|
tooltipDateFormatter,
|
|
1622
|
-
x,
|
|
1623
1768
|
onClick,
|
|
1624
|
-
tooltipClickLabel
|
|
1769
|
+
tooltipClickLabel,
|
|
1770
|
+
x,
|
|
1771
|
+
xAnnotationDetails
|
|
1625
1772
|
}
|
|
1626
1773
|
);
|
|
1627
1774
|
}
|
|
1628
1775
|
}
|
|
1629
1776
|
) : null,
|
|
1630
|
-
/* @__PURE__ */ (0,
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_seeds_react_box14.Box, { mt: 350, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LineChartLegend, { data }) })
|
|
1631
1778
|
]
|
|
1632
1779
|
}
|
|
1633
1780
|
)
|