@sproutsocial/seeds-react-data-viz 0.15.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{axis-PJwu5Xmo.d.ts → axis-BVPkC6iF.d.ts} +1 -1
- package/dist/{axis-DXzufRRj.d.mts → axis-BjucJt39.d.mts} +1 -1
- package/dist/bar/index.d.mts +16 -46
- package/dist/bar/index.d.ts +16 -46
- package/dist/bar/index.js +88 -71
- package/dist/bar/index.js.map +1 -1
- package/dist/{chunk-VSZSIN34.js → chunk-EJYDQYLE.js} +15 -15
- package/dist/chunk-EJYDQYLE.js.map +1 -0
- package/dist/{chunk-EEVKTTT3.js → chunk-WEKDYQ4T.js} +1 -1
- package/dist/chunk-WEKDYQ4T.js.map +1 -0
- package/dist/esm/bar/index.js +79 -62
- package/dist/esm/bar/index.js.map +1 -1
- package/dist/esm/{chunk-OAN5VC7M.js → chunk-DKTW56NJ.js} +3 -3
- package/dist/esm/chunk-DKTW56NJ.js.map +1 -0
- package/dist/esm/{chunk-LC3HGWDD.js → chunk-Z4LOM4OZ.js} +1 -1
- package/dist/esm/chunk-Z4LOM4OZ.js.map +1 -0
- package/dist/esm/export/index.js.map +1 -1
- package/dist/esm/index.js +185 -21
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/line-area/index.js +2 -2
- package/dist/export/index.js.map +1 -1
- package/dist/index.d.mts +23 -23
- package/dist/index.d.ts +23 -23
- package/dist/index.js +278 -114
- package/dist/index.js.map +1 -1
- package/dist/line-area/index.d.mts +2 -2
- package/dist/line-area/index.d.ts +2 -2
- package/dist/line-area/index.js +10 -10
- package/dist/{types-B7ILUQ6_.d.mts → types-DxrhdAdn.d.mts} +3 -3
- package/dist/{types-B7ILUQ6_.d.ts → types-DxrhdAdn.d.ts} +3 -3
- package/package.json +3 -2
- package/dist/chunk-EEVKTTT3.js.map +0 -1
- package/dist/chunk-JXARPHQE.js +0 -193
- package/dist/chunk-JXARPHQE.js.map +0 -1
- package/dist/chunk-VSZSIN34.js.map +0 -1
- package/dist/esm/chunk-HQM3EIZW.js +0 -193
- package/dist/esm/chunk-HQM3EIZW.js.map +0 -1
- package/dist/esm/chunk-LC3HGWDD.js.map +0 -1
- package/dist/esm/chunk-OAN5VC7M.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { TypeIconName } from '@sproutsocial/seeds-react-icon';
|
|
3
|
-
import { c as TypeChartNumberFormat, k as TypeChartStyleColor } from './types-
|
|
3
|
+
import { c as TypeChartNumberFormat, k as TypeChartStyleColor } from './types-DxrhdAdn.js';
|
|
4
4
|
|
|
5
5
|
type TypeValuePercentInput = "decimal" | "whole";
|
|
6
6
|
type TypeValueFormatterOptions = Readonly<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { TypeIconName } from '@sproutsocial/seeds-react-icon';
|
|
3
|
-
import { c as TypeChartNumberFormat, k as TypeChartStyleColor } from './types-
|
|
3
|
+
import { c as TypeChartNumberFormat, k as TypeChartStyleColor } from './types-DxrhdAdn.mjs';
|
|
4
4
|
|
|
5
5
|
type TypeValuePercentInput = "decimal" | "whole";
|
|
6
6
|
type TypeValueFormatterOptions = Readonly<{
|
package/dist/bar/index.d.mts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { TypeIconName } from '@sproutsocial/seeds-react-icon';
|
|
4
|
-
import { C as ChartDataPoint, a as CategoryAxis, D as DatetimeAxis, V as ValueFormat, b as ChartTooltipProps, c as ChartAnnotation, d as DatetimePoint } from '../axis-
|
|
4
|
+
import { C as ChartDataPoint, a as CategoryAxis, D as DatetimeAxis, V as ValueFormat, b as ChartTooltipProps, c as ChartAnnotation, d as DatetimePoint } from '../axis-BjucJt39.mjs';
|
|
5
5
|
import { C as ChartExportHandle } from '../chartExport-CKYpuhik.mjs';
|
|
6
|
-
import '../types-
|
|
6
|
+
import '../types-DxrhdAdn.mjs';
|
|
7
7
|
import 'highcharts';
|
|
8
8
|
|
|
9
|
-
/** A datetime data point: `[msSinceEpoch, value]` tuple or `{ x, y }` object. */
|
|
10
9
|
type BarDatetimePoint = DatetimePoint;
|
|
11
|
-
/** A category y-value, or a datetime point when the dimensional axis is `"datetime"`. */
|
|
12
10
|
type BarDataPoint = ChartDataPoint;
|
|
13
11
|
interface BarSeries {
|
|
14
12
|
name: string;
|
|
15
|
-
/**
|
|
16
|
-
* Y-values indexed parallel to `xAxis.categories` on a category axis, or
|
|
17
|
-
* `[timestamp, value]` / `{ x, y }` points on a datetime axis.
|
|
18
|
-
*/
|
|
13
|
+
/** Y-values for each category, or `[timestamp, value]` / `{ x, y }` points on a datetime axis. */
|
|
19
14
|
data: Array<BarDataPoint>;
|
|
20
15
|
color?: string;
|
|
21
16
|
/** Seeds icon or partner-logo name rendered before the series name in the legend. */
|
|
@@ -28,48 +23,27 @@ interface BarYAxis {
|
|
|
28
23
|
/** Default: true. */
|
|
29
24
|
showGridLines?: boolean;
|
|
30
25
|
title?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Declarative value formatting applied to y-axis tick labels and the default
|
|
33
|
-
* tooltip value. Omit for the zero-config decimal default (smart 1k/10k
|
|
34
|
-
* abbreviation on the axis, raw values in the tooltip).
|
|
35
|
-
*/
|
|
26
|
+
/** Declarative value formatting for axis tick labels and tooltip values. */
|
|
36
27
|
format?: ValueFormat;
|
|
37
|
-
/**
|
|
38
|
-
* Show y-axis tick labels. Default `true`. `false` hides them (maps to
|
|
39
|
-
* Highcharts' `labels.enabled`, replacing v1's `() => ""` formatter trick).
|
|
40
|
-
*/
|
|
28
|
+
/** Show y-axis tick labels. Default `true`. */
|
|
41
29
|
showLabels?: boolean;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
|
-
* Direction in which bars are drawn. Single-member union for now; expands to
|
|
45
|
-
* `"vertical" | "horizontal"` when `HorizontalBarChart` ships.
|
|
46
|
-
*/
|
|
47
|
-
type BarChartDirection = "vertical";
|
|
31
|
+
type BarChartDirection = "vertical" | "horizontal";
|
|
48
32
|
interface BarChartProps {
|
|
49
33
|
/** Wired into Highcharts' `accessibility.description`. */
|
|
50
34
|
description: string;
|
|
51
35
|
series: Array<BarSeries>;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*/
|
|
36
|
+
/** Orientation of the bars. `"vertical"` (default) renders columns; `"horizontal"` renders bars. */
|
|
37
|
+
direction?: BarChartDirection;
|
|
38
|
+
/** Maximum number of series to display. Series beyond the limit are dropped. Default `10`. */
|
|
56
39
|
seriesLimit?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Suppress the `console.warn` emitted when the series count exceeds the limit.
|
|
59
|
-
* The cap still applies. Default `false`.
|
|
60
|
-
*/
|
|
40
|
+
/** Suppress the `console.warn` when series count exceeds the limit. The cap still applies. Default `false`. */
|
|
61
41
|
hideSeriesLimitWarning?: boolean;
|
|
62
42
|
xAxis: BarXAxis;
|
|
63
43
|
yAxis?: BarYAxis;
|
|
64
44
|
/** IANA timezone for datetime-axis ticks and tooltips. Default `"UTC"`. Ignored for category axes. */
|
|
65
45
|
timezone?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Stacking mode for multi-series charts. Defaults to `"normal"` — the
|
|
68
|
-
* canonical design-system spec renders multi-series bar charts as a single
|
|
69
|
-
* stacked column per category. `"percent"` normalizes each column to 100%.
|
|
70
|
-
* `"grouped"` renders series as adjacent bars per category; not part of the
|
|
71
|
-
* canonical spec, but available for non-standard use cases.
|
|
72
|
-
*/
|
|
46
|
+
/** Stacking mode. `"normal"` stacks series (default); `"percent"` normalizes to 100%; `"grouped"` renders adjacent bars. */
|
|
73
47
|
stacking?: "normal" | "percent" | "grouped";
|
|
74
48
|
/** Appended to each tooltip value (e.g., `" MT"`, `"%"`). */
|
|
75
49
|
valueSuffix?: string;
|
|
@@ -77,22 +51,18 @@ interface BarChartProps {
|
|
|
77
51
|
tooltip?: (args: ChartTooltipProps) => ReactNode;
|
|
78
52
|
/** Declarative annotations rendered at positions on the chart. */
|
|
79
53
|
annotations?: ChartAnnotation[];
|
|
80
|
-
/** Click handler invoked with the
|
|
54
|
+
/** Click handler invoked with the category name or timestamp of the clicked bar. */
|
|
81
55
|
onClick?: ({ position }: {
|
|
82
56
|
position: number | string;
|
|
83
57
|
}) => void;
|
|
84
58
|
/** Footer content shown in the default tooltip when `onClick` is set. */
|
|
85
59
|
tooltipClickLabel?: ReactNode;
|
|
86
|
-
/** Override for the value shown when a data point is
|
|
60
|
+
/** Override for the value shown when a data point is null. Defaults to an em-dash. */
|
|
87
61
|
invalidNumberLabel?: ReactNode;
|
|
88
|
-
/**
|
|
89
|
-
* Fired once per chart instance with an opaque {@link ChartExportHandle} for
|
|
90
|
-
* triggering PNG/SVG/PDF/CSV downloads. Re-fires only on a genuine remount,
|
|
91
|
-
* never on data or prop updates.
|
|
92
|
-
*/
|
|
62
|
+
/** Fired once per chart instance with a handle for PNG/SVG/PDF/CSV downloads. Re-fires only on remount. */
|
|
93
63
|
onReady?: (handle: ChartExportHandle) => void;
|
|
94
64
|
}
|
|
95
65
|
|
|
96
|
-
declare const
|
|
66
|
+
declare const BarChart: react.NamedExoticComponent<BarChartProps>;
|
|
97
67
|
|
|
98
|
-
export { type BarChartDirection, type BarChartProps, type BarDataPoint, type BarDatetimePoint, type BarSeries, type BarXAxis, type BarYAxis, CategoryAxis, ChartExportHandle, DatetimeAxis, ValueFormat
|
|
68
|
+
export { BarChart, type BarChartDirection, type BarChartProps, type BarDataPoint, type BarDatetimePoint, type BarSeries, type BarXAxis, type BarYAxis, CategoryAxis, ChartExportHandle, DatetimeAxis, ValueFormat };
|
package/dist/bar/index.d.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { TypeIconName } from '@sproutsocial/seeds-react-icon';
|
|
4
|
-
import { C as ChartDataPoint, a as CategoryAxis, D as DatetimeAxis, V as ValueFormat, b as ChartTooltipProps, c as ChartAnnotation, d as DatetimePoint } from '../axis-
|
|
4
|
+
import { C as ChartDataPoint, a as CategoryAxis, D as DatetimeAxis, V as ValueFormat, b as ChartTooltipProps, c as ChartAnnotation, d as DatetimePoint } from '../axis-BVPkC6iF.js';
|
|
5
5
|
import { C as ChartExportHandle } from '../chartExport-CKYpuhik.js';
|
|
6
|
-
import '../types-
|
|
6
|
+
import '../types-DxrhdAdn.js';
|
|
7
7
|
import 'highcharts';
|
|
8
8
|
|
|
9
|
-
/** A datetime data point: `[msSinceEpoch, value]` tuple or `{ x, y }` object. */
|
|
10
9
|
type BarDatetimePoint = DatetimePoint;
|
|
11
|
-
/** A category y-value, or a datetime point when the dimensional axis is `"datetime"`. */
|
|
12
10
|
type BarDataPoint = ChartDataPoint;
|
|
13
11
|
interface BarSeries {
|
|
14
12
|
name: string;
|
|
15
|
-
/**
|
|
16
|
-
* Y-values indexed parallel to `xAxis.categories` on a category axis, or
|
|
17
|
-
* `[timestamp, value]` / `{ x, y }` points on a datetime axis.
|
|
18
|
-
*/
|
|
13
|
+
/** Y-values for each category, or `[timestamp, value]` / `{ x, y }` points on a datetime axis. */
|
|
19
14
|
data: Array<BarDataPoint>;
|
|
20
15
|
color?: string;
|
|
21
16
|
/** Seeds icon or partner-logo name rendered before the series name in the legend. */
|
|
@@ -28,48 +23,27 @@ interface BarYAxis {
|
|
|
28
23
|
/** Default: true. */
|
|
29
24
|
showGridLines?: boolean;
|
|
30
25
|
title?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Declarative value formatting applied to y-axis tick labels and the default
|
|
33
|
-
* tooltip value. Omit for the zero-config decimal default (smart 1k/10k
|
|
34
|
-
* abbreviation on the axis, raw values in the tooltip).
|
|
35
|
-
*/
|
|
26
|
+
/** Declarative value formatting for axis tick labels and tooltip values. */
|
|
36
27
|
format?: ValueFormat;
|
|
37
|
-
/**
|
|
38
|
-
* Show y-axis tick labels. Default `true`. `false` hides them (maps to
|
|
39
|
-
* Highcharts' `labels.enabled`, replacing v1's `() => ""` formatter trick).
|
|
40
|
-
*/
|
|
28
|
+
/** Show y-axis tick labels. Default `true`. */
|
|
41
29
|
showLabels?: boolean;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
|
-
* Direction in which bars are drawn. Single-member union for now; expands to
|
|
45
|
-
* `"vertical" | "horizontal"` when `HorizontalBarChart` ships.
|
|
46
|
-
*/
|
|
47
|
-
type BarChartDirection = "vertical";
|
|
31
|
+
type BarChartDirection = "vertical" | "horizontal";
|
|
48
32
|
interface BarChartProps {
|
|
49
33
|
/** Wired into Highcharts' `accessibility.description`. */
|
|
50
34
|
description: string;
|
|
51
35
|
series: Array<BarSeries>;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*/
|
|
36
|
+
/** Orientation of the bars. `"vertical"` (default) renders columns; `"horizontal"` renders bars. */
|
|
37
|
+
direction?: BarChartDirection;
|
|
38
|
+
/** Maximum number of series to display. Series beyond the limit are dropped. Default `10`. */
|
|
56
39
|
seriesLimit?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Suppress the `console.warn` emitted when the series count exceeds the limit.
|
|
59
|
-
* The cap still applies. Default `false`.
|
|
60
|
-
*/
|
|
40
|
+
/** Suppress the `console.warn` when series count exceeds the limit. The cap still applies. Default `false`. */
|
|
61
41
|
hideSeriesLimitWarning?: boolean;
|
|
62
42
|
xAxis: BarXAxis;
|
|
63
43
|
yAxis?: BarYAxis;
|
|
64
44
|
/** IANA timezone for datetime-axis ticks and tooltips. Default `"UTC"`. Ignored for category axes. */
|
|
65
45
|
timezone?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Stacking mode for multi-series charts. Defaults to `"normal"` — the
|
|
68
|
-
* canonical design-system spec renders multi-series bar charts as a single
|
|
69
|
-
* stacked column per category. `"percent"` normalizes each column to 100%.
|
|
70
|
-
* `"grouped"` renders series as adjacent bars per category; not part of the
|
|
71
|
-
* canonical spec, but available for non-standard use cases.
|
|
72
|
-
*/
|
|
46
|
+
/** Stacking mode. `"normal"` stacks series (default); `"percent"` normalizes to 100%; `"grouped"` renders adjacent bars. */
|
|
73
47
|
stacking?: "normal" | "percent" | "grouped";
|
|
74
48
|
/** Appended to each tooltip value (e.g., `" MT"`, `"%"`). */
|
|
75
49
|
valueSuffix?: string;
|
|
@@ -77,22 +51,18 @@ interface BarChartProps {
|
|
|
77
51
|
tooltip?: (args: ChartTooltipProps) => ReactNode;
|
|
78
52
|
/** Declarative annotations rendered at positions on the chart. */
|
|
79
53
|
annotations?: ChartAnnotation[];
|
|
80
|
-
/** Click handler invoked with the
|
|
54
|
+
/** Click handler invoked with the category name or timestamp of the clicked bar. */
|
|
81
55
|
onClick?: ({ position }: {
|
|
82
56
|
position: number | string;
|
|
83
57
|
}) => void;
|
|
84
58
|
/** Footer content shown in the default tooltip when `onClick` is set. */
|
|
85
59
|
tooltipClickLabel?: ReactNode;
|
|
86
|
-
/** Override for the value shown when a data point is
|
|
60
|
+
/** Override for the value shown when a data point is null. Defaults to an em-dash. */
|
|
87
61
|
invalidNumberLabel?: ReactNode;
|
|
88
|
-
/**
|
|
89
|
-
* Fired once per chart instance with an opaque {@link ChartExportHandle} for
|
|
90
|
-
* triggering PNG/SVG/PDF/CSV downloads. Re-fires only on a genuine remount,
|
|
91
|
-
* never on data or prop updates.
|
|
92
|
-
*/
|
|
62
|
+
/** Fired once per chart instance with a handle for PNG/SVG/PDF/CSV downloads. Re-fires only on remount. */
|
|
93
63
|
onReady?: (handle: ChartExportHandle) => void;
|
|
94
64
|
}
|
|
95
65
|
|
|
96
|
-
declare const
|
|
66
|
+
declare const BarChart: react.NamedExoticComponent<BarChartProps>;
|
|
97
67
|
|
|
98
|
-
export { type BarChartDirection, type BarChartProps, type BarDataPoint, type BarDatetimePoint, type BarSeries, type BarXAxis, type BarYAxis, CategoryAxis, ChartExportHandle, DatetimeAxis, ValueFormat
|
|
68
|
+
export { BarChart, type BarChartDirection, type BarChartProps, type BarDataPoint, type BarDatetimePoint, type BarSeries, type BarXAxis, type BarYAxis, CategoryAxis, ChartExportHandle, DatetimeAxis, ValueFormat };
|
package/dist/bar/index.js
CHANGED
|
@@ -1,101 +1,99 @@
|
|
|
1
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
|
-
var _chunkJXARPHQEjs = require('../chunk-JXARPHQE.js');
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
10
|
+
var _chunkEJYDQYLEjs = require('../chunk-EJYDQYLE.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
var _chunkWEKDYQ4Tjs = require('../chunk-WEKDYQ4T.js');
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
require('../chunk-EEVKTTT3.js');
|
|
16
|
-
|
|
17
|
-
// src/charts/bar/VerticalBarChart.tsx
|
|
15
|
+
// src/charts/bar/BarChart.tsx
|
|
18
16
|
var _react = require('react');
|
|
19
17
|
|
|
20
18
|
// src/charts/bar/adapter.ts
|
|
21
19
|
function highchartsType(direction) {
|
|
22
|
-
|
|
23
|
-
case "vertical":
|
|
24
|
-
return "column";
|
|
25
|
-
}
|
|
20
|
+
return direction === "horizontal" ? "bar" : "column";
|
|
26
21
|
}
|
|
27
22
|
function buildBarChartOptions(props, direction, series = props.series) {
|
|
28
23
|
const chartType = highchartsType(direction);
|
|
29
24
|
const isDatetime = props.xAxis.type === "datetime";
|
|
30
|
-
const tooltipTimezone =
|
|
31
|
-
const { annotations, lookup: annotationLookup } =
|
|
25
|
+
const tooltipTimezone = _chunkEJYDQYLEjs.resolveTooltipTimezone.call(void 0, props.xAxis, props.timezone);
|
|
26
|
+
const { annotations, lookup: annotationLookup } = _chunkEJYDQYLEjs.buildAnnotationConfig.call(void 0,
|
|
32
27
|
props.annotations
|
|
33
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
|
+
};
|
|
34
72
|
const options = {
|
|
35
|
-
...
|
|
73
|
+
..._chunkEJYDQYLEjs.buildBaseChartOptions.call(void 0, {
|
|
36
74
|
type: chartType,
|
|
37
75
|
description: props.description,
|
|
38
76
|
valueSuffix: props.valueSuffix,
|
|
39
77
|
reserveTopMargin: Boolean(annotations),
|
|
40
78
|
timezone: tooltipTimezone
|
|
41
79
|
}),
|
|
42
|
-
xAxis:
|
|
80
|
+
xAxis: _chunkEJYDQYLEjs.buildDimensionalAxis.call(void 0, props.xAxis, _nullishCoalesce(tooltipTimezone, () => ( "UTC"))),
|
|
43
81
|
yAxis: {
|
|
44
|
-
min: _optionalChain([props, 'access',
|
|
45
|
-
max: _optionalChain([props, 'access',
|
|
46
|
-
gridLineWidth: _optionalChain([props, 'access',
|
|
47
|
-
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]), () => ( "")) },
|
|
48
86
|
labels: {
|
|
49
87
|
// `showLabels` toggles tick-label visibility; defaults to shown.
|
|
50
|
-
enabled: _optionalChain([props, 'access',
|
|
88
|
+
enabled: _optionalChain([props, 'access', _19 => _19.yAxis, 'optionalAccess', _20 => _20.showLabels]) !== false,
|
|
51
89
|
// A declarative `format` drives ticks through the shared valueFormatter;
|
|
52
90
|
// absent it, the zero-config decimal default (1.20K / 1.20M / 1.20B).
|
|
53
|
-
formatter: _optionalChain([props, 'access',
|
|
91
|
+
formatter: _optionalChain([props, 'access', _21 => _21.yAxis, 'optionalAccess', _22 => _22.format]) ? _chunkEJYDQYLEjs.makeValueAxisLabelFormatter.call(void 0, props.yAxis.format) : _chunkEJYDQYLEjs.defaultValueAxisLabelFormatter
|
|
54
92
|
}
|
|
55
93
|
},
|
|
56
94
|
plotOptions: {
|
|
57
95
|
series: { animation: false },
|
|
58
|
-
|
|
59
|
-
// "grouped" maps to omitting `stacking` — Highcharts renders multi-series
|
|
60
|
-
// columns side-by-side when no stacking is set.
|
|
61
|
-
...props.stacking === "grouped" ? {} : { stacking: _nullishCoalesce(props.stacking, () => ( "normal")) },
|
|
62
|
-
pointPadding: 0.25,
|
|
63
|
-
groupPadding: 0.25,
|
|
64
|
-
// Fixed bar width on datetime axes. Sparse time-series otherwise size
|
|
65
|
-
// columns from the (large) gap between points and balloon; this mirrors
|
|
66
|
-
// v1's `pointWidth: 20` time-series treatment. Dense datetime data may
|
|
67
|
-
// instead want a `maxPointWidth` cap — revisit when Line/Area land.
|
|
68
|
-
...isDatetime ? { pointWidth: 20 } : {},
|
|
69
|
-
borderRadius: 4,
|
|
70
|
-
borderWidth: 0,
|
|
71
|
-
// Pairs with the `:hover` dimming rule in `styles.ts`: while the cursor
|
|
72
|
-
// is over the chart, all bars dim; these handlers restore opacity for
|
|
73
|
-
// every bar at the hovered x (so stacked/grouped columns highlight
|
|
74
|
-
// together rather than just the single hovered bar).
|
|
75
|
-
point: {
|
|
76
|
-
events: {
|
|
77
|
-
click: props.onClick ? (event) => props.onClick({ position: event.point.x }) : void 0,
|
|
78
|
-
mouseOver: function() {
|
|
79
|
-
const x = this.x;
|
|
80
|
-
this.series.chart.series.forEach((s) => {
|
|
81
|
-
if (s.type !== "column") return;
|
|
82
|
-
s.data.forEach((point) => {
|
|
83
|
-
if (point.x !== x) return;
|
|
84
|
-
_optionalChain([point, 'access', _13 => _13.graphic, 'optionalAccess', _14 => _14.element, 'optionalAccess', _15 => _15.classList, 'access', _16 => _16.add, 'call', _17 => _17("column-hover")]);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
mouseOut: function() {
|
|
89
|
-
this.series.chart.series.forEach((s) => {
|
|
90
|
-
if (s.type !== "column") return;
|
|
91
|
-
s.data.forEach((point) => {
|
|
92
|
-
_optionalChain([point, 'access', _18 => _18.graphic, 'optionalAccess', _19 => _19.element, 'optionalAccess', _20 => _20.classList, 'access', _21 => _21.remove, 'call', _22 => _22("column-hover")]);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
96
|
+
[chartType]: barTypeConfig
|
|
99
97
|
},
|
|
100
98
|
series: series.map((s) => ({
|
|
101
99
|
type: chartType,
|
|
@@ -133,36 +131,55 @@ var axisLabelV2Styles = _styledcomponents.css`
|
|
|
133
131
|
`;
|
|
134
132
|
|
|
135
133
|
// src/charts/bar/styles.ts
|
|
136
|
-
var
|
|
137
|
-
${
|
|
134
|
+
var barFamilyStyles = _styledcomponents.css`
|
|
135
|
+
${_chunkWEKDYQ4Tjs.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}
|
|
138
152
|
${axisLabelV2Styles}
|
|
139
153
|
`;
|
|
140
154
|
|
|
141
|
-
// src/charts/
|
|
155
|
+
// src/charts/constants.ts
|
|
156
|
+
var BAR_CHART_DEFAULT_SERIES_LIMIT = 10;
|
|
157
|
+
|
|
158
|
+
// src/charts/bar/BarChart.tsx
|
|
142
159
|
var _jsxruntime = require('react/jsx-runtime');
|
|
143
|
-
var
|
|
144
|
-
const seriesLimit = _nullishCoalesce(props.seriesLimit, () => (
|
|
145
|
-
const { colors, series } =
|
|
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 } = _chunkEJYDQYLEjs.useSeedsChartSetup.call(void 0, {
|
|
146
163
|
series: props.series,
|
|
147
164
|
seriesLimit,
|
|
148
165
|
isSeriesLimitOverridden: props.seriesLimit !== void 0,
|
|
149
166
|
hideSeriesLimitWarning: props.hideSeriesLimitWarning,
|
|
150
|
-
componentName: "
|
|
167
|
+
componentName: "BarChart"
|
|
151
168
|
});
|
|
152
169
|
const { options, annotationLookup, tooltipTimezone } = buildBarChartOptions(
|
|
153
170
|
props,
|
|
154
|
-
"vertical",
|
|
171
|
+
_nullishCoalesce(props.direction, () => ( "vertical")),
|
|
155
172
|
series
|
|
156
173
|
);
|
|
157
174
|
const hasOnClick = Boolean(props.onClick);
|
|
158
175
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
159
|
-
|
|
176
|
+
BarStyledBox,
|
|
160
177
|
{
|
|
161
178
|
$colors: colors,
|
|
162
179
|
$hasOnClick: hasOnClick,
|
|
163
180
|
bg: "container.background.base",
|
|
164
181
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
165
|
-
|
|
182
|
+
_chunkEJYDQYLEjs.ChartRenderer,
|
|
166
183
|
{
|
|
167
184
|
options,
|
|
168
185
|
series,
|
|
@@ -182,5 +199,5 @@ var VerticalBarChart = _react.memo.call(void 0, function VerticalBarChart2(props
|
|
|
182
199
|
});
|
|
183
200
|
|
|
184
201
|
|
|
185
|
-
exports.
|
|
202
|
+
exports.BarChart = BarChart;
|
|
186
203
|
//# sourceMappingURL=index.js.map
|
package/dist/bar/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/bar/index.js","../../src/charts/bar/VerticalBarChart.tsx","../../src/charts/bar/adapter.ts","../../src/charts/bar/styles.ts","../../src/charts/shared/styles.ts"],"names":["VerticalBarChart"],"mappings":"AAAA;AACE;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B;AACA;AChBA,8BAAqB;ADkBrB;AACA;AEFA,SAAS,cAAA,CAAe,SAAA,EAAwC;AAC9D,EAAA,OAAA,CAAQ,SAAA,EAAW;AAAA,IACjB,KAAK,UAAA;AACH,MAAA,OAAO,QAAA;AAAA,EACX;AACF;AAEO,SA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AA,CAAM,OAAO,CAAA;AAExC,EAAA,uBACE,6BAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACC,OAAA,EAAS,MAAA;AAAA,MACT,WAAA,EAAa,UAAA;AAAA,MACb,EAAA,EAAG,2BAAA;AAAA,MAEH,QAAA,kBAAA,6BAAA;AAAA,QAAC,8BAAA;AAAA,QAAA;AAAA,UACC,OAAA;AAAA,UACA,MAAA;AAAA,UACA,MAAA;AAAA,UACA,OAAA,EAAS,KAAA,CAAM,OAAA;AAAA,UACf,gBAAA;AAAA,UACA,UAAA;AAAA,UACA,iBAAA,EAAmB,KAAA,CAAM,iBAAA;AAAA,UACzB,QAAA,EAAU,eAAA;AAAA,UACV,kBAAA,EAAoB,KAAA,CAAM,kBAAA;AAAA,UAC1B,WAAA,kBAAa,KAAA,uBAAM,KAAA,+BAAO,QAAA;AAAA,UAC1B,OAAA,EAAS,KAAA,CAAM;AAAA,QAAA;AAAA,MACjB;AAAA,IAAA;AAAA,EACF,CAAA;AAEJ,CAAC,CAAA;ADmID;AACE;AACF,4CAAC","file":"/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/bar/index.js","sourcesContent":[null,"import { memo } from \"react\";\nimport { useSeedsChartSetup, ChartRenderer } from \"../shared/chartBase\";\nimport { buildBarChartOptions } from \"./adapter\";\nimport { VerticalBarStyledBox } from \"./styles\";\nimport type { BarChartProps } from \"./types\";\nimport { VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT } from \"../../constants\";\n\nexport const VerticalBarChart = memo(function VerticalBarChart(\n props: BarChartProps\n) {\n // The shared hook caps the series to the limit (and warns once per render\n // when the default is exceeded without an explicit override) so the adapter\n // and renderer below all consume the capped data.\n const seriesLimit =\n props.seriesLimit ?? VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT;\n const { colors, series } = useSeedsChartSetup({\n series: props.series,\n seriesLimit,\n isSeriesLimitOverridden: props.seriesLimit !== undefined,\n hideSeriesLimitWarning: props.hideSeriesLimitWarning,\n componentName: \"VerticalBarChart\",\n });\n\n const { options, annotationLookup, tooltipTimezone } = buildBarChartOptions(\n props,\n \"vertical\",\n series\n );\n const hasOnClick = Boolean(props.onClick);\n\n return (\n <VerticalBarStyledBox\n $colors={colors}\n $hasOnClick={hasOnClick}\n bg=\"container.background.base\"\n >\n <ChartRenderer\n options={options}\n series={series}\n colors={colors}\n tooltip={props.tooltip}\n annotationLookup={annotationLookup}\n hasOnClick={hasOnClick}\n tooltipClickLabel={props.tooltipClickLabel}\n timezone={tooltipTimezone}\n invalidNumberLabel={props.invalidNumberLabel}\n valueFormat={props.yAxis?.format}\n onReady={props.onReady}\n />\n </VerticalBarStyledBox>\n );\n});\n","import { buildAnnotationConfig } from \"../shared/annotations\";\nimport type { ChartAnnotationLookup } from \"../shared/annotations\";\nimport type { SeedsChartOptions } from \"../shared/chartBase\";\nimport { buildBaseChartOptions } from \"../shared/baseChartOptions\";\nimport {\n buildDimensionalAxis,\n resolveTooltipTimezone,\n} from \"../shared/axisOptions\";\nimport {\n defaultValueAxisLabelFormatter,\n makeValueAxisLabelFormatter,\n} from \"../shared/valueAxisLabelFormatter\";\nimport type { BarChartDirection, BarChartProps } from \"./types\";\n\n// `direction` is a single-member union for now (`\"vertical\"`). When\n// `HorizontalBarChart` ships, the union expands and this switch fails to\n// compile until the `\"horizontal\"` case is added.\nfunction highchartsType(direction: BarChartDirection): \"column\" {\n switch (direction) {\n case \"vertical\":\n return \"column\";\n }\n}\n\nexport function buildBarChartOptions(\n props: BarChartProps,\n direction: BarChartDirection,\n // The (already-capped) series to render. Defaults to `props.series` so the\n // ~40 existing call sites keep working; the component passes the capped\n // series from `useSeedsChartSetup` explicitly.\n series: BarChartProps[\"series\"] = props.series\n): {\n options: SeedsChartOptions;\n annotationLookup: ChartAnnotationLookup | undefined;\n /** Resolved timezone for the tooltip date formatter; undefined on category axes. */\n tooltipTimezone: string | undefined;\n} {\n const chartType = highchartsType(direction);\n const isDatetime = props.xAxis.type === \"datetime\";\n const tooltipTimezone = resolveTooltipTimezone(props.xAxis, props.timezone);\n const { annotations, lookup: annotationLookup } = buildAnnotationConfig(\n props.annotations\n );\n const options: SeedsChartOptions = {\n ...buildBaseChartOptions({\n type: chartType,\n description: props.description,\n valueSuffix: props.valueSuffix,\n reserveTopMargin: Boolean(annotations),\n timezone: tooltipTimezone,\n }),\n xAxis: buildDimensionalAxis(props.xAxis, tooltipTimezone ?? \"UTC\"),\n yAxis: {\n min: props.yAxis?.min,\n max: props.yAxis?.max,\n gridLineWidth: props.yAxis?.showGridLines === false ? 0 : 1,\n title: { text: props.yAxis?.title ?? \"\" },\n labels: {\n // `showLabels` toggles tick-label visibility; defaults to shown.\n enabled: props.yAxis?.showLabels !== false,\n // A declarative `format` drives ticks through the shared valueFormatter;\n // absent it, the zero-config decimal default (1.20K / 1.20M / 1.20B).\n formatter: props.yAxis?.format\n ? makeValueAxisLabelFormatter(props.yAxis.format)\n : defaultValueAxisLabelFormatter,\n },\n },\n plotOptions: {\n series: { animation: false },\n column: {\n // \"grouped\" maps to omitting `stacking` — Highcharts renders multi-series\n // columns side-by-side when no stacking is set.\n ...(props.stacking === \"grouped\"\n ? {}\n : { stacking: props.stacking ?? \"normal\" }),\n pointPadding: 0.25,\n groupPadding: 0.25,\n // Fixed bar width on datetime axes. Sparse time-series otherwise size\n // columns from the (large) gap between points and balloon; this mirrors\n // v1's `pointWidth: 20` time-series treatment. Dense datetime data may\n // instead want a `maxPointWidth` cap — revisit when Line/Area land.\n ...(isDatetime ? { pointWidth: 20 } : {}),\n borderRadius: 4,\n borderWidth: 0,\n // Pairs with the `:hover` dimming rule in `styles.ts`: while the cursor\n // is over the chart, all bars dim; these handlers restore opacity for\n // every bar at the hovered x (so stacked/grouped columns highlight\n // together rather than just the single hovered bar).\n point: {\n events: {\n click: props.onClick\n ? (event) => props.onClick!({ position: event.point.x })\n : undefined,\n mouseOver: function () {\n const x = this.x;\n this.series.chart.series.forEach((s) => {\n if (s.type !== \"column\") return;\n s.data.forEach((point) => {\n if (point.x !== x) return;\n point.graphic?.element?.classList.add(\"column-hover\");\n });\n });\n },\n mouseOut: function () {\n this.series.chart.series.forEach((s) => {\n if (s.type !== \"column\") return;\n s.data.forEach((point) => {\n point.graphic?.element?.classList.remove(\"column-hover\");\n });\n });\n },\n },\n },\n },\n },\n series: series.map((s) => ({\n type: chartType,\n name: s.name,\n data: [...s.data],\n color: s.color,\n })),\n ...(annotations ? { annotations } : {}),\n };\n\n return { options, annotationLookup, tooltipTimezone };\n}\n","import styled from \"styled-components\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\nimport { verticalBarChartStyles } from \"../../components/VerticalBarChart/styles\";\nimport { axisLabelV2Styles } from \"../shared/styles\";\nimport type {\n TypeChartStyleColor,\n TypeChartStyleHasOnClick,\n} from \"../../types\";\n\ntype StyleProps = Readonly<{\n $colors: ReadonlyArray<TypeChartStyleColor>;\n $hasOnClick: TypeChartStyleHasOnClick;\n}>;\n\nexport const VerticalBarStyledBox = styled(Box)<StyleProps>`\n ${verticalBarChartStyles}\n ${axisLabelV2Styles}\n`;\n","import { css } from \"styled-components\";\n\n/**\n * v2 chart axis-label styles. v2 charts render in `styledMode` with\n * `useHTML: false`, so axis labels are SVG `<text>` / `<tspan>` rather than the\n * HTML `<span>`s v1 uses; these mirror the v1 HTML label rules in\n * `styles/chartStyles.ts` for the SVG element type.\n *\n * Kept here, separate from v1's `timeSeriesChartStyles`: v2 may *consume* the v1\n * styles, but v2-specific rules must not accrete into the v1 files — that keeps\n * the eventual v1 → v2 port clean and avoids coupling. Compose this into each v2\n * chart family's styled wrapper.\n */\nexport const axisLabelV2Styles = css`\n .highcharts-xaxis-labels,\n .highcharts-yaxis-labels {\n // SVG labels (styledMode): fill is the SVG text colour; color has no effect.\n text {\n font-family: ${({ theme }) => theme.fontFamily};\n ${({ theme }) => theme.typography[100]};\n font-weight: ${({ theme }) => theme.fontWeights.normal};\n fill: ${({ theme }) => theme.colors.text.subtext};\n }\n }\n // Two-line stacked datetime label: the boundary token is an\n // hc-axis-label-secondary tspan on a second line, rendered semibold.\n .highcharts-xaxis-labels text tspan.hc-axis-label-secondary {\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n }\n`;\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/bar/index.js","../../src/charts/bar/BarChart.tsx","../../src/charts/bar/adapter.ts","../../src/charts/bar/styles.ts","../../src/charts/shared/styles.ts","../../src/charts/constants.ts"],"names":["css","BarChart"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uDAA6B;AAC7B;AACE;AACF,uDAA6B;AAC7B;AACA;ACdA,8BAAqB;ADgBrB;AACA;AEIA,SAAS,cAAA,CAAe,SAAA,EAAgD;AACtE,EAAA,OAAO,UAAA,IAAc,aAAA,EAAe,MAAA,EAAQ,QAAA;AAC9C;AAEO,SAAS,oBAAA,CACd,KAAA,EACA,SAAA,EAIA,OAAA,EAAkC,KAAA,CAAM,MAAA,EAMxC;AACA,EAAA,MAAM,UAAA,EAAY,cAAA,CAAe,SAAS,CAAA;AAC1C,EAAA,MAAM,WAAA,EAAa,KAAA,CAAM,KAAA,CAAM,KAAA,IAAS,UAAA;AACxC,EAAA,MAAM,gBAAA,EAAkB,qDAAA,KAAuB,CAAM,KAAA,EAAO,KAAA,CAAM,QAAQ,CAAA;AAC1E,EAAA,MAAM,EAAE,WAAA,EAAa,MAAA,EAAQ,iBAAiB,EAAA,EAAI,oDAAA;AAAA,IAChD,KAAA,CAAM;AAAA,EACR,CAAA;AAKA,EAAA,MAAM,cAAA,EAA6C;AAAA;AAAA;AAAA,IAGjD,GAAI,KAAA,CAAM,SAAA,IAAa,UAAA,EACnB,CAAC,EAAA,EACD,EAAE,QAAA,mBAAU,KAAA,CAAM,QAAA,UAAY,WAAS,CAAA;AAAA;AAAA;AAAA,IAG3C,YAAA,EAAc,UAAA,IAAc,aAAA,EAAe,KAA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AAAA,UACA,OAAA,EAAS,KAAA,CAAM,OAAA;AAAA,UACf,gBAAA;AAAA,UACA,UAAA;AAAA,UACA,iBAAA,EAAmB,KAAA,CAAM,iBAAA;AAAA,UACzB,QAAA,EAAU,eAAA;AAAA,UACV,kBAAA,EAAoB,KAAA,CAAM,kBAAA;AAAA,UAC1B,WAAA,kBAAa,KAAA,uBAAM,KAAA,+BAAO,QAAA;AAAA,UAC1B,OAAA,EAAS,KAAA,CAAM;AAAA,QAAA;AAAA,MACjB;AAAA,IAAA;AAAA,EACF,CAAA;AAEJ,CAAC,CAAA;ADuJD;AACE;AACF,4BAAC","file":"/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/bar/index.js","sourcesContent":[null,"import { memo } from \"react\";\nimport { useSeedsChartSetup, ChartRenderer } from \"../shared/chartBase\";\nimport { buildBarChartOptions } from \"./adapter\";\nimport { BarStyledBox } from \"./styles\";\nimport type { BarChartProps } from \"./types\";\nimport { BAR_CHART_DEFAULT_SERIES_LIMIT } from \"../constants\";\n\nexport const BarChart = memo(function BarChart(props: BarChartProps) {\n // The shared hook caps the series to the limit (and warns once per render\n // when the default is exceeded without an explicit override) so the adapter\n // and renderer below all consume the capped data.\n const seriesLimit = props.seriesLimit ?? BAR_CHART_DEFAULT_SERIES_LIMIT;\n const { colors, series } = useSeedsChartSetup({\n series: props.series,\n seriesLimit,\n isSeriesLimitOverridden: props.seriesLimit !== undefined,\n hideSeriesLimitWarning: props.hideSeriesLimitWarning,\n componentName: \"BarChart\",\n });\n\n const { options, annotationLookup, tooltipTimezone } = buildBarChartOptions(\n props,\n props.direction ?? \"vertical\",\n series\n );\n const hasOnClick = Boolean(props.onClick);\n\n return (\n <BarStyledBox\n $colors={colors}\n $hasOnClick={hasOnClick}\n bg=\"container.background.base\"\n >\n <ChartRenderer\n options={options}\n series={series}\n colors={colors}\n tooltip={props.tooltip}\n annotationLookup={annotationLookup}\n hasOnClick={hasOnClick}\n tooltipClickLabel={props.tooltipClickLabel}\n timezone={tooltipTimezone}\n invalidNumberLabel={props.invalidNumberLabel}\n valueFormat={props.yAxis?.format}\n onReady={props.onReady}\n />\n </BarStyledBox>\n );\n});\n","import { buildAnnotationConfig } from \"../shared/annotations\";\nimport type { ChartAnnotationLookup } from \"../shared/annotations\";\nimport type {\n SeedsChartColumnPlotOptions,\n SeedsChartOptions,\n} from \"../shared/chartBase\";\nimport { buildBaseChartOptions } from \"../shared/baseChartOptions\";\nimport {\n buildDimensionalAxis,\n resolveTooltipTimezone,\n} from \"../shared/axisOptions\";\nimport {\n defaultValueAxisLabelFormatter,\n makeValueAxisLabelFormatter,\n} from \"../shared/valueAxisLabelFormatter\";\nimport type { BarChartDirection, BarChartProps } from \"./types\";\n\n// Maps the public `direction` to the Highcharts series/chart type. Highcharts\n// `bar` is a horizontally-oriented `column`: it performs the visual rotation\n// while keeping axis roles (xAxis = category, yAxis = value), so the rest of the\n// adapter is direction-agnostic.\nfunction highchartsType(direction: BarChartDirection): \"column\" | \"bar\" {\n return direction === \"horizontal\" ? \"bar\" : \"column\";\n}\n\nexport function buildBarChartOptions(\n props: BarChartProps,\n direction: BarChartDirection,\n // The (already-capped) series to render. Defaults to `props.series` so the\n // ~40 existing call sites keep working; the component passes the capped\n // series from `useSeedsChartSetup` explicitly.\n series: BarChartProps[\"series\"] = props.series\n): {\n options: SeedsChartOptions;\n annotationLookup: ChartAnnotationLookup | undefined;\n /** Resolved timezone for the tooltip date formatter; undefined on category axes. */\n tooltipTimezone: string | undefined;\n} {\n const chartType = highchartsType(direction);\n const isDatetime = props.xAxis.type === \"datetime\";\n const tooltipTimezone = resolveTooltipTimezone(props.xAxis, props.timezone);\n const { annotations, lookup: annotationLookup } = buildAnnotationConfig(\n props.annotations\n );\n // `column` (vertical) and `bar` (horizontal) take the same option shape, so a\n // single config is assigned under the active direction's key. Typed\n // explicitly so the `point.events` handlers below keep their `this`/`event`\n // contextual types (a computed `[chartType]` key would otherwise erase them).\n const barTypeConfig: SeedsChartColumnPlotOptions = {\n // \"grouped\" maps to omitting `stacking` — Highcharts renders multi-series\n // columns side-by-side when no stacking is set.\n ...(props.stacking === \"grouped\"\n ? {}\n : { stacking: props.stacking ?? \"normal\" }),\n // Horizontal bars are height-constrained (fixed chart height ÷ categories),\n // so the same padding fractions that work for columns produce hairline bars.\n pointPadding: direction === \"horizontal\" ? 0.05 : 0.25,\n groupPadding: direction === \"horizontal\" ? 0.1 : 0.25,\n // Fixed bar width on datetime axes. Sparse time-series otherwise size\n // columns from the (large) gap between points and balloon; this mirrors\n // v1's `pointWidth: 20` time-series treatment. Dense datetime data may\n // instead want a `maxPointWidth` cap — revisit when Line/Area land.\n ...(isDatetime ? { pointWidth: 20 } : {}),\n borderRadius: 4,\n borderWidth: 0,\n // Pairs with the `:hover` dimming rule in `styles.ts`: while the cursor\n // is over the chart, all bars dim; these handlers restore opacity for\n // every bar at the hovered x (so stacked/grouped bars highlight together\n // rather than just the single hovered bar).\n point: {\n events: {\n click: props.onClick\n ? (event) => props.onClick!({ position: event.point.x })\n : undefined,\n mouseOver: function () {\n const x = this.x;\n this.series.chart.series.forEach((s) => {\n if (s.type !== chartType) return;\n s.data.forEach((point) => {\n if (point.x !== x) return;\n point.graphic?.element?.classList.add(\"bar-point-hover\");\n });\n });\n },\n mouseOut: function () {\n this.series.chart.series.forEach((s) => {\n if (s.type !== chartType) return;\n s.data.forEach((point) => {\n point.graphic?.element?.classList.remove(\"bar-point-hover\");\n });\n });\n },\n },\n },\n };\n const options: SeedsChartOptions = {\n ...buildBaseChartOptions({\n type: chartType,\n description: props.description,\n valueSuffix: props.valueSuffix,\n reserveTopMargin: Boolean(annotations),\n timezone: tooltipTimezone,\n }),\n xAxis: buildDimensionalAxis(props.xAxis, tooltipTimezone ?? \"UTC\"),\n yAxis: {\n min: props.yAxis?.min,\n max: props.yAxis?.max,\n gridLineWidth: props.yAxis?.showGridLines === false ? 0 : 1,\n title: { text: props.yAxis?.title ?? \"\" },\n labels: {\n // `showLabels` toggles tick-label visibility; defaults to shown.\n enabled: props.yAxis?.showLabels !== false,\n // A declarative `format` drives ticks through the shared valueFormatter;\n // absent it, the zero-config decimal default (1.20K / 1.20M / 1.20B).\n formatter: props.yAxis?.format\n ? makeValueAxisLabelFormatter(props.yAxis.format)\n : defaultValueAxisLabelFormatter,\n },\n },\n plotOptions: {\n series: { animation: false },\n [chartType]: barTypeConfig,\n },\n series: series.map((s) => ({\n type: chartType,\n name: s.name,\n data: [...s.data],\n color: s.color,\n })),\n ...(annotations ? { annotations } : {}),\n };\n\n return { options, annotationLookup, tooltipTimezone };\n}\n","import styled, { css } from \"styled-components\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\nimport { timeSeriesChartStyles } from \"../../styles/chartStyles\";\nimport { axisLabelV2Styles } from \"../shared/styles\";\nimport type {\n TypeChartStyleColor,\n TypeChartStyleHasOnClick,\n} from \"../../types\";\n\ntype StyleProps = Readonly<{\n $colors: ReadonlyArray<TypeChartStyleColor>;\n $hasOnClick: TypeChartStyleHasOnClick;\n}>;\n\n// Direction-neutral styling shared by the v2 bar family (vertical + horizontal).\n// Consumes only the v1 `timeSeriesChartStyles` base and owns the hover-dimming\n// block itself, keyed on the neutral `.bar-point-hover` class the adapter emits\n// — so v2 no longer imports v1 *component* styles (see `shared/styles.ts`).\nexport const barFamilyStyles = css<StyleProps>`\n ${timeSeriesChartStyles}\n\n /*\n When the chart container is hovered, dim all bars. Then restore opacity for\n the hovered bar(s) — flagged with the bar-point-hover class by the adapter —\n so the non-hovered bars fade out.\n */\n .highcharts-container:hover .highcharts-point {\n fill-opacity: 0.3;\n }\n\n .highcharts-point.bar-point-hover {\n fill-opacity: 1 !important;\n }\n`;\n\nexport const BarStyledBox = styled(Box)<StyleProps>`\n ${barFamilyStyles}\n ${axisLabelV2Styles}\n`;\n","import { css } from \"styled-components\";\n\n/**\n * v2 chart axis-label styles. v2 charts render in `styledMode` with\n * `useHTML: false`, so axis labels are SVG `<text>` / `<tspan>` rather than the\n * HTML `<span>`s v1 uses; these mirror the v1 HTML label rules in\n * `styles/chartStyles.ts` for the SVG element type.\n *\n * Kept here, separate from v1's `timeSeriesChartStyles`: v2 may *consume* the v1\n * styles, but v2-specific rules must not accrete into the v1 files — that keeps\n * the eventual v1 → v2 port clean and avoids coupling. Compose this into each v2\n * chart family's styled wrapper.\n */\nexport const axisLabelV2Styles = css`\n .highcharts-xaxis-labels,\n .highcharts-yaxis-labels {\n // SVG labels (styledMode): fill is the SVG text colour; color has no effect.\n text {\n font-family: ${({ theme }) => theme.fontFamily};\n ${({ theme }) => theme.typography[100]};\n font-weight: ${({ theme }) => theme.fontWeights.normal};\n fill: ${({ theme }) => theme.colors.text.subtext};\n }\n }\n // Two-line stacked datetime label: the boundary token is an\n // hc-axis-label-secondary tspan on a second line, rendered semibold.\n .highcharts-xaxis-labels text tspan.hc-axis-label-secondary {\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n }\n`;\n","export const BAR_CHART_DEFAULT_SERIES_LIMIT = 10;\n"]}
|