@sproutsocial/seeds-react-data-viz 0.3.0 → 0.4.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/README.md +2 -0
- package/dist/esm/index.js +449 -50
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +143 -19
- package/dist/index.d.ts +143 -19
- package/dist/index.js +456 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -538,7 +538,12 @@ var ChartXAnnotationMarkerPortal = memo13(
|
|
|
538
538
|
);
|
|
539
539
|
|
|
540
540
|
// src/helpers/transformDataToSeries.ts
|
|
541
|
-
var transformDataToSeries = ({
|
|
541
|
+
var transformDataToSeries = ({
|
|
542
|
+
data
|
|
543
|
+
}, type) => {
|
|
544
|
+
const hasCategoricalData = data.some(
|
|
545
|
+
(series) => series.points.some((point) => typeof point.x === "string")
|
|
546
|
+
);
|
|
542
547
|
return data.map((dataItem, dataIndex) => {
|
|
543
548
|
const points = dataItem.points || [];
|
|
544
549
|
const dataPoints = points.map((point, pointsIndex) => {
|
|
@@ -555,12 +560,14 @@ var transformDataToSeries = ({ data }, type) => {
|
|
|
555
560
|
enableMarker = true;
|
|
556
561
|
}
|
|
557
562
|
return {
|
|
558
|
-
x: point.x,
|
|
563
|
+
x: hasCategoricalData ? pointsIndex : point.x,
|
|
559
564
|
y: point.y,
|
|
560
565
|
marker: {
|
|
561
566
|
enabled: enableMarker ? enableMarker : void 0,
|
|
562
567
|
symbol: enableMarker ? "circle" : void 0
|
|
563
|
-
}
|
|
568
|
+
},
|
|
569
|
+
// For categorical data, store the original category name
|
|
570
|
+
...hasCategoricalData && { name: point.x }
|
|
564
571
|
};
|
|
565
572
|
});
|
|
566
573
|
return {
|
|
@@ -590,6 +597,42 @@ var transformTimeSeriesTooltipData = ({
|
|
|
590
597
|
});
|
|
591
598
|
};
|
|
592
599
|
|
|
600
|
+
// src/helpers/yAxisLabelFormatter.ts
|
|
601
|
+
import { formatDuration } from "@sproutsocial/seeds-react-duration";
|
|
602
|
+
import { formatNumeral } from "@sproutsocial/seeds-react-numeral";
|
|
603
|
+
var yAxisLabelFormatter = ({
|
|
604
|
+
numberLocale,
|
|
605
|
+
textLocale,
|
|
606
|
+
tickPositions,
|
|
607
|
+
value,
|
|
608
|
+
currency = "USD",
|
|
609
|
+
numberFormat = "decimal"
|
|
610
|
+
}) => {
|
|
611
|
+
const numberValue = Number(value);
|
|
612
|
+
if (numberValue === 0) {
|
|
613
|
+
return formatNumeral({
|
|
614
|
+
locale: numberLocale,
|
|
615
|
+
number: numberValue
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
if (numberFormat === "duration") {
|
|
619
|
+
return formatDuration({
|
|
620
|
+
display: "narrow",
|
|
621
|
+
locale: textLocale,
|
|
622
|
+
milliseconds: numberValue
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
const maxValue = tickPositions && tickPositions.length > 0 ? tickPositions[tickPositions.length - 1] : void 0;
|
|
626
|
+
const abbreviate = typeof maxValue === "number" && maxValue > 9999 ? 1e3 : true;
|
|
627
|
+
return formatNumeral({
|
|
628
|
+
abbreviate,
|
|
629
|
+
currency,
|
|
630
|
+
format: numberFormat,
|
|
631
|
+
locale: numberLocale,
|
|
632
|
+
number: numberValue
|
|
633
|
+
});
|
|
634
|
+
};
|
|
635
|
+
|
|
593
636
|
// src/helpers/xAxisLabelFormatter.ts
|
|
594
637
|
var xAxisLabelFormatter = ({
|
|
595
638
|
textLocale,
|
|
@@ -599,6 +642,9 @@ var xAxisLabelFormatter = ({
|
|
|
599
642
|
// optional
|
|
600
643
|
timeFormat = "12"
|
|
601
644
|
}) => {
|
|
645
|
+
if (typeof value === "string") {
|
|
646
|
+
return `<span>${value}</span>`;
|
|
647
|
+
}
|
|
602
648
|
const tickIndex = tickPositions.indexOf(value);
|
|
603
649
|
const isFirst = tickIndex === 0;
|
|
604
650
|
const previousValue = tickPositions[tickIndex - 1];
|
|
@@ -644,39 +690,227 @@ var xAxisLabelFormatter = ({
|
|
|
644
690
|
return `<span>${firstPart}</span>${secondPart ? `<span>${secondPart}</span>` : ""}`;
|
|
645
691
|
};
|
|
646
692
|
|
|
647
|
-
// src/helpers/
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
693
|
+
// src/helpers/isHourlyTimeData.ts
|
|
694
|
+
function isHourlyTimeData(data) {
|
|
695
|
+
if (!data.length) return false;
|
|
696
|
+
const xVals = data.flatMap((series) => series.points.map((p) => p.x));
|
|
697
|
+
if (!xVals.length) return false;
|
|
698
|
+
if (xVals.some((x) => typeof x === "string")) return false;
|
|
699
|
+
const dates = xVals.map((x) => {
|
|
700
|
+
const d = new Date(x);
|
|
701
|
+
return `${d.getUTCFullYear()}-${d.getUTCMonth()}-${d.getUTCDate()}`;
|
|
702
|
+
});
|
|
703
|
+
const uniqueDates = new Set(dates);
|
|
704
|
+
if (uniqueDates.size !== 1) return false;
|
|
705
|
+
return xVals.every((x) => {
|
|
706
|
+
const d = new Date(x);
|
|
707
|
+
const hour = d.getUTCHours();
|
|
708
|
+
const minutes = d.getUTCMinutes();
|
|
709
|
+
const seconds = d.getUTCSeconds();
|
|
710
|
+
return hour >= 0 && hour <= 23 && minutes === 0 && seconds === 0;
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// src/helpers/isCategoricalHourData.ts
|
|
715
|
+
function isCategoricalHourData(data) {
|
|
716
|
+
if (!data.length) return false;
|
|
717
|
+
const xVals = data.flatMap((series) => series.points.map((p) => p.x));
|
|
718
|
+
if (!xVals.length) return false;
|
|
719
|
+
if (xVals.some((x) => typeof x !== "string")) return false;
|
|
720
|
+
const hour12Pattern = /^\d{1,2} (AM|PM)$/;
|
|
721
|
+
const hour24Pattern = /^([01]?\d|2[0-3]):([0-5]\d)$/;
|
|
722
|
+
const stringValues = xVals;
|
|
723
|
+
const allMatch12Hour = stringValues.every((x) => hour12Pattern.test(x));
|
|
724
|
+
const allMatch24Hour = stringValues.every((x) => hour24Pattern.test(x));
|
|
725
|
+
return allMatch12Hour || allMatch24Hour;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// src/helpers/getStorybookRandomColor.ts
|
|
729
|
+
var getStorybookRandomColor = () => {
|
|
730
|
+
const letters = "0123456789ABCDEF";
|
|
731
|
+
let color = "#";
|
|
732
|
+
for (let i = 0; i < 6; i++) {
|
|
733
|
+
color += letters[Math.floor(Math.random() * 16)];
|
|
671
734
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
735
|
+
return color;
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
// src/helpers/getStorybookCategoricalData.ts
|
|
739
|
+
var getStorybookCategoricalData = ({
|
|
740
|
+
showNulls,
|
|
741
|
+
showNegativeValues,
|
|
742
|
+
numberOfSeries,
|
|
743
|
+
yAxisMax,
|
|
744
|
+
showCustomColors,
|
|
745
|
+
showDashedLines,
|
|
746
|
+
categoryType
|
|
747
|
+
}) => {
|
|
748
|
+
const categoryOptions = {
|
|
749
|
+
hours: [
|
|
750
|
+
"12 AM",
|
|
751
|
+
"1 AM",
|
|
752
|
+
"2 AM",
|
|
753
|
+
"3 AM",
|
|
754
|
+
"4 AM",
|
|
755
|
+
"5 AM",
|
|
756
|
+
"6 AM",
|
|
757
|
+
"7 AM",
|
|
758
|
+
"8 AM",
|
|
759
|
+
"9 AM",
|
|
760
|
+
"10 AM",
|
|
761
|
+
"11 AM",
|
|
762
|
+
"12 PM",
|
|
763
|
+
"1 PM",
|
|
764
|
+
"2 PM",
|
|
765
|
+
"3 PM",
|
|
766
|
+
"4 PM",
|
|
767
|
+
"5 PM",
|
|
768
|
+
"6 PM",
|
|
769
|
+
"7 PM",
|
|
770
|
+
"8 PM",
|
|
771
|
+
"9 PM",
|
|
772
|
+
"10 PM",
|
|
773
|
+
"11 PM"
|
|
774
|
+
],
|
|
775
|
+
hours24: [
|
|
776
|
+
"00:00",
|
|
777
|
+
"01:00",
|
|
778
|
+
"02:00",
|
|
779
|
+
"03:00",
|
|
780
|
+
"04:00",
|
|
781
|
+
"05:00",
|
|
782
|
+
"06:00",
|
|
783
|
+
"07:00",
|
|
784
|
+
"08:00",
|
|
785
|
+
"09:00",
|
|
786
|
+
"10:00",
|
|
787
|
+
"11:00",
|
|
788
|
+
"12:00",
|
|
789
|
+
"13:00",
|
|
790
|
+
"14:00",
|
|
791
|
+
"15:00",
|
|
792
|
+
"16:00",
|
|
793
|
+
"17:00",
|
|
794
|
+
"18:00",
|
|
795
|
+
"19:00",
|
|
796
|
+
"20:00",
|
|
797
|
+
"21:00",
|
|
798
|
+
"22:00",
|
|
799
|
+
"23:00"
|
|
800
|
+
],
|
|
801
|
+
days: [
|
|
802
|
+
"Monday",
|
|
803
|
+
"Tuesday",
|
|
804
|
+
"Wednesday",
|
|
805
|
+
"Thursday",
|
|
806
|
+
"Friday",
|
|
807
|
+
"Saturday",
|
|
808
|
+
"Sunday"
|
|
809
|
+
],
|
|
810
|
+
months: [
|
|
811
|
+
"January",
|
|
812
|
+
"February",
|
|
813
|
+
"March",
|
|
814
|
+
"April",
|
|
815
|
+
"May",
|
|
816
|
+
"June",
|
|
817
|
+
"July",
|
|
818
|
+
"August",
|
|
819
|
+
"September",
|
|
820
|
+
"October",
|
|
821
|
+
"November",
|
|
822
|
+
"December"
|
|
823
|
+
],
|
|
824
|
+
custom: [
|
|
825
|
+
"Category A",
|
|
826
|
+
"Category B",
|
|
827
|
+
"Category C",
|
|
828
|
+
"Category D",
|
|
829
|
+
"Category E"
|
|
830
|
+
]
|
|
831
|
+
};
|
|
832
|
+
const categories = categoryOptions[categoryType];
|
|
833
|
+
const numberOfPoints = categories.length;
|
|
834
|
+
return [...Array(numberOfSeries).keys()].map((seriesIndex) => {
|
|
835
|
+
let nullsArray = [];
|
|
836
|
+
if (showNulls) {
|
|
837
|
+
const nullsArrayLength = Math.floor(numberOfPoints / 5);
|
|
838
|
+
nullsArray = [...Array(nullsArrayLength)].map(
|
|
839
|
+
() => Math.floor(Math.random() * numberOfPoints)
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
return {
|
|
843
|
+
points: categories.map((category, pointIndex) => {
|
|
844
|
+
const showNull = nullsArray && nullsArray.length > 0 ? nullsArray.includes(pointIndex) : false;
|
|
845
|
+
const randomValue = Math.random();
|
|
846
|
+
const positiveOrNegativeYAxisMax = showNegativeValues ? randomValue < 0.5 ? -yAxisMax : yAxisMax : yAxisMax;
|
|
847
|
+
return {
|
|
848
|
+
x: category,
|
|
849
|
+
y: showNull ? null : Math.floor(randomValue * positiveOrNegativeYAxisMax)
|
|
850
|
+
};
|
|
851
|
+
}),
|
|
852
|
+
name: `Series ${seriesIndex + 1}`,
|
|
853
|
+
styles: {
|
|
854
|
+
color: showCustomColors ? getStorybookRandomColor() : void 0,
|
|
855
|
+
pattern: showDashedLines ? "dashed" : "solid"
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
});
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
// src/helpers/getStorybookSparseTimelineData.ts
|
|
862
|
+
var getStorybookSparseTimelineData = ({
|
|
863
|
+
showNulls,
|
|
864
|
+
showNegativeValues,
|
|
865
|
+
numberOfSeries,
|
|
866
|
+
yAxisMax,
|
|
867
|
+
showCustomColors,
|
|
868
|
+
showDashedLines,
|
|
869
|
+
numberOfPoints = 5,
|
|
870
|
+
timeSpanHours = 24
|
|
871
|
+
}) => {
|
|
872
|
+
const seriesNames = [
|
|
873
|
+
"Posts Published",
|
|
874
|
+
"Comments",
|
|
875
|
+
"Likes",
|
|
876
|
+
"Shares",
|
|
877
|
+
"Clicks",
|
|
878
|
+
"Views",
|
|
879
|
+
"Saves",
|
|
880
|
+
"Reposts",
|
|
881
|
+
"Mentions",
|
|
882
|
+
"Reactions"
|
|
883
|
+
];
|
|
884
|
+
const baseDate = /* @__PURE__ */ new Date("2024-01-01T00:00:00Z");
|
|
885
|
+
const timeSpanMs = timeSpanHours * 60 * 60 * 1e3;
|
|
886
|
+
return [...Array(numberOfSeries).keys()].map((seriesIndex) => {
|
|
887
|
+
let nullsArray = [];
|
|
888
|
+
if (showNulls) {
|
|
889
|
+
const nullsArrayLength = Math.floor(numberOfPoints / 5);
|
|
890
|
+
nullsArray = [...Array(nullsArrayLength)].map(
|
|
891
|
+
() => Math.floor(Math.random() * numberOfPoints)
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
const timestamps = [...Array(numberOfPoints)].map(() => {
|
|
895
|
+
const randomOffset = Math.random() * timeSpanMs;
|
|
896
|
+
return baseDate.getTime() + randomOffset;
|
|
897
|
+
}).sort((a, b) => a - b);
|
|
898
|
+
return {
|
|
899
|
+
points: timestamps.map((timestamp, pointIndex) => {
|
|
900
|
+
const showNull = nullsArray && nullsArray.length > 0 ? nullsArray.includes(pointIndex) : false;
|
|
901
|
+
const randomValue = Math.random();
|
|
902
|
+
const positiveOrNegativeYAxisMax = showNegativeValues ? randomValue < 0.5 ? -yAxisMax : yAxisMax : yAxisMax;
|
|
903
|
+
return {
|
|
904
|
+
x: timestamp,
|
|
905
|
+
y: showNull ? null : Math.floor(randomValue * positiveOrNegativeYAxisMax)
|
|
906
|
+
};
|
|
907
|
+
}),
|
|
908
|
+
name: seriesNames[seriesIndex] || `Series ${seriesIndex + 1}`,
|
|
909
|
+
styles: {
|
|
910
|
+
color: showCustomColors ? getStorybookRandomColor() : void 0,
|
|
911
|
+
pattern: showDashedLines ? "dashed" : "solid"
|
|
912
|
+
}
|
|
913
|
+
};
|
|
680
914
|
});
|
|
681
915
|
};
|
|
682
916
|
|
|
@@ -766,7 +1000,20 @@ var timeSeriesChartOptions = _.merge({}, baseChartOptions, {
|
|
|
766
1000
|
softMin: 0,
|
|
767
1001
|
title: {
|
|
768
1002
|
text: void 0
|
|
769
|
-
}
|
|
1003
|
+
},
|
|
1004
|
+
plotLines: [
|
|
1005
|
+
/* Adds a custom plotLine at y=0 to represent the chart baseline.
|
|
1006
|
+
This approach allows full control over the line's appearance (e.g., color, z-index),
|
|
1007
|
+
unlike relying on the default xAxis line, which always renders at the bottom of the chart
|
|
1008
|
+
even when y=0 appears elsewhere (e.g., with negative values).
|
|
1009
|
+
*/
|
|
1010
|
+
{
|
|
1011
|
+
className: "y-axis-zero-line",
|
|
1012
|
+
value: 0,
|
|
1013
|
+
zIndex: 3
|
|
1014
|
+
// ensures the line appears over the default y=0 line, which we can't seleect as specifically
|
|
1015
|
+
}
|
|
1016
|
+
]
|
|
770
1017
|
}
|
|
771
1018
|
});
|
|
772
1019
|
var lineChartOptions = _.merge({}, timeSeriesChartOptions, {
|
|
@@ -780,6 +1027,30 @@ var areaChartOptions = _.merge({}, timeSeriesChartOptions, {
|
|
|
780
1027
|
}
|
|
781
1028
|
}
|
|
782
1029
|
});
|
|
1030
|
+
var columnChartOptions = _.merge({}, timeSeriesChartOptions, {
|
|
1031
|
+
plotOptions: {
|
|
1032
|
+
column: {
|
|
1033
|
+
stacking: "normal",
|
|
1034
|
+
pointPadding: 0.25,
|
|
1035
|
+
groupPadding: 0.25,
|
|
1036
|
+
borderRadius: 4
|
|
1037
|
+
}
|
|
1038
|
+
},
|
|
1039
|
+
xAxis: {
|
|
1040
|
+
crosshair: false
|
|
1041
|
+
},
|
|
1042
|
+
yAxis: {
|
|
1043
|
+
plotLines: [
|
|
1044
|
+
{
|
|
1045
|
+
// For stacked column charts with visible borders (e.g., white for contrast),
|
|
1046
|
+
// we raise the zIndex of the y=0 plotLine to ensure it remains visible
|
|
1047
|
+
// and isn't visually covered by overlapping column borders.
|
|
1048
|
+
zIndex: 5
|
|
1049
|
+
}
|
|
1050
|
+
]
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
var VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT = 10;
|
|
783
1054
|
var DONUT_CHART_HALO_SIZE = 10;
|
|
784
1055
|
var DONUT_CHART_HEIGHT = 250 + DONUT_CHART_HALO_SIZE * 2;
|
|
785
1056
|
var DONUT_CHART_WIDTH = DONUT_CHART_HEIGHT;
|
|
@@ -810,10 +1081,12 @@ var useTimeSeriesChartOptions = ({
|
|
|
810
1081
|
seriesType,
|
|
811
1082
|
textLocale,
|
|
812
1083
|
currency = "USD",
|
|
1084
|
+
disableTooltips = false,
|
|
813
1085
|
numberFormat = "decimal",
|
|
814
1086
|
yAxisLabelFormatter: yAxisLabelFormatter2,
|
|
815
1087
|
onClick,
|
|
816
|
-
timeFormat = "12"
|
|
1088
|
+
timeFormat = "12",
|
|
1089
|
+
xAxisLabelFormatter: xAxisLabelFormatter2
|
|
817
1090
|
}) => {
|
|
818
1091
|
const [chart, setChart] = useState3(null);
|
|
819
1092
|
const callback = useCallback((chartInstance) => {
|
|
@@ -847,7 +1120,24 @@ var useTimeSeriesChartOptions = ({
|
|
|
847
1120
|
}
|
|
848
1121
|
};
|
|
849
1122
|
const chartMarginTop = xAnnotations ? 24 : null;
|
|
850
|
-
const
|
|
1123
|
+
const getBaseChartOptions = (type) => {
|
|
1124
|
+
switch (type) {
|
|
1125
|
+
case "areaspline":
|
|
1126
|
+
return areaChartOptions;
|
|
1127
|
+
case "spline":
|
|
1128
|
+
return lineChartOptions;
|
|
1129
|
+
case "column":
|
|
1130
|
+
return columnChartOptions;
|
|
1131
|
+
default:
|
|
1132
|
+
return lineChartOptions;
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
const baseChartOptions2 = getBaseChartOptions(seriesType);
|
|
1136
|
+
const hasCategoricalData = data.some(
|
|
1137
|
+
(series) => series.points.some((point) => typeof point.x === "string")
|
|
1138
|
+
);
|
|
1139
|
+
const categories = hasCategoricalData ? data[0]?.points.map((point) => point.x) || [] : [];
|
|
1140
|
+
const hasSparseTimelineData = !hasCategoricalData && seriesType === "column";
|
|
851
1141
|
const options = useMemo(() => {
|
|
852
1142
|
return merge({}, baseChartOptions2, {
|
|
853
1143
|
accessibility: {
|
|
@@ -888,20 +1178,101 @@ var useTimeSeriesChartOptions = ({
|
|
|
888
1178
|
return onClick({ x: event.point.x });
|
|
889
1179
|
} : void 0
|
|
890
1180
|
}
|
|
1181
|
+
},
|
|
1182
|
+
column: {
|
|
1183
|
+
// For sparse timeline data, set explicit point width to make columns wider
|
|
1184
|
+
...hasSparseTimelineData && {
|
|
1185
|
+
pointWidth: 20
|
|
1186
|
+
// Fixed width in pixels for sparse timeline data
|
|
1187
|
+
},
|
|
1188
|
+
point: {
|
|
1189
|
+
events: {
|
|
1190
|
+
/*
|
|
1191
|
+
Custom hover behavior for multi-series column charts.
|
|
1192
|
+
|
|
1193
|
+
In multi-series column charts, multiple columns
|
|
1194
|
+
can share the same x-axis position (stacked or grouped). When hovering
|
|
1195
|
+
over one column, we want ALL columns at that x-position to highlight
|
|
1196
|
+
together for better visual feedback. Simple CSS :hover only affects the
|
|
1197
|
+
individual element being hovered, not related columns at the same position.
|
|
1198
|
+
|
|
1199
|
+
This custom behavior ensures that when you hover over any column at a
|
|
1200
|
+
specific x-position, all columns at that same position get the "column-hover"
|
|
1201
|
+
class, creating a unified highlight effect across all series.
|
|
1202
|
+
*/
|
|
1203
|
+
mouseOver: function() {
|
|
1204
|
+
const x = this.x;
|
|
1205
|
+
if (this.series && this.series.chart && this.series.chart.series) {
|
|
1206
|
+
this.series.chart.series.forEach((series) => {
|
|
1207
|
+
if (series.type === "column") {
|
|
1208
|
+
series.data.forEach((point) => {
|
|
1209
|
+
if (point.x === x) {
|
|
1210
|
+
const el = point.graphic && point.graphic.element;
|
|
1211
|
+
if (el) {
|
|
1212
|
+
el.classList.add("column-hover");
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
},
|
|
1220
|
+
mouseOut: function() {
|
|
1221
|
+
if (this.series && this.series.chart && this.series.chart.series) {
|
|
1222
|
+
this.series.chart.series.forEach((series) => {
|
|
1223
|
+
if (series.type === "column") {
|
|
1224
|
+
series.data.forEach((point) => {
|
|
1225
|
+
const el = point.graphic && point.graphic.element;
|
|
1226
|
+
if (el) {
|
|
1227
|
+
el.classList.remove("column-hover");
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
891
1236
|
}
|
|
892
1237
|
},
|
|
893
1238
|
series: transformDataToSeries({ data }, seriesType),
|
|
1239
|
+
tooltip: {
|
|
1240
|
+
enabled: !disableTooltips
|
|
1241
|
+
},
|
|
894
1242
|
xAxis: {
|
|
895
1243
|
labels: {
|
|
896
1244
|
formatter: function() {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
1245
|
+
const tickPositions = (this.axis.tickPositions || []).map(
|
|
1246
|
+
Number
|
|
1247
|
+
);
|
|
1248
|
+
const value = this.value;
|
|
1249
|
+
const unitName = this.tickPositionInfo?.unitName;
|
|
1250
|
+
if (typeof xAxisLabelFormatter2 === "function") {
|
|
1251
|
+
return xAxisLabelFormatter2({
|
|
1252
|
+
textLocale,
|
|
1253
|
+
tickPositions,
|
|
1254
|
+
timeFormat,
|
|
1255
|
+
unitName,
|
|
1256
|
+
value
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
if (typeof xAxisLabelFormatterDefault === "function") {
|
|
1260
|
+
return xAxisLabelFormatterDefault({
|
|
1261
|
+
textLocale,
|
|
1262
|
+
tickPositions,
|
|
1263
|
+
timeFormat,
|
|
1264
|
+
unitName,
|
|
1265
|
+
value
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
return "";
|
|
904
1269
|
}
|
|
1270
|
+
},
|
|
1271
|
+
// Override xAxis type for categorical data
|
|
1272
|
+
...hasCategoricalData && {
|
|
1273
|
+
type: "category",
|
|
1274
|
+
categories,
|
|
1275
|
+
crosshair: false
|
|
905
1276
|
}
|
|
906
1277
|
},
|
|
907
1278
|
yAxis: {
|
|
@@ -924,8 +1295,11 @@ var useTimeSeriesChartOptions = ({
|
|
|
924
1295
|
});
|
|
925
1296
|
}, [
|
|
926
1297
|
baseChartOptions2,
|
|
1298
|
+
categories,
|
|
927
1299
|
currency,
|
|
928
1300
|
data,
|
|
1301
|
+
hasCategoricalData,
|
|
1302
|
+
hasSparseTimelineData,
|
|
929
1303
|
numberFormat,
|
|
930
1304
|
numberLocale,
|
|
931
1305
|
onClick,
|
|
@@ -933,10 +1307,12 @@ var useTimeSeriesChartOptions = ({
|
|
|
933
1307
|
textLocale,
|
|
934
1308
|
timeFormat,
|
|
935
1309
|
xAnnotations,
|
|
936
|
-
yAxisLabelFormatter2
|
|
1310
|
+
yAxisLabelFormatter2,
|
|
1311
|
+
xAxisLabelFormatter2
|
|
937
1312
|
]);
|
|
938
1313
|
return { options, chart, callback };
|
|
939
1314
|
};
|
|
1315
|
+
var xAxisLabelFormatterDefault = xAxisLabelFormatter;
|
|
940
1316
|
|
|
941
1317
|
// src/styles/chartStyles.ts
|
|
942
1318
|
import { css as css2, createGlobalStyle } from "styled-components";
|
|
@@ -955,6 +1331,8 @@ var GlobalChartStyleOverrides = createGlobalStyle`
|
|
|
955
1331
|
}
|
|
956
1332
|
`;
|
|
957
1333
|
var baseChartStyles = css2`
|
|
1334
|
+
--highcharts-background-color: ${({ theme: theme14 }) => theme14.colors.container.background.base};
|
|
1335
|
+
|
|
958
1336
|
// set color variables and map to each series
|
|
959
1337
|
${({ $colors }) => $colors.map((color, index) => {
|
|
960
1338
|
const chartColor = color || theme6.colors.DATAVIZ_COLORS_LIST[index];
|
|
@@ -998,9 +1376,11 @@ var timeSeriesChartStyles = css2`
|
|
|
998
1376
|
.highcharts-grid-line {
|
|
999
1377
|
stroke: ${({ theme: theme14 }) => theme14.colors.container.border.base};
|
|
1000
1378
|
}
|
|
1379
|
+
|
|
1001
1380
|
.highcharts-axis-line {
|
|
1002
1381
|
stroke: ${({ theme: theme14 }) => theme14.colors.container.border.base};
|
|
1003
1382
|
}
|
|
1383
|
+
|
|
1004
1384
|
.highcharts-tick {
|
|
1005
1385
|
stroke: none;
|
|
1006
1386
|
}
|
|
@@ -1041,6 +1421,10 @@ var timeSeriesChartStyles = css2`
|
|
|
1041
1421
|
fill: transparent;
|
|
1042
1422
|
cursor: pointer;
|
|
1043
1423
|
}`}
|
|
1424
|
+
|
|
1425
|
+
path.highcharts-plot-line.y-axis-zero-line {
|
|
1426
|
+
stroke: ${({ theme: theme14 }) => theme14.colors.container.border.decorative.neutral};
|
|
1427
|
+
}
|
|
1044
1428
|
`;
|
|
1045
1429
|
var lineChartStyles = css2`
|
|
1046
1430
|
${timeSeriesChartStyles}
|
|
@@ -1112,6 +1496,7 @@ var AreaChartWithData = memo14(function AreaChartWithData2({
|
|
|
1112
1496
|
tooltipTotalLabel,
|
|
1113
1497
|
// optional
|
|
1114
1498
|
currency = "USD",
|
|
1499
|
+
disableTooltips = false,
|
|
1115
1500
|
numberFormat = "decimal",
|
|
1116
1501
|
tooltip,
|
|
1117
1502
|
yAxisLabelFormatter: yAxisLabelFormatter2,
|
|
@@ -1123,6 +1508,7 @@ var AreaChartWithData = memo14(function AreaChartWithData2({
|
|
|
1123
1508
|
const { options, chart, callback } = useTimeSeriesChartOptions({
|
|
1124
1509
|
currency,
|
|
1125
1510
|
data,
|
|
1511
|
+
disableTooltips,
|
|
1126
1512
|
numberFormat,
|
|
1127
1513
|
numberLocale,
|
|
1128
1514
|
seriesType: "areaspline",
|
|
@@ -1159,7 +1545,7 @@ var AreaChartWithData = memo14(function AreaChartWithData2({
|
|
|
1159
1545
|
annotationContext: chart.annotations?.[0]
|
|
1160
1546
|
}
|
|
1161
1547
|
) : null,
|
|
1162
|
-
chart ? /* @__PURE__ */ jsx15(
|
|
1548
|
+
chart && !disableTooltips ? /* @__PURE__ */ jsx15(
|
|
1163
1549
|
ChartTooltipPortal,
|
|
1164
1550
|
{
|
|
1165
1551
|
chart,
|
|
@@ -1315,6 +1701,7 @@ var DonutChartWithData = memo17(
|
|
|
1315
1701
|
textLocale = "en-us",
|
|
1316
1702
|
// optional
|
|
1317
1703
|
currency = "USD",
|
|
1704
|
+
disableTooltips = false,
|
|
1318
1705
|
hideLegend = false,
|
|
1319
1706
|
numberFormat = "decimal",
|
|
1320
1707
|
tooltip
|
|
@@ -1362,7 +1749,10 @@ var DonutChartWithData = memo17(
|
|
|
1362
1749
|
};
|
|
1363
1750
|
})
|
|
1364
1751
|
}
|
|
1365
|
-
]
|
|
1752
|
+
],
|
|
1753
|
+
tooltip: {
|
|
1754
|
+
enabled: !disableTooltips
|
|
1755
|
+
}
|
|
1366
1756
|
});
|
|
1367
1757
|
}, [data]);
|
|
1368
1758
|
const colors = data.map(
|
|
@@ -1379,7 +1769,7 @@ var DonutChartWithData = memo17(
|
|
|
1379
1769
|
callback
|
|
1380
1770
|
}
|
|
1381
1771
|
),
|
|
1382
|
-
chart ? /* @__PURE__ */ jsx18(
|
|
1772
|
+
chart && !disableTooltips ? /* @__PURE__ */ jsx18(
|
|
1383
1773
|
ChartTooltipPortal,
|
|
1384
1774
|
{
|
|
1385
1775
|
chart,
|
|
@@ -1601,6 +1991,7 @@ var LineChartWithData = memo21(function LineChartWithData2({
|
|
|
1601
1991
|
tooltipDateFormatter,
|
|
1602
1992
|
// optional
|
|
1603
1993
|
currency = "USD",
|
|
1994
|
+
disableTooltips = false,
|
|
1604
1995
|
numberFormat = "decimal",
|
|
1605
1996
|
tooltip,
|
|
1606
1997
|
yAxisLabelFormatter: yAxisLabelFormatter2,
|
|
@@ -1612,6 +2003,7 @@ var LineChartWithData = memo21(function LineChartWithData2({
|
|
|
1612
2003
|
const { options, chart, callback } = useTimeSeriesChartOptions({
|
|
1613
2004
|
currency,
|
|
1614
2005
|
data,
|
|
2006
|
+
disableTooltips,
|
|
1615
2007
|
numberFormat,
|
|
1616
2008
|
numberLocale,
|
|
1617
2009
|
seriesType: "spline",
|
|
@@ -1659,7 +2051,7 @@ var LineChartWithData = memo21(function LineChartWithData2({
|
|
|
1659
2051
|
annotationContext: chart.annotations?.[0]
|
|
1660
2052
|
}
|
|
1661
2053
|
) : null,
|
|
1662
|
-
chart ? /* @__PURE__ */ jsx22(
|
|
2054
|
+
chart && !disableTooltips ? /* @__PURE__ */ jsx22(
|
|
1663
2055
|
ChartTooltipPortal,
|
|
1664
2056
|
{
|
|
1665
2057
|
chart,
|
|
@@ -1717,18 +2109,25 @@ export {
|
|
|
1717
2109
|
LineChart,
|
|
1718
2110
|
NetworkColorBox,
|
|
1719
2111
|
TIME_SERIES_CHART_HEIGHT,
|
|
2112
|
+
VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT,
|
|
1720
2113
|
areaChartOptions,
|
|
1721
2114
|
areaChartStyles,
|
|
1722
2115
|
baseChartOptions,
|
|
1723
2116
|
baseChartStyles,
|
|
2117
|
+
columnChartOptions,
|
|
1724
2118
|
donutChartOptions,
|
|
1725
2119
|
donutChartStyles,
|
|
1726
2120
|
generateChartTooltipPortalId,
|
|
1727
2121
|
getDatavizColor,
|
|
1728
2122
|
getDatavizColorWithAlpha,
|
|
1729
2123
|
getDatavizOpacity,
|
|
2124
|
+
getStorybookCategoricalData,
|
|
2125
|
+
getStorybookSparseTimelineData,
|
|
2126
|
+
isCategoricalHourData,
|
|
2127
|
+
isHourlyTimeData,
|
|
1730
2128
|
lineChartOptions,
|
|
1731
2129
|
lineChartStyles,
|
|
2130
|
+
timeSeriesChartOptions,
|
|
1732
2131
|
timeSeriesChartStyles,
|
|
1733
2132
|
transformDataToSeries,
|
|
1734
2133
|
transformTimeSeriesTooltipData,
|