@sproutsocial/seeds-react-data-viz 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/axis-DXzufRRj.d.mts +116 -0
- package/dist/axis-PJwu5Xmo.d.ts +116 -0
- package/dist/bar/index.d.mts +16 -156
- package/dist/bar/index.d.ts +16 -156
- package/dist/bar/index.js +97 -823
- package/dist/bar/index.js.map +1 -1
- package/dist/{chunk-VFBZ7FNK.js → chunk-EEVKTTT3.js} +13 -199
- package/dist/chunk-EEVKTTT3.js.map +1 -0
- package/dist/chunk-XVV7PYQE.js +796 -0
- package/dist/chunk-XVV7PYQE.js.map +1 -0
- package/dist/esm/bar/index.js +99 -825
- package/dist/esm/bar/index.js.map +1 -1
- package/dist/esm/{chunk-CDBW4SOR.js → chunk-LC3HGWDD.js} +2 -188
- package/dist/esm/chunk-LC3HGWDD.js.map +1 -0
- package/dist/esm/chunk-ZXXFRUVF.js +796 -0
- package/dist/esm/chunk-ZXXFRUVF.js.map +1 -0
- package/dist/esm/index.js +179 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/line-area/index.js +151 -0
- package/dist/esm/line-area/index.js.map +1 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +272 -106
- package/dist/index.js.map +1 -1
- package/dist/line-area/index.d.mts +83 -0
- package/dist/line-area/index.d.ts +83 -0
- package/dist/line-area/index.js +151 -0
- package/dist/line-area/index.js.map +1 -0
- package/package.json +6 -1
- package/dist/chunk-VFBZ7FNK.js.map +0 -1
- package/dist/esm/chunk-CDBW4SOR.js.map +0 -1
package/dist/bar/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -7,838 +7,93 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
var _chunkXVV7PYQEjs = require('../chunk-XVV7PYQE.js');
|
|
10
11
|
|
|
11
12
|
|
|
13
|
+
var _chunkEEVKTTT3js = require('../chunk-EEVKTTT3.js');
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkVFBZ7FNKjs = require('../chunk-VFBZ7FNK.js');
|
|
16
|
-
|
|
17
|
-
// src/charts/bar/VerticalBarChart.tsx
|
|
15
|
+
// src/charts/bar/BarChart.tsx
|
|
18
16
|
var _react = require('react');
|
|
19
17
|
|
|
20
|
-
// src/charts/shared/chartBase.tsx
|
|
21
|
-
var _highcharts = require('highcharts'); var _highcharts2 = _interopRequireDefault(_highcharts);
|
|
22
|
-
var _highchartsreactofficial = require('highcharts-react-official');
|
|
23
|
-
var _accessibility = require('highcharts/modules/accessibility'); var _accessibility2 = _interopRequireDefault(_accessibility);
|
|
24
|
-
var _annotations = require('highcharts/modules/annotations'); var _annotations2 = _interopRequireDefault(_annotations);
|
|
25
|
-
var _exporting = require('highcharts/modules/exporting'); var _exporting2 = _interopRequireDefault(_exporting);
|
|
26
|
-
var _offlineexporting = require('highcharts/modules/offline-exporting'); var _offlineexporting2 = _interopRequireDefault(_offlineexporting);
|
|
27
|
-
var _exportdata = require('highcharts/modules/export-data'); var _exportdata2 = _interopRequireDefault(_exportdata);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var _styledcomponents = require('styled-components'); var _styledcomponents2 = _interopRequireDefault(_styledcomponents);
|
|
36
|
-
var _seedsreactbox = require('@sproutsocial/seeds-react-box');
|
|
37
|
-
|
|
38
|
-
// src/charts/shared/ChartAnnotationMarkerPortal.tsx
|
|
39
|
-
|
|
40
|
-
var _reactdom = require('react-dom');
|
|
41
|
-
|
|
42
|
-
var _seedsreacticon = require('@sproutsocial/seeds-react-icon');
|
|
43
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
44
|
-
function ChartAnnotationMarker({
|
|
45
|
-
annotation,
|
|
46
|
-
lineHeight
|
|
47
|
-
}) {
|
|
48
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _seedsreactbox.Box, { display: "flex", flexDirection: "column", alignItems: "center", gap: 200, children: [
|
|
49
|
-
annotation.icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
50
|
-
_seedsreactbox.Box,
|
|
51
|
-
{
|
|
52
|
-
display: "flex",
|
|
53
|
-
alignItems: "center",
|
|
54
|
-
justifyContent: "center",
|
|
55
|
-
width: "20px",
|
|
56
|
-
height: "20px",
|
|
57
|
-
bg: "icon.base",
|
|
58
|
-
borderRadius: "50%",
|
|
59
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacticon.Icon, { name: annotation.icon, size: "mini", color: "icon.inverse" })
|
|
60
|
-
}
|
|
61
|
-
) : null,
|
|
62
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
63
|
-
_seedsreactbox.Box,
|
|
64
|
-
{
|
|
65
|
-
height: `${lineHeight}px`,
|
|
66
|
-
width: "0.5px",
|
|
67
|
-
bg: _nullishCoalesce(annotation.color, () => ( "neutral.200"))
|
|
68
|
-
}
|
|
69
|
-
)
|
|
70
|
-
] });
|
|
71
|
-
}
|
|
72
|
-
var MARKER_ATTR = "data-v2-chart-annotation-marker";
|
|
73
|
-
var ChartAnnotationMarkerPortal = _react.memo.call(void 0,
|
|
74
|
-
function ChartAnnotationMarkerPortal2({
|
|
75
|
-
annotationLookup,
|
|
76
|
-
annotationContext,
|
|
77
|
-
chartContainer,
|
|
78
|
-
plotHeight
|
|
79
|
-
}) {
|
|
80
|
-
const annotationContainers = _react.useRef.call(void 0, {});
|
|
81
|
-
const [, setRenderCount] = _react.useState.call(void 0, 0);
|
|
82
|
-
const forceRender = () => setRenderCount((prev) => prev + 1);
|
|
83
|
-
_react.useEffect.call(void 0, () => {
|
|
84
|
-
if (!annotationContext.labels) return;
|
|
85
|
-
const newContainers = {};
|
|
86
|
-
const existingAnnotationContainers = chartContainer.querySelectorAll(
|
|
87
|
-
`div[${MARKER_ATTR}='true']`
|
|
88
|
-
);
|
|
89
|
-
existingAnnotationContainers.forEach(
|
|
90
|
-
(annotation) => annotation.setAttribute(MARKER_ATTR, "false")
|
|
91
|
-
);
|
|
92
|
-
annotationContext.labels.forEach((label) => {
|
|
93
|
-
const labelElement = _optionalChain([label, 'access', _ => _.graphic, 'optionalAccess', _2 => _2.div]);
|
|
94
|
-
if (!labelElement) return;
|
|
95
|
-
labelElement.querySelectorAll(`div[${MARKER_ATTR}]`).forEach((component) => component.remove());
|
|
96
|
-
const annotationDiv = document.createElement("div");
|
|
97
|
-
annotationDiv.setAttribute(MARKER_ATTR, "true");
|
|
98
|
-
labelElement.appendChild(annotationDiv);
|
|
99
|
-
const xValue = _optionalChain([label, 'access', _3 => _3.options, 'optionalAccess', _4 => _4.point, 'optionalAccess', _5 => _5.x]);
|
|
100
|
-
newContainers[xValue] = annotationDiv;
|
|
101
|
-
});
|
|
102
|
-
annotationContainers.current = newContainers;
|
|
103
|
-
forceRender();
|
|
104
|
-
requestAnimationFrame(() => {
|
|
105
|
-
chartContainer.querySelectorAll("div.highcharts-annotation").forEach((annotationDiv) => {
|
|
106
|
-
const reactAnnotations = annotationDiv.querySelectorAll(
|
|
107
|
-
`div[${MARKER_ATTR}]`
|
|
108
|
-
);
|
|
109
|
-
const hasActiveAnnotations = Array.from(reactAnnotations).some(
|
|
110
|
-
(div) => div.getAttribute(MARKER_ATTR) === "true"
|
|
111
|
-
);
|
|
112
|
-
if (!hasActiveAnnotations) annotationDiv.remove();
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}, [annotationContext.labels, annotationLookup, chartContainer]);
|
|
116
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: Object.entries(annotationContainers.current).map(
|
|
117
|
-
([xValue, container]) => {
|
|
118
|
-
const annotation = annotationLookup.get(Number(xValue));
|
|
119
|
-
return annotation ? _reactdom.createPortal.call(void 0,
|
|
120
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
121
|
-
ChartAnnotationMarker,
|
|
122
|
-
{
|
|
123
|
-
annotation,
|
|
124
|
-
lineHeight: plotHeight
|
|
125
|
-
}
|
|
126
|
-
),
|
|
127
|
-
container
|
|
128
|
-
) : null;
|
|
129
|
-
}
|
|
130
|
-
) });
|
|
131
|
-
}
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
// src/charts/shared/DefaultChartTooltip.tsx
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
var _seedsreacttext = require('@sproutsocial/seeds-react-text');
|
|
138
|
-
|
|
139
|
-
// src/charts/shared/formatters/valueFormatter.ts
|
|
140
|
-
var _seedsreactduration = require('@sproutsocial/seeds-react-duration');
|
|
141
|
-
var _seedsreactnumeral = require('@sproutsocial/seeds-react-numeral');
|
|
142
|
-
function valueFormatter({
|
|
143
|
-
value,
|
|
144
|
-
numberFormat = "decimal",
|
|
145
|
-
currency = "USD",
|
|
146
|
-
abbreviate = true,
|
|
147
|
-
percentInput = "decimal",
|
|
148
|
-
numberLocale,
|
|
149
|
-
textLocale
|
|
150
|
-
}) {
|
|
151
|
-
const numberValue = Number(value);
|
|
152
|
-
if (numberValue === 0) {
|
|
153
|
-
return _seedsreactnumeral.formatNumeral.call(void 0, { locale: numberLocale, number: 0 });
|
|
154
|
-
}
|
|
155
|
-
if (numberFormat === "duration") {
|
|
156
|
-
return _seedsreactduration.formatDuration.call(void 0, {
|
|
157
|
-
display: "narrow",
|
|
158
|
-
locale: textLocale,
|
|
159
|
-
milliseconds: numberValue
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (numberFormat === "percent") {
|
|
163
|
-
const whole = percentInput === "decimal" ? numberValue * 100 : numberValue;
|
|
164
|
-
return _seedsreactnumeral.formatNumeral.call(void 0, {
|
|
165
|
-
format: "percent",
|
|
166
|
-
locale: numberLocale,
|
|
167
|
-
number: whole
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
return _seedsreactnumeral.formatNumeral.call(void 0, {
|
|
171
|
-
abbreviate,
|
|
172
|
-
currency,
|
|
173
|
-
format: numberFormat,
|
|
174
|
-
locale: numberLocale,
|
|
175
|
-
number: numberValue
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// src/charts/shared/DefaultChartTooltip.tsx
|
|
180
|
-
|
|
181
|
-
function formatTitle(position, timezone) {
|
|
182
|
-
if (typeof position === "string") return position;
|
|
183
|
-
return new Date(position).toLocaleDateString(void 0, {
|
|
184
|
-
year: "numeric",
|
|
185
|
-
month: "long",
|
|
186
|
-
day: "numeric",
|
|
187
|
-
weekday: "long",
|
|
188
|
-
timeZone: timezone
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
function AnnotationHeader({
|
|
192
|
-
icon,
|
|
193
|
-
title,
|
|
194
|
-
description
|
|
195
|
-
}) {
|
|
196
|
-
const hasIconOrTitle = Boolean(icon || title);
|
|
197
|
-
if (!hasIconOrTitle && !description) return null;
|
|
198
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
199
|
-
hasIconOrTitle ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVFBZ7FNKjs.ChartTooltipHeader, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _seedsreactbox.Box, { display: "flex", alignItems: "center", gap: 300, children: [
|
|
200
|
-
icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacticon.Icon, { name: icon, size: "mini", color: "icon.base" }) : null,
|
|
201
|
-
title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttext.Text, { color: "text.body", fontSize: 200, children: title }) : null
|
|
202
|
-
] }) }) : null,
|
|
203
|
-
description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVFBZ7FNKjs.ChartTooltipHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttext.Text, { fontSize: 200, color: "text.subtext", children: description }) }) : null
|
|
204
|
-
] });
|
|
205
|
-
}
|
|
206
|
-
function DefaultChartTooltip({
|
|
207
|
-
data,
|
|
208
|
-
position,
|
|
209
|
-
annotation,
|
|
210
|
-
hasOnClick,
|
|
211
|
-
tooltipClickLabel,
|
|
212
|
-
timezone,
|
|
213
|
-
invalidNumberLabel,
|
|
214
|
-
valueFormat
|
|
215
|
-
}) {
|
|
216
|
-
const rows = data.map((d) => ({
|
|
217
|
-
cells: [
|
|
218
|
-
{
|
|
219
|
-
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVFBZ7FNKjs.ChartLegendLabel, { color: d.color, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttext.Text, { "aria-label": `${d.name}: `, children: d.name }) })
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
// Format non-null values through the shared formatter when a
|
|
223
|
-
// `valueFormat` is supplied. Tooltip values are always full precision
|
|
224
|
-
// (`abbreviate: false`) — the axis tick scan never applies here (v1
|
|
225
|
-
// parity: `VerticalBarChartTooltip` passed `abbreviate={false}`).
|
|
226
|
-
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttext.Text, { children: d.value == null ? _nullishCoalesce(invalidNumberLabel, () => ( "\u2014")) : valueFormat ? valueFormatter({
|
|
227
|
-
...valueFormat,
|
|
228
|
-
value: d.value,
|
|
229
|
-
abbreviate: false
|
|
230
|
-
}) : d.value }),
|
|
231
|
-
align: "right"
|
|
232
|
-
}
|
|
233
|
-
]
|
|
234
|
-
}));
|
|
235
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVFBZ7FNKjs.ChartTooltip, { children: [
|
|
236
|
-
annotation ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
237
|
-
AnnotationHeader,
|
|
238
|
-
{
|
|
239
|
-
icon: annotation.icon,
|
|
240
|
-
title: annotation.title,
|
|
241
|
-
description: annotation.description
|
|
242
|
-
}
|
|
243
|
-
) : null,
|
|
244
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVFBZ7FNKjs.ChartTooltipTitle, { children: formatTitle(position, timezone) }),
|
|
245
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVFBZ7FNKjs.ChartTooltipTable, { rows }),
|
|
246
|
-
hasOnClick && tooltipClickLabel ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVFBZ7FNKjs.ChartTooltipFooter, { children: typeof tooltipClickLabel === "string" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _seedsreactbox.Box, { display: "flex", alignItems: "center", gap: 300, children: [
|
|
247
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacticon.Icon, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
|
|
248
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttext.Text, { color: "text.subtext", fontSize: 200, children: tooltipClickLabel })
|
|
249
|
-
] }) : tooltipClickLabel }) : null
|
|
250
|
-
] });
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// src/charts/shared/SeriesLegend.tsx
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
var SeriesLegend = _react.memo.call(void 0, function SeriesLegend2({
|
|
258
|
-
items
|
|
259
|
-
}) {
|
|
260
|
-
const labels = items.map((item) => ({
|
|
261
|
-
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
262
|
-
_chunkVFBZ7FNKjs.ChartLegendLabelContentWithIcon,
|
|
263
|
-
{
|
|
264
|
-
icon: item.icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacticon.Icon, { name: item.icon, fixedWidth: true, "aria-hidden": true }) : void 0,
|
|
265
|
-
children: item.name
|
|
266
|
-
}
|
|
267
|
-
),
|
|
268
|
-
color: item.color
|
|
269
|
-
}));
|
|
270
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVFBZ7FNKjs.ChartLegend, { legendLabels: labels });
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// src/charts/shared/chartExport.ts
|
|
274
|
-
function defaultFilename(type, now) {
|
|
275
|
-
const iso = now.toISOString();
|
|
276
|
-
const stamp = `${iso.slice(0, 10)}-${iso.slice(11, 19).replace(/:/g, "-")}`;
|
|
277
|
-
return slugify(type ? `chart-${type}-${stamp}` : `chart-${stamp}`);
|
|
278
|
-
}
|
|
279
|
-
function slugify(value) {
|
|
280
|
-
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// src/charts/shared/chartBase.tsx
|
|
284
|
-
|
|
285
|
-
_accessibility2.default.call(void 0, _highcharts2.default);
|
|
286
|
-
_annotations2.default.call(void 0, _highcharts2.default);
|
|
287
|
-
_exporting2.default.call(void 0, _highcharts2.default);
|
|
288
|
-
_offlineexporting2.default.call(void 0, _highcharts2.default);
|
|
289
|
-
_exportdata2.default.call(void 0, _highcharts2.default);
|
|
290
|
-
function useSeedsChartSetup({
|
|
291
|
-
series,
|
|
292
|
-
includePatterns = false,
|
|
293
|
-
seriesLimit,
|
|
294
|
-
isSeriesLimitOverridden = false,
|
|
295
|
-
hideSeriesLimitWarning = false,
|
|
296
|
-
componentName
|
|
297
|
-
}) {
|
|
298
|
-
const theme = _styledcomponents.useTheme.call(void 0, );
|
|
299
|
-
const palette = theme.colors.DATAVIZ_COLORS_LIST;
|
|
300
|
-
const cappedSeries = _react.useMemo.call(void 0,
|
|
301
|
-
() => seriesLimit !== void 0 && seriesLimit >= 1 && series.length > seriesLimit ? series.slice(0, seriesLimit) : series,
|
|
302
|
-
[series, seriesLimit]
|
|
303
|
-
);
|
|
304
|
-
_react.useEffect.call(void 0, () => {
|
|
305
|
-
if (seriesLimit !== void 0 && seriesLimit >= 1 && series.length > seriesLimit && !isSeriesLimitOverridden && !hideSeriesLimitWarning && componentName != null) {
|
|
306
|
-
console.warn(
|
|
307
|
-
`${componentName}: Maximum number of series (${seriesLimit}) exceeded. Only the first ${seriesLimit} series will be displayed.`
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
}, [
|
|
311
|
-
series.length,
|
|
312
|
-
seriesLimit,
|
|
313
|
-
isSeriesLimitOverridden,
|
|
314
|
-
hideSeriesLimitWarning,
|
|
315
|
-
componentName
|
|
316
|
-
]);
|
|
317
|
-
const colors = _react.useMemo.call(void 0, () => {
|
|
318
|
-
const out = [];
|
|
319
|
-
const paletteLen = palette.length;
|
|
320
|
-
for (let i = 0; i < cappedSeries.length; i++) {
|
|
321
|
-
const s = cappedSeries[i];
|
|
322
|
-
out.push(_nullishCoalesce(_nullishCoalesce(s.color, () => ( palette[i % paletteLen])), () => ( "")));
|
|
323
|
-
}
|
|
324
|
-
return out;
|
|
325
|
-
}, [cappedSeries, palette]);
|
|
326
|
-
const patterns = _react.useMemo.call(void 0, () => {
|
|
327
|
-
if (!includePatterns) return [];
|
|
328
|
-
const out = [];
|
|
329
|
-
for (let i = 0; i < cappedSeries.length; i++) {
|
|
330
|
-
const s = cappedSeries[i];
|
|
331
|
-
out.push(_nullishCoalesce(s.pattern, () => ( "solid")));
|
|
332
|
-
}
|
|
333
|
-
return out;
|
|
334
|
-
}, [cappedSeries, includePatterns]);
|
|
335
|
-
return { theme, colors, patterns, series: cappedSeries };
|
|
336
|
-
}
|
|
337
|
-
function buildExportChartOptions(theme, colors) {
|
|
338
|
-
const axisOptions = {
|
|
339
|
-
lineColor: theme.colors.container.border.base,
|
|
340
|
-
gridLineColor: theme.colors.container.border.base,
|
|
341
|
-
labels: {
|
|
342
|
-
style: {
|
|
343
|
-
color: theme.colors.text.subtext,
|
|
344
|
-
fontFamily: theme.fontFamily,
|
|
345
|
-
fontSize: theme.typography[100].fontSize,
|
|
346
|
-
fontWeight: String(theme.fontWeights.normal)
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
return {
|
|
351
|
-
chart: {
|
|
352
|
-
styledMode: false,
|
|
353
|
-
backgroundColor: theme.colors.container.background.base
|
|
354
|
-
},
|
|
355
|
-
// Series without an explicit `color` fall through to this palette by index.
|
|
356
|
-
colors: [...colors],
|
|
357
|
-
// The on-screen legend is a React sibling (`SeriesLegend`) outside the chart
|
|
358
|
-
// SVG, so the export can't capture it. Turn on Highcharts' native legend for
|
|
359
|
-
// the clone instead, themed to approximate the Seeds `ChartLegend` (centered
|
|
360
|
-
// row of swatch + `text.subtext` label). It can't reproduce per-series Seeds
|
|
361
|
-
// icons — those series show colour + name only.
|
|
362
|
-
legend: {
|
|
363
|
-
enabled: true,
|
|
364
|
-
symbolRadius: 4,
|
|
365
|
-
symbolHeight: 12,
|
|
366
|
-
symbolWidth: 12,
|
|
367
|
-
itemStyle: {
|
|
368
|
-
color: theme.colors.text.subtext,
|
|
369
|
-
fontFamily: theme.fontFamily,
|
|
370
|
-
fontSize: theme.typography[200].fontSize,
|
|
371
|
-
fontWeight: String(theme.fontWeights.normal)
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
xAxis: {
|
|
375
|
-
...axisOptions,
|
|
376
|
-
crosshair: {
|
|
377
|
-
color: theme.colors.container.border.decorative.neutral,
|
|
378
|
-
width: 1
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
|
-
// No zero-line: the `y-axis-zero-line` rule in chartStyles is a v1 leftover;
|
|
382
|
-
// the v2 bar adapter never creates that plotLine.
|
|
383
|
-
yAxis: axisOptions
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
function createChartExportHandle(chart, getExportChartOptions) {
|
|
387
|
-
const resolveName = (filename) => _nullishCoalesce(filename, () => ( defaultFilename(_optionalChain([chart, 'access', _6 => _6.options, 'access', _7 => _7.chart, 'optionalAccess', _8 => _8.type]), /* @__PURE__ */ new Date())));
|
|
388
|
-
const exportImage = async (type, filename) => {
|
|
389
|
-
chart.exportChartLocal(
|
|
390
|
-
{ type, filename: resolveName(filename) },
|
|
391
|
-
getExportChartOptions()
|
|
392
|
-
);
|
|
393
|
-
};
|
|
394
|
-
return {
|
|
395
|
-
exportPNG: ({ filename } = {}) => exportImage("image/png", filename),
|
|
396
|
-
exportSVG: ({ filename } = {}) => exportImage("image/svg+xml", filename),
|
|
397
|
-
exportPDF: async ({ filename } = {}) => {
|
|
398
|
-
const { loadPdfExportLibs } = await Promise.resolve().then(() => _interopRequireWildcard(require("../pdfExportLibs-BZR2D3RA.js")));
|
|
399
|
-
loadPdfExportLibs();
|
|
400
|
-
await exportImage("application/pdf", filename);
|
|
401
|
-
},
|
|
402
|
-
exportCSV: async ({ filename } = {}) => {
|
|
403
|
-
const exporting = chart.options.exporting ??= {};
|
|
404
|
-
const previous = exporting.filename;
|
|
405
|
-
exporting.filename = resolveName(filename);
|
|
406
|
-
try {
|
|
407
|
-
chart.downloadCSV();
|
|
408
|
-
} finally {
|
|
409
|
-
exporting.filename = previous;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
function ChartRenderer({
|
|
415
|
-
options,
|
|
416
|
-
series,
|
|
417
|
-
colors,
|
|
418
|
-
tooltip,
|
|
419
|
-
annotationLookup,
|
|
420
|
-
hasOnClick,
|
|
421
|
-
tooltipClickLabel,
|
|
422
|
-
timezone,
|
|
423
|
-
invalidNumberLabel,
|
|
424
|
-
valueFormat,
|
|
425
|
-
onReady
|
|
426
|
-
}) {
|
|
427
|
-
const [chart, setChart] = _react.useState.call(void 0, null);
|
|
428
|
-
const [plotHeight, setPlotHeight] = _react.useState.call(void 0, 0);
|
|
429
|
-
const renderTooltip = _nullishCoalesce(tooltip, () => ( DefaultChartTooltip));
|
|
430
|
-
const theme = _styledcomponents.useTheme.call(void 0, );
|
|
431
|
-
const exportThemeRef = _react.useRef.call(void 0, { theme, colors });
|
|
432
|
-
exportThemeRef.current = { theme, colors };
|
|
433
|
-
const captureChart = _react.useCallback.call(void 0, (chartInstance) => {
|
|
434
|
-
const forExport = _optionalChain([chartInstance, 'access', _9 => _9.options, 'access', _10 => _10.chart, 'optionalAccess', _11 => _11.forExport]);
|
|
435
|
-
if (!forExport) {
|
|
436
|
-
setChart(chartInstance);
|
|
437
|
-
}
|
|
438
|
-
}, []);
|
|
439
|
-
const onReadyRef = _react.useRef.call(void 0, onReady);
|
|
440
|
-
onReadyRef.current = onReady;
|
|
441
|
-
_react.useEffect.call(void 0, () => {
|
|
442
|
-
if (!chart) return;
|
|
443
|
-
_optionalChain([onReadyRef, 'access', _12 => _12.current, 'optionalCall', _13 => _13(
|
|
444
|
-
createChartExportHandle(
|
|
445
|
-
chart,
|
|
446
|
-
() => buildExportChartOptions(
|
|
447
|
-
exportThemeRef.current.theme,
|
|
448
|
-
exportThemeRef.current.colors
|
|
449
|
-
)
|
|
450
|
-
)
|
|
451
|
-
)]);
|
|
452
|
-
}, [chart]);
|
|
453
|
-
_react.useEffect.call(void 0, () => {
|
|
454
|
-
if (!chart) return;
|
|
455
|
-
setPlotHeight(chart.plotHeight);
|
|
456
|
-
const unbind = _highcharts2.default.addEvent(chart, "redraw", () => {
|
|
457
|
-
setPlotHeight(chart.plotHeight);
|
|
458
|
-
});
|
|
459
|
-
return () => unbind();
|
|
460
|
-
}, [chart]);
|
|
461
|
-
if (series.length === 0) return null;
|
|
462
|
-
const chartWithAnnotations = chart;
|
|
463
|
-
const hasRenderedAnnotations = !!_optionalChain([chartWithAnnotations, 'optionalAccess', _14 => _14.annotations, 'optionalAccess', _15 => _15.length]) && !!_optionalChain([annotationLookup, 'optionalAccess', _16 => _16.size]) && plotHeight > 0;
|
|
464
|
-
const highchartsOptions = {
|
|
465
|
-
...options,
|
|
466
|
-
tooltip: { ...options.tooltip, useHTML: true },
|
|
467
|
-
// Export stays client-side/offline only. `fallbackToExportServer: false`
|
|
468
|
-
// stops Highcharts from POSTing chart SVG/data to its public export server
|
|
469
|
-
// (https://export.highcharts.com/) when a local export fails — our
|
|
470
|
-
// `useHTML: true` tooltips are a known trigger for offline-rasterization
|
|
471
|
-
// failure, so this guard is load-bearing, not theoretical. `contextButton`
|
|
472
|
-
// is disabled because v2 charts expose export only through the `onReady`
|
|
473
|
-
// handle; programmatic `exportChartLocal` / `downloadCSV` are unaffected.
|
|
474
|
-
exporting: {
|
|
475
|
-
fallbackToExportServer: false,
|
|
476
|
-
buttons: { contextButton: { enabled: false } }
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
480
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVFBZ7FNKjs.GlobalChartStyleOverrides, {}),
|
|
481
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
482
|
-
_highchartsreactofficial.HighchartsReact,
|
|
483
|
-
{
|
|
484
|
-
highcharts: _highcharts2.default,
|
|
485
|
-
options: highchartsOptions,
|
|
486
|
-
callback: captureChart
|
|
487
|
-
}
|
|
488
|
-
),
|
|
489
|
-
hasRenderedAnnotations ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
490
|
-
ChartAnnotationMarkerPortal,
|
|
491
|
-
{
|
|
492
|
-
annotationLookup,
|
|
493
|
-
annotationContext: chartWithAnnotations.annotations[0],
|
|
494
|
-
chartContainer: chartWithAnnotations.container,
|
|
495
|
-
plotHeight
|
|
496
|
-
}
|
|
497
|
-
) : null,
|
|
498
|
-
chart ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
499
|
-
_chunkVFBZ7FNKjs.ChartTooltipPortal,
|
|
500
|
-
{
|
|
501
|
-
chart,
|
|
502
|
-
renderContent: (context) => {
|
|
503
|
-
const data = _chunkVFBZ7FNKjs.transformTimeSeriesTooltipData.call(void 0, {
|
|
504
|
-
context,
|
|
505
|
-
data: series.map((s, i) => ({
|
|
506
|
-
name: s.name,
|
|
507
|
-
points: [],
|
|
508
|
-
styles: { color: _nullishCoalesce(_nullishCoalesce(s.color, () => ( colors[i])), () => ( "")) }
|
|
509
|
-
}))
|
|
510
|
-
}).map((row) => ({
|
|
511
|
-
color: row.color,
|
|
512
|
-
name: row.name,
|
|
513
|
-
value: row.value
|
|
514
|
-
}));
|
|
515
|
-
const position = context.x;
|
|
516
|
-
const resolved = _optionalChain([annotationLookup, 'optionalAccess', _17 => _17.get, 'call', _18 => _18(context.point.x)]);
|
|
517
|
-
const annotation = resolved ? {
|
|
518
|
-
icon: resolved.icon,
|
|
519
|
-
color: resolved.color,
|
|
520
|
-
title: resolved.title,
|
|
521
|
-
description: resolved.description
|
|
522
|
-
} : void 0;
|
|
523
|
-
return renderTooltip({
|
|
524
|
-
data,
|
|
525
|
-
position,
|
|
526
|
-
annotation,
|
|
527
|
-
hasOnClick,
|
|
528
|
-
tooltipClickLabel,
|
|
529
|
-
timezone,
|
|
530
|
-
invalidNumberLabel,
|
|
531
|
-
valueFormat
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
) : null,
|
|
536
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreactbox.Box, { mt: 350, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
537
|
-
SeriesLegend,
|
|
538
|
-
{
|
|
539
|
-
items: series.map((s, i) => ({
|
|
540
|
-
name: s.name,
|
|
541
|
-
icon: s.icon,
|
|
542
|
-
color: _nullishCoalesce(_nullishCoalesce(s.color, () => ( colors[i])), () => ( ""))
|
|
543
|
-
}))
|
|
544
|
-
}
|
|
545
|
-
) })
|
|
546
|
-
] });
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// src/charts/shared/annotations.ts
|
|
550
|
-
function buildAnnotationConfig(annotations) {
|
|
551
|
-
if (!_optionalChain([annotations, 'optionalAccess', _19 => _19.length])) {
|
|
552
|
-
return { annotations: void 0, lookup: void 0 };
|
|
553
|
-
}
|
|
554
|
-
const labels = [];
|
|
555
|
-
const lookup = /* @__PURE__ */ new Map();
|
|
556
|
-
for (const annotation of annotations) {
|
|
557
|
-
const { position } = annotation;
|
|
558
|
-
labels.push({
|
|
559
|
-
// Highcharts anchor — always uses `x` regardless of chart orientation.
|
|
560
|
-
point: { x: position, y: 0, xAxis: 0, yAxis: 0 },
|
|
561
|
-
// Space (not empty) — Highcharts reverts to its built-in label text on empty string.
|
|
562
|
-
text: " "
|
|
563
|
-
});
|
|
564
|
-
lookup.set(position, annotation);
|
|
565
|
-
}
|
|
566
|
-
if (labels.length === 0) {
|
|
567
|
-
return { annotations: void 0, lookup: void 0 };
|
|
568
|
-
}
|
|
569
|
-
return {
|
|
570
|
-
// `useHTML: true` makes Highcharts attach an HTML `graphic.div` to each
|
|
571
|
-
// label, which the marker portal needs as its render target. `padding: 0`
|
|
572
|
-
// removes Highcharts' default left padding so markers stay centered.
|
|
573
|
-
annotations: [{ labels, labelOptions: { useHTML: true, padding: 0 } }],
|
|
574
|
-
lookup
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// src/charts/shared/formatters/datetimeFormatter.ts
|
|
579
|
-
var DAY_MS = 864e5;
|
|
580
|
-
var WEEK_MS = 6048e5;
|
|
581
|
-
var MIN_MONTH_MS = 24192e5;
|
|
582
|
-
var MIN_YEAR_MS = 31536e6;
|
|
583
|
-
var getDatePartsInTimezone = (date, timezone) => {
|
|
584
|
-
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
585
|
-
year: "numeric",
|
|
586
|
-
month: "numeric",
|
|
587
|
-
day: "numeric",
|
|
588
|
-
timeZone: timezone
|
|
589
|
-
});
|
|
590
|
-
const parts = formatter.formatToParts(date);
|
|
591
|
-
return {
|
|
592
|
-
day: parseInt(_nullishCoalesce(_optionalChain([parts, 'access', _20 => _20.find, 'call', _21 => _21((p) => p.type === "day"), 'optionalAccess', _22 => _22.value]), () => ( "0")), 10),
|
|
593
|
-
month: parseInt(_nullishCoalesce(_optionalChain([parts, 'access', _23 => _23.find, 'call', _24 => _24((p) => p.type === "month"), 'optionalAccess', _25 => _25.value]), () => ( "0")), 10),
|
|
594
|
-
year: parseInt(_nullishCoalesce(_optionalChain([parts, 'access', _26 => _26.find, 'call', _27 => _27((p) => p.type === "year"), 'optionalAccess', _28 => _28.value]), () => ( "0")), 10)
|
|
595
|
-
};
|
|
596
|
-
};
|
|
597
|
-
var deriveGranularity = (tickPositions) => {
|
|
598
|
-
if (tickPositions.length < 2) {
|
|
599
|
-
return "day";
|
|
600
|
-
}
|
|
601
|
-
const deltas = [];
|
|
602
|
-
for (let i = 1; i < tickPositions.length; i++) {
|
|
603
|
-
const curr = tickPositions[i];
|
|
604
|
-
const prev = tickPositions[i - 1];
|
|
605
|
-
if (curr === void 0 || prev === void 0) {
|
|
606
|
-
continue;
|
|
607
|
-
}
|
|
608
|
-
deltas.push(Math.abs(curr - prev));
|
|
609
|
-
}
|
|
610
|
-
deltas.sort((a, b) => a - b);
|
|
611
|
-
const mid = Math.floor(deltas.length / 2);
|
|
612
|
-
const upper = deltas[mid];
|
|
613
|
-
const lower = deltas[mid - 1];
|
|
614
|
-
const median = deltas.length % 2 === 0 && lower !== void 0 ? (lower + upper) / 2 : upper;
|
|
615
|
-
if (median < DAY_MS) {
|
|
616
|
-
return "hour";
|
|
617
|
-
}
|
|
618
|
-
if (median < WEEK_MS) {
|
|
619
|
-
return "day";
|
|
620
|
-
}
|
|
621
|
-
if (median < MIN_MONTH_MS) {
|
|
622
|
-
return "week";
|
|
623
|
-
}
|
|
624
|
-
if (median < MIN_YEAR_MS) {
|
|
625
|
-
return "month";
|
|
626
|
-
}
|
|
627
|
-
return "year";
|
|
628
|
-
};
|
|
629
|
-
function datetimeFormatter({
|
|
630
|
-
value,
|
|
631
|
-
tickPositions = [],
|
|
632
|
-
// optional
|
|
633
|
-
timezone = "UTC",
|
|
634
|
-
timeFormat = "12",
|
|
635
|
-
textLocale = "en-US"
|
|
636
|
-
}) {
|
|
637
|
-
if (typeof value === "string" || !Number.isFinite(value)) {
|
|
638
|
-
return { primary: String(value) };
|
|
639
|
-
}
|
|
640
|
-
const granularity = deriveGranularity(tickPositions);
|
|
641
|
-
const tickIndex = tickPositions.indexOf(value);
|
|
642
|
-
const isFirst = tickIndex === 0;
|
|
643
|
-
const previousValue = tickPositions[tickIndex - 1];
|
|
644
|
-
const valueDate = new Date(value);
|
|
645
|
-
const valueParts = getDatePartsInTimezone(valueDate, timezone);
|
|
646
|
-
const previousValueDate = previousValue ? new Date(previousValue) : void 0;
|
|
647
|
-
const previousValueParts = previousValueDate ? getDatePartsInTimezone(previousValueDate, timezone) : void 0;
|
|
648
|
-
let firstPartOptions = {};
|
|
649
|
-
let secondPartOptions = {};
|
|
650
|
-
switch (granularity) {
|
|
651
|
-
case "hour":
|
|
652
|
-
firstPartOptions = timeFormat === "24" ? { hour: "numeric", minute: "numeric", hour12: false } : { hour: "numeric" };
|
|
653
|
-
if (isFirst || valueParts.day !== _optionalChain([previousValueParts, 'optionalAccess', _29 => _29.day])) {
|
|
654
|
-
secondPartOptions = { day: "numeric", month: "short" };
|
|
655
|
-
}
|
|
656
|
-
break;
|
|
657
|
-
case "day":
|
|
658
|
-
case "week":
|
|
659
|
-
firstPartOptions = { day: "numeric" };
|
|
660
|
-
if (isFirst || valueParts.month !== _optionalChain([previousValueParts, 'optionalAccess', _30 => _30.month])) {
|
|
661
|
-
secondPartOptions = { month: "short" };
|
|
662
|
-
}
|
|
663
|
-
break;
|
|
664
|
-
case "month":
|
|
665
|
-
firstPartOptions = { month: "short" };
|
|
666
|
-
if (isFirst || valueParts.year !== _optionalChain([previousValueParts, 'optionalAccess', _31 => _31.year])) {
|
|
667
|
-
secondPartOptions = { year: "numeric" };
|
|
668
|
-
}
|
|
669
|
-
break;
|
|
670
|
-
case "year":
|
|
671
|
-
firstPartOptions = { year: "numeric" };
|
|
672
|
-
break;
|
|
673
|
-
default:
|
|
674
|
-
firstPartOptions = {};
|
|
675
|
-
break;
|
|
676
|
-
}
|
|
677
|
-
const primary = new Intl.DateTimeFormat(textLocale, {
|
|
678
|
-
...firstPartOptions,
|
|
679
|
-
timeZone: timezone
|
|
680
|
-
}).format(valueDate);
|
|
681
|
-
if (Object.keys(secondPartOptions).length > 0) {
|
|
682
|
-
const secondary = new Intl.DateTimeFormat(textLocale, {
|
|
683
|
-
...secondPartOptions,
|
|
684
|
-
timeZone: timezone
|
|
685
|
-
}).format(valueDate);
|
|
686
|
-
return { primary, secondary };
|
|
687
|
-
}
|
|
688
|
-
return { primary };
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
// src/charts/shared/valueAxisLabelFormatter.ts
|
|
692
|
-
|
|
693
|
-
var FIXED_LOCALE = "en-US";
|
|
694
|
-
function deriveAbbreviateFromTicks(context) {
|
|
695
|
-
const tickPositions = context.axis.tickPositions;
|
|
696
|
-
const maxValue = tickPositions && tickPositions.length > 0 ? tickPositions[tickPositions.length - 1] : void 0;
|
|
697
|
-
return typeof maxValue === "number" && maxValue > 9999 ? 1e3 : true;
|
|
698
|
-
}
|
|
699
|
-
function defaultValueAxisLabelFormatter() {
|
|
700
|
-
const numberValue = Number(this.value);
|
|
701
|
-
if (numberValue === 0) {
|
|
702
|
-
return _seedsreactnumeral.formatNumeral.call(void 0, { locale: FIXED_LOCALE, number: 0 });
|
|
703
|
-
}
|
|
704
|
-
const abbreviate = deriveAbbreviateFromTicks(this);
|
|
705
|
-
return _seedsreactnumeral.formatNumeral.call(void 0, {
|
|
706
|
-
abbreviate,
|
|
707
|
-
format: "decimal",
|
|
708
|
-
locale: FIXED_LOCALE,
|
|
709
|
-
number: numberValue
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
function makeValueAxisLabelFormatter(format) {
|
|
713
|
-
return function() {
|
|
714
|
-
const numberValue = Number(this.value);
|
|
715
|
-
const abbreviate = format.abbreviate === false ? false : deriveAbbreviateFromTicks(this);
|
|
716
|
-
return valueFormatter({ ...format, value: numberValue, abbreviate });
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
|
|
720
18
|
// src/charts/bar/adapter.ts
|
|
721
19
|
function highchartsType(direction) {
|
|
722
|
-
|
|
723
|
-
case "vertical":
|
|
724
|
-
return "column";
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
function makeDatetimeAxisLabelFormatter(timezone, timeFormat) {
|
|
728
|
-
return function() {
|
|
729
|
-
const { primary, secondary } = datetimeFormatter({
|
|
730
|
-
value: this.value,
|
|
731
|
-
tickPositions: _nullishCoalesce(this.axis.tickPositions, () => ( [])),
|
|
732
|
-
timezone,
|
|
733
|
-
timeFormat
|
|
734
|
-
});
|
|
735
|
-
return secondary ? `${primary}<br/><span class="hc-axis-label-secondary">${secondary}</span>` : primary;
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
function buildXAxis(xAxis, timezone) {
|
|
739
|
-
if (xAxis.type === "datetime") {
|
|
740
|
-
return {
|
|
741
|
-
type: "datetime",
|
|
742
|
-
crosshair: xAxis.crosshair,
|
|
743
|
-
labels: {
|
|
744
|
-
formatter: makeDatetimeAxisLabelFormatter(timezone, xAxis.timeFormat)
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
}
|
|
748
|
-
return {
|
|
749
|
-
type: "category",
|
|
750
|
-
categories: [...xAxis.categories],
|
|
751
|
-
crosshair: xAxis.crosshair
|
|
752
|
-
};
|
|
20
|
+
return direction === "horizontal" ? "bar" : "column";
|
|
753
21
|
}
|
|
754
22
|
function buildBarChartOptions(props, direction, series = props.series) {
|
|
755
23
|
const chartType = highchartsType(direction);
|
|
756
24
|
const isDatetime = props.xAxis.type === "datetime";
|
|
757
|
-
const tooltipTimezone =
|
|
758
|
-
const { annotations, lookup: annotationLookup } = buildAnnotationConfig(
|
|
25
|
+
const tooltipTimezone = _chunkXVV7PYQEjs.resolveTooltipTimezone.call(void 0, props.xAxis, props.timezone);
|
|
26
|
+
const { annotations, lookup: annotationLookup } = _chunkXVV7PYQEjs.buildAnnotationConfig.call(void 0,
|
|
759
27
|
props.annotations
|
|
760
28
|
);
|
|
29
|
+
const barTypeConfig = {
|
|
30
|
+
// "grouped" maps to omitting `stacking` — Highcharts renders multi-series
|
|
31
|
+
// columns side-by-side when no stacking is set.
|
|
32
|
+
...props.stacking === "grouped" ? {} : { stacking: _nullishCoalesce(props.stacking, () => ( "normal")) },
|
|
33
|
+
// Horizontal bars are height-constrained (fixed chart height ÷ categories),
|
|
34
|
+
// so the same padding fractions that work for columns produce hairline bars.
|
|
35
|
+
pointPadding: direction === "horizontal" ? 0.05 : 0.25,
|
|
36
|
+
groupPadding: direction === "horizontal" ? 0.1 : 0.25,
|
|
37
|
+
// Fixed bar width on datetime axes. Sparse time-series otherwise size
|
|
38
|
+
// columns from the (large) gap between points and balloon; this mirrors
|
|
39
|
+
// v1's `pointWidth: 20` time-series treatment. Dense datetime data may
|
|
40
|
+
// instead want a `maxPointWidth` cap — revisit when Line/Area land.
|
|
41
|
+
...isDatetime ? { pointWidth: 20 } : {},
|
|
42
|
+
borderRadius: 4,
|
|
43
|
+
borderWidth: 0,
|
|
44
|
+
// Pairs with the `:hover` dimming rule in `styles.ts`: while the cursor
|
|
45
|
+
// is over the chart, all bars dim; these handlers restore opacity for
|
|
46
|
+
// every bar at the hovered x (so stacked/grouped bars highlight together
|
|
47
|
+
// rather than just the single hovered bar).
|
|
48
|
+
point: {
|
|
49
|
+
events: {
|
|
50
|
+
click: props.onClick ? (event) => props.onClick({ position: event.point.x }) : void 0,
|
|
51
|
+
mouseOver: function() {
|
|
52
|
+
const x = this.x;
|
|
53
|
+
this.series.chart.series.forEach((s) => {
|
|
54
|
+
if (s.type !== chartType) return;
|
|
55
|
+
s.data.forEach((point) => {
|
|
56
|
+
if (point.x !== x) return;
|
|
57
|
+
_optionalChain([point, 'access', _ => _.graphic, 'optionalAccess', _2 => _2.element, 'optionalAccess', _3 => _3.classList, 'access', _4 => _4.add, 'call', _5 => _5("bar-point-hover")]);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
mouseOut: function() {
|
|
62
|
+
this.series.chart.series.forEach((s) => {
|
|
63
|
+
if (s.type !== chartType) return;
|
|
64
|
+
s.data.forEach((point) => {
|
|
65
|
+
_optionalChain([point, 'access', _6 => _6.graphic, 'optionalAccess', _7 => _7.element, 'optionalAccess', _8 => _8.classList, 'access', _9 => _9.remove, 'call', _10 => _10("bar-point-hover")]);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
761
72
|
const options = {
|
|
762
|
-
|
|
73
|
+
..._chunkXVV7PYQEjs.buildBaseChartOptions.call(void 0, {
|
|
763
74
|
type: chartType,
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
},
|
|
769
|
-
|
|
770
|
-
title: { text: "" },
|
|
771
|
-
credits: { enabled: false },
|
|
772
|
-
legend: { enabled: false },
|
|
773
|
-
tooltip: {
|
|
774
|
-
enabled: true,
|
|
775
|
-
outside: true,
|
|
776
|
-
padding: 0,
|
|
777
|
-
shape: "rect",
|
|
778
|
-
shared: true,
|
|
779
|
-
hideDelay: 0,
|
|
780
|
-
valueSuffix: props.valueSuffix
|
|
781
|
-
},
|
|
782
|
-
xAxis: buildXAxis(props.xAxis, _nullishCoalesce(tooltipTimezone, () => ( "UTC"))),
|
|
783
|
-
// `timezone` is chart-global in Highcharts (`time.timezone`) and only
|
|
784
|
-
// meaningful for a datetime axis, so it's omitted otherwise.
|
|
785
|
-
...tooltipTimezone ? { time: { timezone: tooltipTimezone } } : {},
|
|
75
|
+
description: props.description,
|
|
76
|
+
valueSuffix: props.valueSuffix,
|
|
77
|
+
reserveTopMargin: Boolean(annotations),
|
|
78
|
+
timezone: tooltipTimezone
|
|
79
|
+
}),
|
|
80
|
+
xAxis: _chunkXVV7PYQEjs.buildDimensionalAxis.call(void 0, props.xAxis, _nullishCoalesce(tooltipTimezone, () => ( "UTC"))),
|
|
786
81
|
yAxis: {
|
|
787
|
-
min: _optionalChain([props, 'access',
|
|
788
|
-
max: _optionalChain([props, 'access',
|
|
789
|
-
gridLineWidth: _optionalChain([props, 'access',
|
|
790
|
-
title: { text: _nullishCoalesce(_optionalChain([props, 'access',
|
|
82
|
+
min: _optionalChain([props, 'access', _11 => _11.yAxis, 'optionalAccess', _12 => _12.min]),
|
|
83
|
+
max: _optionalChain([props, 'access', _13 => _13.yAxis, 'optionalAccess', _14 => _14.max]),
|
|
84
|
+
gridLineWidth: _optionalChain([props, 'access', _15 => _15.yAxis, 'optionalAccess', _16 => _16.showGridLines]) === false ? 0 : 1,
|
|
85
|
+
title: { text: _nullishCoalesce(_optionalChain([props, 'access', _17 => _17.yAxis, 'optionalAccess', _18 => _18.title]), () => ( "")) },
|
|
791
86
|
labels: {
|
|
792
87
|
// `showLabels` toggles tick-label visibility; defaults to shown.
|
|
793
|
-
enabled: _optionalChain([props, 'access',
|
|
88
|
+
enabled: _optionalChain([props, 'access', _19 => _19.yAxis, 'optionalAccess', _20 => _20.showLabels]) !== false,
|
|
794
89
|
// A declarative `format` drives ticks through the shared valueFormatter;
|
|
795
90
|
// absent it, the zero-config decimal default (1.20K / 1.20M / 1.20B).
|
|
796
|
-
formatter: _optionalChain([props, 'access',
|
|
91
|
+
formatter: _optionalChain([props, 'access', _21 => _21.yAxis, 'optionalAccess', _22 => _22.format]) ? _chunkXVV7PYQEjs.makeValueAxisLabelFormatter.call(void 0, props.yAxis.format) : _chunkXVV7PYQEjs.defaultValueAxisLabelFormatter
|
|
797
92
|
}
|
|
798
93
|
},
|
|
799
94
|
plotOptions: {
|
|
800
95
|
series: { animation: false },
|
|
801
|
-
|
|
802
|
-
// "grouped" maps to omitting `stacking` — Highcharts renders multi-series
|
|
803
|
-
// columns side-by-side when no stacking is set.
|
|
804
|
-
...props.stacking === "grouped" ? {} : { stacking: _nullishCoalesce(props.stacking, () => ( "normal")) },
|
|
805
|
-
pointPadding: 0.25,
|
|
806
|
-
groupPadding: 0.25,
|
|
807
|
-
// Fixed bar width on datetime axes. Sparse time-series otherwise size
|
|
808
|
-
// columns from the (large) gap between points and balloon; this mirrors
|
|
809
|
-
// v1's `pointWidth: 20` time-series treatment. Dense datetime data may
|
|
810
|
-
// instead want a `maxPointWidth` cap — revisit when Line/Area land.
|
|
811
|
-
...isDatetime ? { pointWidth: 20 } : {},
|
|
812
|
-
borderRadius: 4,
|
|
813
|
-
borderWidth: 0,
|
|
814
|
-
// Pairs with the `:hover` dimming rule in `styles.ts`: while the cursor
|
|
815
|
-
// is over the chart, all bars dim; these handlers restore opacity for
|
|
816
|
-
// every bar at the hovered x (so stacked/grouped columns highlight
|
|
817
|
-
// together rather than just the single hovered bar).
|
|
818
|
-
point: {
|
|
819
|
-
events: {
|
|
820
|
-
click: props.onClick ? (event) => props.onClick({ position: event.point.x }) : void 0,
|
|
821
|
-
mouseOver: function() {
|
|
822
|
-
const x = this.x;
|
|
823
|
-
this.series.chart.series.forEach((s) => {
|
|
824
|
-
if (s.type !== "column") return;
|
|
825
|
-
s.data.forEach((point) => {
|
|
826
|
-
if (point.x !== x) return;
|
|
827
|
-
_optionalChain([point, 'access', _44 => _44.graphic, 'optionalAccess', _45 => _45.element, 'optionalAccess', _46 => _46.classList, 'access', _47 => _47.add, 'call', _48 => _48("column-hover")]);
|
|
828
|
-
});
|
|
829
|
-
});
|
|
830
|
-
},
|
|
831
|
-
mouseOut: function() {
|
|
832
|
-
this.series.chart.series.forEach((s) => {
|
|
833
|
-
if (s.type !== "column") return;
|
|
834
|
-
s.data.forEach((point) => {
|
|
835
|
-
_optionalChain([point, 'access', _49 => _49.graphic, 'optionalAccess', _50 => _50.element, 'optionalAccess', _51 => _51.classList, 'access', _52 => _52.remove, 'call', _53 => _53("column-hover")]);
|
|
836
|
-
});
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
96
|
+
[chartType]: barTypeConfig
|
|
842
97
|
},
|
|
843
98
|
series: series.map((s) => ({
|
|
844
99
|
type: chartType,
|
|
@@ -852,8 +107,8 @@ function buildBarChartOptions(props, direction, series = props.series) {
|
|
|
852
107
|
}
|
|
853
108
|
|
|
854
109
|
// src/charts/bar/styles.ts
|
|
855
|
-
|
|
856
|
-
|
|
110
|
+
var _styledcomponents = require('styled-components'); var _styledcomponents2 = _interopRequireDefault(_styledcomponents);
|
|
111
|
+
var _seedsreactbox = require('@sproutsocial/seeds-react-box');
|
|
857
112
|
|
|
858
113
|
// src/charts/shared/styles.ts
|
|
859
114
|
|
|
@@ -876,36 +131,55 @@ var axisLabelV2Styles = _styledcomponents.css`
|
|
|
876
131
|
`;
|
|
877
132
|
|
|
878
133
|
// src/charts/bar/styles.ts
|
|
879
|
-
var
|
|
880
|
-
${
|
|
134
|
+
var barFamilyStyles = _styledcomponents.css`
|
|
135
|
+
${_chunkEEVKTTT3js.timeSeriesChartStyles}
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
When the chart container is hovered, dim all bars. Then restore opacity for
|
|
139
|
+
the hovered bar(s) — flagged with the bar-point-hover class by the adapter —
|
|
140
|
+
so the non-hovered bars fade out.
|
|
141
|
+
*/
|
|
142
|
+
.highcharts-container:hover .highcharts-point {
|
|
143
|
+
fill-opacity: 0.3;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.highcharts-point.bar-point-hover {
|
|
147
|
+
fill-opacity: 1 !important;
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
var BarStyledBox = _styledcomponents2.default.call(void 0, _seedsreactbox.Box)`
|
|
151
|
+
${barFamilyStyles}
|
|
881
152
|
${axisLabelV2Styles}
|
|
882
153
|
`;
|
|
883
154
|
|
|
884
|
-
// src/charts/
|
|
155
|
+
// src/charts/constants.ts
|
|
156
|
+
var BAR_CHART_DEFAULT_SERIES_LIMIT = 10;
|
|
885
157
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
158
|
+
// src/charts/bar/BarChart.tsx
|
|
159
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
160
|
+
var BarChart = _react.memo.call(void 0, function BarChart2(props) {
|
|
161
|
+
const seriesLimit = _nullishCoalesce(props.seriesLimit, () => ( BAR_CHART_DEFAULT_SERIES_LIMIT));
|
|
162
|
+
const { colors, series } = _chunkXVV7PYQEjs.useSeedsChartSetup.call(void 0, {
|
|
889
163
|
series: props.series,
|
|
890
164
|
seriesLimit,
|
|
891
165
|
isSeriesLimitOverridden: props.seriesLimit !== void 0,
|
|
892
166
|
hideSeriesLimitWarning: props.hideSeriesLimitWarning,
|
|
893
|
-
componentName: "
|
|
167
|
+
componentName: "BarChart"
|
|
894
168
|
});
|
|
895
169
|
const { options, annotationLookup, tooltipTimezone } = buildBarChartOptions(
|
|
896
170
|
props,
|
|
897
|
-
"vertical",
|
|
171
|
+
_nullishCoalesce(props.direction, () => ( "vertical")),
|
|
898
172
|
series
|
|
899
173
|
);
|
|
900
174
|
const hasOnClick = Boolean(props.onClick);
|
|
901
175
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
902
|
-
|
|
176
|
+
BarStyledBox,
|
|
903
177
|
{
|
|
904
178
|
$colors: colors,
|
|
905
179
|
$hasOnClick: hasOnClick,
|
|
906
180
|
bg: "container.background.base",
|
|
907
181
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
908
|
-
ChartRenderer,
|
|
182
|
+
_chunkXVV7PYQEjs.ChartRenderer,
|
|
909
183
|
{
|
|
910
184
|
options,
|
|
911
185
|
series,
|
|
@@ -916,7 +190,7 @@ var VerticalBarChart = _react.memo.call(void 0, function VerticalBarChart2(props
|
|
|
916
190
|
tooltipClickLabel: props.tooltipClickLabel,
|
|
917
191
|
timezone: tooltipTimezone,
|
|
918
192
|
invalidNumberLabel: props.invalidNumberLabel,
|
|
919
|
-
valueFormat: _optionalChain([props, 'access',
|
|
193
|
+
valueFormat: _optionalChain([props, 'access', _23 => _23.yAxis, 'optionalAccess', _24 => _24.format]),
|
|
920
194
|
onReady: props.onReady
|
|
921
195
|
}
|
|
922
196
|
)
|
|
@@ -925,5 +199,5 @@ var VerticalBarChart = _react.memo.call(void 0, function VerticalBarChart2(props
|
|
|
925
199
|
});
|
|
926
200
|
|
|
927
201
|
|
|
928
|
-
exports.
|
|
202
|
+
exports.BarChart = BarChart;
|
|
929
203
|
//# sourceMappingURL=index.js.map
|