@sproutsocial/seeds-react-data-viz 0.16.1 → 0.17.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.
Files changed (56) hide show
  1. package/dist/annotations-CjFoRPXf.d.mts +20 -0
  2. package/dist/annotations-CjFoRPXf.d.ts +20 -0
  3. package/dist/axis-WOeYkTO1.d.mts +44 -0
  4. package/dist/axis-WOeYkTO1.d.ts +44 -0
  5. package/dist/bar/index.d.mts +3 -1
  6. package/dist/bar/index.d.ts +3 -1
  7. package/dist/bar/index.js +15 -8
  8. package/dist/bar/index.js.map +1 -1
  9. package/dist/{axis-BVPkC6iF.d.ts → chartBase-C-l7yYGx.d.ts} +5 -59
  10. package/dist/{axis-BjucJt39.d.mts → chartBase-Cn_5CUJi.d.mts} +5 -59
  11. package/dist/chunk-6D7P3IOT.js +150 -0
  12. package/dist/chunk-6D7P3IOT.js.map +1 -0
  13. package/dist/chunk-CYQXUAJC.js +169 -0
  14. package/dist/chunk-CYQXUAJC.js.map +1 -0
  15. package/dist/{chunk-EJYDQYLE.js → chunk-HDEKK4W4.js} +101 -248
  16. package/dist/chunk-HDEKK4W4.js.map +1 -0
  17. package/dist/chunk-QKH2ZO2D.js +68 -0
  18. package/dist/chunk-QKH2ZO2D.js.map +1 -0
  19. package/dist/donut/index.d.mts +48 -0
  20. package/dist/donut/index.d.ts +48 -0
  21. package/dist/donut/index.js +125 -0
  22. package/dist/donut/index.js.map +1 -0
  23. package/dist/esm/bar/index.js +13 -6
  24. package/dist/esm/bar/index.js.map +1 -1
  25. package/dist/esm/chunk-NAKJY5PA.js +150 -0
  26. package/dist/esm/chunk-NAKJY5PA.js.map +1 -0
  27. package/dist/esm/chunk-O5VJGGZY.js +68 -0
  28. package/dist/esm/chunk-O5VJGGZY.js.map +1 -0
  29. package/dist/esm/{chunk-DKTW56NJ.js → chunk-TKNWM7L3.js} +102 -249
  30. package/dist/esm/chunk-TKNWM7L3.js.map +1 -0
  31. package/dist/esm/chunk-XMYGML25.js +169 -0
  32. package/dist/esm/chunk-XMYGML25.js.map +1 -0
  33. package/dist/esm/donut/index.js +125 -0
  34. package/dist/esm/donut/index.js.map +1 -0
  35. package/dist/esm/index.js +13 -157
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/line-area/index.js +14 -6
  38. package/dist/esm/line-area/index.js.map +1 -1
  39. package/dist/esm/sparkline/index.js +123 -0
  40. package/dist/esm/sparkline/index.js.map +1 -0
  41. package/dist/index.d.mts +3 -0
  42. package/dist/index.d.ts +3 -0
  43. package/dist/index.js +55 -199
  44. package/dist/index.js.map +1 -1
  45. package/dist/line-area/index.d.mts +6 -3
  46. package/dist/line-area/index.d.ts +6 -3
  47. package/dist/line-area/index.js +16 -8
  48. package/dist/line-area/index.js.map +1 -1
  49. package/dist/sparkline/index.d.mts +75 -0
  50. package/dist/sparkline/index.d.ts +75 -0
  51. package/dist/sparkline/index.js +123 -0
  52. package/dist/sparkline/index.js.map +1 -0
  53. package/dist/sparkline.css +76 -0
  54. package/package.json +22 -11
  55. package/dist/chunk-EJYDQYLE.js.map +0 -1
  56. package/dist/esm/chunk-DKTW56NJ.js.map +0 -1
@@ -0,0 +1,169 @@
1
+ // src/constants/chartOptions.ts
2
+ import _ from "lodash";
3
+ var baseChartOptions = {
4
+ chart: {
5
+ animation: false,
6
+ styledMode: true
7
+ },
8
+ credits: {
9
+ enabled: false
10
+ },
11
+ exporting: {
12
+ enabled: false,
13
+ fallbackToExportServer: false
14
+ },
15
+ legend: {
16
+ enabled: false
17
+ },
18
+ title: {
19
+ text: void 0
20
+ },
21
+ tooltip: {
22
+ hideDelay: 0,
23
+ outside: true,
24
+ padding: 0,
25
+ shape: "rect",
26
+ shared: true,
27
+ useHTML: true
28
+ }
29
+ };
30
+ var TIME_SERIES_CHART_HEIGHT = 275;
31
+ var timeSeriesChartOptions = _.merge({}, baseChartOptions, {
32
+ annotations: [
33
+ {
34
+ draggable: "",
35
+ labelOptions: {
36
+ useHTML: true,
37
+ padding: 0
38
+ // removes "left" property padding created by highcharts so that label is centered
39
+ }
40
+ }
41
+ ],
42
+ chart: {
43
+ // events.click is set at the component level because of the optional onClick prop
44
+ height: TIME_SERIES_CHART_HEIGHT,
45
+ spacing: [5, 1, 0, 2]
46
+ },
47
+ plotOptions: {
48
+ series: {
49
+ animation: false,
50
+ clip: false,
51
+ marker: {
52
+ enabled: false,
53
+ states: {
54
+ hover: {
55
+ enabled: false
56
+ }
57
+ }
58
+ }
59
+ }
60
+ },
61
+ xAxis: {
62
+ crosshair: {
63
+ zIndex: 3
64
+ },
65
+ minPadding: 0,
66
+ // must be handled dynamically instead of css
67
+ maxPadding: 0,
68
+ // must be handled dynamically instead of css
69
+ type: "datetime",
70
+ labels: {
71
+ useHTML: true
72
+ // formatter is set at the component level because of the required text locale prop
73
+ }
74
+ },
75
+ yAxis: {
76
+ labels: {
77
+ useHTML: true
78
+ // formatter is set at the component level because of the optional yAxisLabelFormatter prop
79
+ },
80
+ softMax: 0,
81
+ softMin: 0,
82
+ title: {
83
+ text: void 0
84
+ },
85
+ plotLines: [
86
+ /* Adds a custom plotLine at y=0 to represent the chart baseline.
87
+ This approach allows full control over the line's appearance (e.g., color, z-index),
88
+ unlike relying on the default xAxis line, which always renders at the bottom of the chart
89
+ even when y=0 appears elsewhere (e.g., with negative values).
90
+ */
91
+ {
92
+ className: "y-axis-zero-line",
93
+ value: 0,
94
+ zIndex: 3
95
+ // ensures the line appears over the default y=0 line, which we can't seleect as specifically
96
+ }
97
+ ]
98
+ }
99
+ });
100
+ var lineChartOptions = _.merge({}, timeSeriesChartOptions, {
101
+ // plotOptions.spline.events.click is set at the component level because of the optional onClick prop
102
+ });
103
+ var areaChartOptions = _.merge({}, timeSeriesChartOptions, {
104
+ plotOptions: {
105
+ areaspline: {
106
+ // events.click is set at the component level because of the optional onClick prop
107
+ stacking: "normal"
108
+ }
109
+ }
110
+ });
111
+ var columnChartOptions = _.merge({}, timeSeriesChartOptions, {
112
+ plotOptions: {
113
+ column: {
114
+ stacking: "normal",
115
+ pointPadding: 0.25,
116
+ groupPadding: 0.25,
117
+ borderRadius: 4
118
+ }
119
+ },
120
+ xAxis: {
121
+ crosshair: false
122
+ },
123
+ yAxis: {
124
+ plotLines: [
125
+ {
126
+ // For stacked column charts with visible borders (e.g., white for contrast),
127
+ // we raise the zIndex of the y=0 plotLine to ensure it remains visible
128
+ // and isn't visually covered by overlapping column borders.
129
+ zIndex: 5
130
+ }
131
+ ]
132
+ }
133
+ });
134
+ var VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT = 10;
135
+ var DONUT_CHART_HALO_SIZE = 10;
136
+ var DONUT_CHART_HEIGHT = 250 + DONUT_CHART_HALO_SIZE * 2;
137
+ var DONUT_CHART_WIDTH = DONUT_CHART_HEIGHT;
138
+ var donutChartOptions = _.merge({}, baseChartOptions, {
139
+ chart: {
140
+ height: DONUT_CHART_HEIGHT,
141
+ spacing: [0, 0, 0, 0]
142
+ },
143
+ plotOptions: {
144
+ pie: {
145
+ animation: false,
146
+ borderRadius: 0,
147
+ // must be handled here instead of css because of path rendering
148
+ dataLabels: {
149
+ enabled: false
150
+ },
151
+ innerSize: "50%"
152
+ }
153
+ }
154
+ });
155
+
156
+ export {
157
+ baseChartOptions,
158
+ TIME_SERIES_CHART_HEIGHT,
159
+ timeSeriesChartOptions,
160
+ lineChartOptions,
161
+ areaChartOptions,
162
+ columnChartOptions,
163
+ VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT,
164
+ DONUT_CHART_HALO_SIZE,
165
+ DONUT_CHART_HEIGHT,
166
+ DONUT_CHART_WIDTH,
167
+ donutChartOptions
168
+ };
169
+ //# sourceMappingURL=chunk-XMYGML25.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants/chartOptions.ts"],"sourcesContent":["import type { Options } from \"highcharts\";\nimport _ from \"lodash\";\n\n// options that should apply to all charts\n// this is being exported because it's needed for the listening bubble chart component.\n// when that components gets moved into the data-viz package, we can remove the export here\nexport const baseChartOptions: Options = {\n chart: {\n animation: false,\n styledMode: true,\n },\n credits: {\n enabled: false,\n },\n exporting: {\n enabled: false,\n fallbackToExportServer: false,\n },\n legend: {\n enabled: false,\n },\n title: {\n text: undefined,\n },\n tooltip: {\n hideDelay: 0,\n outside: true,\n padding: 0,\n shape: \"rect\",\n shared: true,\n useHTML: true,\n },\n};\n\n// options that should apply to time series charts\nexport const TIME_SERIES_CHART_HEIGHT = 275;\nexport const timeSeriesChartOptions: Options = _.merge({}, baseChartOptions, {\n annotations: [\n {\n draggable: \"\",\n labelOptions: {\n useHTML: true,\n padding: 0, // removes \"left\" property padding created by highcharts so that label is centered\n },\n },\n ],\n chart: {\n // events.click is set at the component level because of the optional onClick prop\n height: TIME_SERIES_CHART_HEIGHT,\n spacing: [5, 1, 0, 2],\n },\n plotOptions: {\n series: {\n animation: false,\n clip: false,\n marker: {\n enabled: false,\n states: {\n hover: {\n enabled: false,\n },\n },\n },\n },\n },\n xAxis: {\n crosshair: {\n zIndex: 3,\n },\n minPadding: 0, // must be handled dynamically instead of css\n maxPadding: 0, // must be handled dynamically instead of css\n type: \"datetime\",\n labels: {\n useHTML: true,\n // formatter is set at the component level because of the required text locale prop\n },\n },\n yAxis: {\n labels: {\n useHTML: true,\n // formatter is set at the component level because of the optional yAxisLabelFormatter prop\n },\n softMax: 0,\n softMin: 0,\n title: {\n text: undefined,\n },\n plotLines: [\n /* Adds a custom plotLine at y=0 to represent the chart baseline.\n This approach allows full control over the line's appearance (e.g., color, z-index),\n unlike relying on the default xAxis line, which always renders at the bottom of the chart\n even when y=0 appears elsewhere (e.g., with negative values).\n */\n {\n className: \"y-axis-zero-line\",\n value: 0,\n zIndex: 3, // ensures the line appears over the default y=0 line, which we can't seleect as specifically\n },\n ],\n },\n});\n\n// options that should apply to LineChart\nexport const lineChartOptions: Options = _.merge({}, timeSeriesChartOptions, {\n // plotOptions.spline.events.click is set at the component level because of the optional onClick prop\n});\n\n// options that should apply to AreaChart\nexport const areaChartOptions: Options = _.merge({}, timeSeriesChartOptions, {\n plotOptions: {\n areaspline: {\n // events.click is set at the component level because of the optional onClick prop\n stacking: \"normal\",\n },\n },\n});\n\nexport const columnChartOptions: Options = _.merge({}, timeSeriesChartOptions, {\n plotOptions: {\n column: {\n stacking: \"normal\",\n pointPadding: 0.25,\n groupPadding: 0.25,\n borderRadius: 4,\n },\n },\n xAxis: {\n crosshair: false,\n },\n yAxis: {\n plotLines: [\n {\n // For stacked column charts with visible borders (e.g., white for contrast),\n // we raise the zIndex of the y=0 plotLine to ensure it remains visible\n // and isn't visually covered by overlapping column borders.\n zIndex: 5,\n },\n ],\n },\n});\n\n/**\n * The default series limit for VerticalBarChart.\n * This limit is recommended to maintain chart readability and accessibility.\n * @see {VerticalBarChart}\n */\nexport const VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT = 10;\n\n// options that should apply to DonutChart\nexport const DONUT_CHART_HALO_SIZE = 10; // 10 is the default from highcharts\nexport const DONUT_CHART_HEIGHT = 250 + DONUT_CHART_HALO_SIZE * 2;\nexport const DONUT_CHART_WIDTH = DONUT_CHART_HEIGHT;\nexport const donutChartOptions: Options = _.merge({}, baseChartOptions, {\n chart: {\n height: DONUT_CHART_HEIGHT,\n spacing: [0, 0, 0, 0],\n },\n plotOptions: {\n pie: {\n animation: false,\n borderRadius: 0, // must be handled here instead of css because of path rendering\n dataLabels: {\n enabled: false,\n },\n innerSize: \"50%\",\n },\n },\n});\n"],"mappings":";AACA,OAAO,OAAO;AAKP,IAAM,mBAA4B;AAAA,EACvC,OAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EACA,SAAS;AAAA,IACP,SAAS;AAAA,EACX;AAAA,EACA,WAAW;AAAA,IACT,SAAS;AAAA,IACT,wBAAwB;AAAA,EAC1B;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EAC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BAA4B,EAAE,MAAM,CAAC,GAAG,wBAAwB;AAAA,EAC3E,aAAa;AAAA,IACX,YAAY;AAAA;AAAA,MAEV,UAAU;AAAA,IACZ;AAAA,EACF;AACF,CAAC;AAEM,IAAM,qBAA8B,EAAE,MAAM,CAAC,GAAG,wBAAwB;AAAA,EAC7E,aAAa;AAAA,IACX,QAAQ;AAAA,MACN,UAAU;AAAA,MACV,cAAc;AAAA,MACd,cAAc;AAAA,MACd,cAAc;AAAA,IAChB;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,EACb;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,MACT;AAAA;AAAA;AAAA;AAAA,QAIE,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAOM,IAAM,0CAA0C;AAGhD,IAAM,wBAAwB;AAC9B,IAAM,qBAAqB,MAAM,wBAAwB;AACzD,IAAM,oBAAoB;AAC1B,IAAM,oBAA6B,EAAE,MAAM,CAAC,GAAG,kBAAkB;AAAA,EACtE,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,SAAS,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,EACtB;AAAA,EACA,aAAa;AAAA,IACX,KAAK;AAAA,MACH,WAAW;AAAA,MACX,cAAc;AAAA;AAAA,MACd,YAAY;AAAA,QACV,SAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,IACb;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -0,0 +1,125 @@
1
+ import {
2
+ DONUT_CHART_HEIGHT
3
+ } from "../chunk-XMYGML25.js";
4
+ import {
5
+ ChartRenderer,
6
+ buildBaseChartOptions,
7
+ useSeedsChartSetup
8
+ } from "../chunk-TKNWM7L3.js";
9
+ import {
10
+ donutChartStyles
11
+ } from "../chunk-Z4LOM4OZ.js";
12
+
13
+ // src/charts/donut/DonutChart.tsx
14
+ import { memo, useMemo } from "react";
15
+
16
+ // src/charts/donut/adapter.ts
17
+ function buildDonutOptions(props, colors) {
18
+ const base = buildBaseChartOptions({
19
+ type: "pie",
20
+ description: props.description
21
+ });
22
+ return {
23
+ ...base,
24
+ chart: {
25
+ type: "pie",
26
+ styledMode: true,
27
+ animation: false,
28
+ // Height only — width is left fluid (v1 parity) so the chart fills its
29
+ // container and the pie auto-centers. The container bounds the width (see
30
+ // styles.ts) so the legend below wraps to the donut and centers with it.
31
+ height: DONUT_CHART_HEIGHT,
32
+ // Drop Highcharts' default spacing so the donut uses the full height.
33
+ spacing: [0, 0, 0, 0]
34
+ },
35
+ plotOptions: {
36
+ pie: {
37
+ animation: false,
38
+ // borderRadius must be set in JS, not CSS, because Highcharts computes
39
+ // the arc path before applying it — CSS border-radius has no effect.
40
+ borderRadius: 0,
41
+ dataLabels: { enabled: false },
42
+ innerSize: "50%",
43
+ ...props.onClick ? {
44
+ point: {
45
+ events: {
46
+ click() {
47
+ props.onClick?.({ position: this.name });
48
+ }
49
+ }
50
+ }
51
+ } : {}
52
+ }
53
+ },
54
+ series: [
55
+ {
56
+ type: "pie",
57
+ name: "Data",
58
+ data: props.data.map((d, i) => ({
59
+ name: d.name,
60
+ y: d.value,
61
+ color: d.color ?? colors[i] ?? ""
62
+ }))
63
+ }
64
+ ]
65
+ };
66
+ }
67
+
68
+ // src/charts/donut/styles.ts
69
+ import styled from "styled-components";
70
+ var DonutChartContainer = styled.div`
71
+ background-color: ${({ theme }) => theme.colors.container.background.base};
72
+ ${donutChartStyles}
73
+
74
+ /* Dim non-hovered slices. Highcharts adds .highcharts-point-inactive to
75
+ all pie points except the hovered one. In styledMode, opacity is CSS-only
76
+ (JS plotOptions.states.inactive.opacity is ignored). */
77
+ .highcharts-pie-series .highcharts-point-inactive {
78
+ opacity: 0.3;
79
+ transition: opacity 0s;
80
+ }
81
+ `;
82
+
83
+ // src/charts/donut/DonutChart.tsx
84
+ import { jsx } from "react/jsx-runtime";
85
+ var DonutChart = memo(function DonutChart2(props) {
86
+ const { colors } = useSeedsChartSetup({
87
+ series: props.data.map((d) => ({ color: d.color }))
88
+ });
89
+ const options = useMemo(
90
+ () => buildDonutOptions(props, colors),
91
+ [props, colors]
92
+ );
93
+ const hasOnClick = Boolean(props.onClick);
94
+ const tooltip = props.tooltip ? (args) => props.tooltip(args) : void 0;
95
+ return /* @__PURE__ */ jsx(
96
+ DonutChartContainer,
97
+ {
98
+ $colors: colors,
99
+ $hasOnClick: hasOnClick,
100
+ className: props.className,
101
+ children: /* @__PURE__ */ jsx(
102
+ ChartRenderer,
103
+ {
104
+ options,
105
+ series: props.data.map((d, i) => ({
106
+ name: d.name,
107
+ color: colors[i],
108
+ icon: d.icon
109
+ })),
110
+ colors,
111
+ tooltip,
112
+ hasOnClick,
113
+ tooltipClickLabel: props.tooltipClickLabel,
114
+ invalidNumberLabel: props.invalidNumberLabel,
115
+ valueFormat: props.format,
116
+ onReady: props.onReady
117
+ }
118
+ )
119
+ }
120
+ );
121
+ });
122
+ export {
123
+ DonutChart
124
+ };
125
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/charts/donut/DonutChart.tsx","../../../src/charts/donut/adapter.ts","../../../src/charts/donut/styles.ts"],"sourcesContent":["import { memo, useMemo } from \"react\";\nimport {\n useSeedsChartSetup,\n ChartRenderer,\n type ChartTooltipProps,\n} from \"../shared/chartBase\";\nimport { buildDonutOptions } from \"./adapter\";\nimport { DonutChartContainer } from \"./styles\";\nimport type { DonutChartProps, DonutChartTooltipProps } from \"./types\";\n\nexport const DonutChart = memo(function DonutChart(props: DonutChartProps) {\n // Map each data item to { color? } so useSeedsChartSetup resolves the palette.\n const { colors } = useSeedsChartSetup({\n series: props.data.map((d) => ({ color: d.color })),\n });\n\n // Memoize to avoid spurious Highcharts redraws on parent re-renders.\n const options = useMemo(\n () => buildDonutOptions(props, colors),\n [props, colors]\n );\n const hasOnClick = Boolean(props.onClick);\n\n // `ChartRenderer` expects `(ChartTooltipProps) => ReactNode`. The consumer's\n // function expects the narrower `DonutChartTooltipProps` (required `percent`).\n // Wrap rather than cast the function type so the intent is explicit.\n const tooltip = props.tooltip\n ? (args: ChartTooltipProps) =>\n props.tooltip!(args as unknown as DonutChartTooltipProps)\n : undefined;\n\n return (\n <DonutChartContainer\n $colors={colors}\n $hasOnClick={hasOnClick}\n className={props.className}\n >\n <ChartRenderer\n options={options}\n series={props.data.map((d, i) => ({\n name: d.name,\n color: colors[i],\n icon: d.icon,\n }))}\n colors={colors}\n tooltip={tooltip}\n hasOnClick={hasOnClick}\n tooltipClickLabel={props.tooltipClickLabel}\n invalidNumberLabel={props.invalidNumberLabel}\n valueFormat={props.format}\n onReady={props.onReady}\n />\n </DonutChartContainer>\n );\n});\n","import type { SeedsChartOptions } from \"../shared/chartBase\";\nimport { buildBaseChartOptions } from \"../shared/baseChartOptions\";\nimport { DONUT_CHART_HEIGHT } from \"../../constants/chartOptions\";\nimport type { DonutChartProps } from \"./types\";\n\nexport function buildDonutOptions(\n props: DonutChartProps,\n colors: ReadonlyArray<string>\n): SeedsChartOptions {\n const base = buildBaseChartOptions({\n type: \"pie\",\n description: props.description,\n });\n return {\n ...base,\n chart: {\n type: \"pie\" as const,\n styledMode: true,\n animation: false,\n // Height only — width is left fluid (v1 parity) so the chart fills its\n // container and the pie auto-centers. The container bounds the width (see\n // styles.ts) so the legend below wraps to the donut and centers with it.\n height: DONUT_CHART_HEIGHT,\n // Drop Highcharts' default spacing so the donut uses the full height.\n spacing: [0, 0, 0, 0],\n },\n plotOptions: {\n pie: {\n animation: false,\n // borderRadius must be set in JS, not CSS, because Highcharts computes\n // the arc path before applying it — CSS border-radius has no effect.\n borderRadius: 0,\n dataLabels: { enabled: false },\n innerSize: \"50%\",\n ...(props.onClick\n ? {\n point: {\n events: {\n click(this: { name: string }) {\n props.onClick?.({ position: this.name });\n },\n },\n },\n }\n : {}),\n },\n },\n series: [\n {\n type: \"pie\",\n name: \"Data\",\n data: props.data.map((d, i) => ({\n name: d.name,\n y: d.value,\n color: d.color ?? colors[i] ?? \"\",\n })),\n },\n ],\n };\n}\n","import styled from \"styled-components\";\nimport { donutChartStyles } from \"../../styles/chartStyles\";\nimport type {\n TypeChartStyleColor,\n TypeChartStyleHasOnClick,\n} from \"../../types\";\n\ntype StyleProps = Readonly<{\n $colors: ReadonlyArray<TypeChartStyleColor>;\n $hasOnClick: TypeChartStyleHasOnClick;\n}>;\n\n// Plain styled `div` — not `Box`. Per the DS Tailwind direction (established in\n// CE-28/line-area), new components render semantic elements internally.\n//\n// No width constraint (v1 parity): the chart fills the container and the pie\n// auto-centers, while the legend centers in the same width — so the legend\n// stays on one row and centers with the donut instead of wrapping to match it.\nexport const DonutChartContainer = styled.div<StyleProps>`\n background-color: ${({ theme }) => theme.colors.container.background.base};\n ${donutChartStyles}\n\n /* Dim non-hovered slices. Highcharts adds .highcharts-point-inactive to\n all pie points except the hovered one. In styledMode, opacity is CSS-only\n (JS plotOptions.states.inactive.opacity is ignored). */\n .highcharts-pie-series .highcharts-point-inactive {\n opacity: 0.3;\n transition: opacity 0s;\n }\n`;\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,MAAM,eAAe;;;ACKvB,SAAS,kBACd,OACA,QACmB;AACnB,QAAM,OAAO,sBAAsB;AAAA,IACjC,MAAM;AAAA,IACN,aAAa,MAAM;AAAA,EACrB,CAAC;AACD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO;AAAA,MACL,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,WAAW;AAAA;AAAA;AAAA;AAAA,MAIX,QAAQ;AAAA;AAAA,MAER,SAAS,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,IACtB;AAAA,IACA,aAAa;AAAA,MACX,KAAK;AAAA,QACH,WAAW;AAAA;AAAA;AAAA,QAGX,cAAc;AAAA,QACd,YAAY,EAAE,SAAS,MAAM;AAAA,QAC7B,WAAW;AAAA,QACX,GAAI,MAAM,UACN;AAAA,UACE,OAAO;AAAA,YACL,QAAQ;AAAA,cACN,QAA8B;AAC5B,sBAAM,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ACV,EAAE;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA,mBAAmB,MAAM;AAAA,UACzB,oBAAoB,MAAM;AAAA,UAC1B,aAAa,MAAM;AAAA,UACnB,SAAS,MAAM;AAAA;AAAA,MACjB;AAAA;AAAA,EACF;AAEJ,CAAC;","names":["DonutChart"]}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,16 @@
1
+ import {
2
+ DONUT_CHART_HALO_SIZE,
3
+ DONUT_CHART_HEIGHT,
4
+ DONUT_CHART_WIDTH,
5
+ TIME_SERIES_CHART_HEIGHT,
6
+ VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT,
7
+ areaChartOptions,
8
+ baseChartOptions,
9
+ columnChartOptions,
10
+ donutChartOptions,
11
+ lineChartOptions,
12
+ timeSeriesChartOptions
13
+ } from "./chunk-XMYGML25.js";
1
14
  import {
2
15
  ChartLegend,
3
16
  ChartLegendLabel,
@@ -215,163 +228,6 @@ var ChartXAnnotationMarkerPortal = memo3(
215
228
 
216
229
  // src/hooks/useTimeSeriesChartOptions.ts
217
230
  import { useState as useState2, useCallback, useMemo } from "react";
218
-
219
- // src/constants/chartOptions.ts
220
- import _ from "lodash";
221
- var baseChartOptions = {
222
- chart: {
223
- animation: false,
224
- styledMode: true
225
- },
226
- credits: {
227
- enabled: false
228
- },
229
- exporting: {
230
- enabled: false,
231
- fallbackToExportServer: false
232
- },
233
- legend: {
234
- enabled: false
235
- },
236
- title: {
237
- text: void 0
238
- },
239
- tooltip: {
240
- hideDelay: 0,
241
- outside: true,
242
- padding: 0,
243
- shape: "rect",
244
- shared: true,
245
- useHTML: true
246
- }
247
- };
248
- var TIME_SERIES_CHART_HEIGHT = 275;
249
- var timeSeriesChartOptions = _.merge({}, baseChartOptions, {
250
- annotations: [
251
- {
252
- draggable: "",
253
- labelOptions: {
254
- useHTML: true,
255
- padding: 0
256
- // removes "left" property padding created by highcharts so that label is centered
257
- }
258
- }
259
- ],
260
- chart: {
261
- // events.click is set at the component level because of the optional onClick prop
262
- height: TIME_SERIES_CHART_HEIGHT,
263
- spacing: [5, 1, 0, 2]
264
- },
265
- plotOptions: {
266
- series: {
267
- animation: false,
268
- clip: false,
269
- marker: {
270
- enabled: false,
271
- states: {
272
- hover: {
273
- enabled: false
274
- }
275
- }
276
- }
277
- }
278
- },
279
- xAxis: {
280
- crosshair: {
281
- zIndex: 3
282
- },
283
- minPadding: 0,
284
- // must be handled dynamically instead of css
285
- maxPadding: 0,
286
- // must be handled dynamically instead of css
287
- type: "datetime",
288
- labels: {
289
- useHTML: true
290
- // formatter is set at the component level because of the required text locale prop
291
- }
292
- },
293
- yAxis: {
294
- labels: {
295
- useHTML: true
296
- // formatter is set at the component level because of the optional yAxisLabelFormatter prop
297
- },
298
- softMax: 0,
299
- softMin: 0,
300
- title: {
301
- text: void 0
302
- },
303
- plotLines: [
304
- /* Adds a custom plotLine at y=0 to represent the chart baseline.
305
- This approach allows full control over the line's appearance (e.g., color, z-index),
306
- unlike relying on the default xAxis line, which always renders at the bottom of the chart
307
- even when y=0 appears elsewhere (e.g., with negative values).
308
- */
309
- {
310
- className: "y-axis-zero-line",
311
- value: 0,
312
- zIndex: 3
313
- // ensures the line appears over the default y=0 line, which we can't seleect as specifically
314
- }
315
- ]
316
- }
317
- });
318
- var lineChartOptions = _.merge({}, timeSeriesChartOptions, {
319
- // plotOptions.spline.events.click is set at the component level because of the optional onClick prop
320
- });
321
- var areaChartOptions = _.merge({}, timeSeriesChartOptions, {
322
- plotOptions: {
323
- areaspline: {
324
- // events.click is set at the component level because of the optional onClick prop
325
- stacking: "normal"
326
- }
327
- }
328
- });
329
- var columnChartOptions = _.merge({}, timeSeriesChartOptions, {
330
- plotOptions: {
331
- column: {
332
- stacking: "normal",
333
- pointPadding: 0.25,
334
- groupPadding: 0.25,
335
- borderRadius: 4
336
- }
337
- },
338
- xAxis: {
339
- crosshair: false
340
- },
341
- yAxis: {
342
- plotLines: [
343
- {
344
- // For stacked column charts with visible borders (e.g., white for contrast),
345
- // we raise the zIndex of the y=0 plotLine to ensure it remains visible
346
- // and isn't visually covered by overlapping column borders.
347
- zIndex: 5
348
- }
349
- ]
350
- }
351
- });
352
- var VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT = 10;
353
- var DONUT_CHART_HALO_SIZE = 10;
354
- var DONUT_CHART_HEIGHT = 250 + DONUT_CHART_HALO_SIZE * 2;
355
- var DONUT_CHART_WIDTH = DONUT_CHART_HEIGHT;
356
- var donutChartOptions = _.merge({}, baseChartOptions, {
357
- chart: {
358
- height: DONUT_CHART_HEIGHT,
359
- spacing: [0, 0, 0, 0]
360
- },
361
- plotOptions: {
362
- pie: {
363
- animation: false,
364
- borderRadius: 0,
365
- // must be handled here instead of css because of path rendering
366
- dataLabels: {
367
- enabled: false
368
- },
369
- innerSize: "50%"
370
- }
371
- }
372
- });
373
-
374
- // src/hooks/useTimeSeriesChartOptions.ts
375
231
  import { merge } from "lodash";
376
232
  var useTimeSeriesChartOptions = ({
377
233
  xAnnotations,