@sproutsocial/seeds-react-data-viz 0.16.1 → 0.17.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/annotations-CjFoRPXf.d.mts +20 -0
- package/dist/annotations-CjFoRPXf.d.ts +20 -0
- package/dist/axis-WOeYkTO1.d.mts +44 -0
- package/dist/axis-WOeYkTO1.d.ts +44 -0
- package/dist/bar/index.d.mts +3 -1
- package/dist/bar/index.d.ts +3 -1
- package/dist/bar/index.js +12 -8
- package/dist/bar/index.js.map +1 -1
- package/dist/{axis-BVPkC6iF.d.ts → chartBase-C-l7yYGx.d.ts} +5 -59
- package/dist/{axis-BjucJt39.d.mts → chartBase-Cn_5CUJi.d.mts} +5 -59
- package/dist/{chunk-EJYDQYLE.js → chunk-2K7PFHIM.js} +92 -245
- package/dist/chunk-2K7PFHIM.js.map +1 -0
- package/dist/chunk-6D7P3IOT.js +150 -0
- package/dist/chunk-6D7P3IOT.js.map +1 -0
- package/dist/chunk-CYQXUAJC.js +169 -0
- package/dist/chunk-CYQXUAJC.js.map +1 -0
- package/dist/chunk-VVGBJOFH.js +68 -0
- package/dist/chunk-VVGBJOFH.js.map +1 -0
- package/dist/donut/index.d.mts +48 -0
- package/dist/donut/index.d.ts +48 -0
- package/dist/donut/index.js +125 -0
- package/dist/donut/index.js.map +1 -0
- package/dist/esm/bar/index.js +10 -6
- package/dist/esm/bar/index.js.map +1 -1
- package/dist/esm/chunk-AUJ3EWRH.js +68 -0
- package/dist/esm/chunk-AUJ3EWRH.js.map +1 -0
- package/dist/esm/{chunk-DKTW56NJ.js → chunk-LPQXJJNT.js} +93 -246
- package/dist/esm/chunk-LPQXJJNT.js.map +1 -0
- package/dist/esm/chunk-NAKJY5PA.js +150 -0
- package/dist/esm/chunk-NAKJY5PA.js.map +1 -0
- package/dist/esm/chunk-XMYGML25.js +169 -0
- package/dist/esm/chunk-XMYGML25.js.map +1 -0
- package/dist/esm/donut/index.js +125 -0
- package/dist/esm/donut/index.js.map +1 -0
- package/dist/esm/index.js +13 -157
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/line-area/index.js +11 -6
- package/dist/esm/line-area/index.js.map +1 -1
- package/dist/esm/sparkline/index.js +123 -0
- package/dist/esm/sparkline/index.js.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +55 -199
- package/dist/index.js.map +1 -1
- package/dist/line-area/index.d.mts +6 -3
- package/dist/line-area/index.d.ts +6 -3
- package/dist/line-area/index.js +13 -8
- package/dist/line-area/index.js.map +1 -1
- package/dist/sparkline/index.d.mts +75 -0
- package/dist/sparkline/index.d.ts +75 -0
- package/dist/sparkline/index.js +123 -0
- package/dist/sparkline/index.js.map +1 -0
- package/dist/sparkline.css +76 -0
- package/package.json +13 -2
- package/dist/chunk-EJYDQYLE.js.map +0 -1
- package/dist/esm/chunk-DKTW56NJ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/line-area/index.js","../../src/charts/line-area/LineAreaChart.tsx","../../src/charts/line-area/adapter.ts","../../src/charts/line-area/styles.ts"],"names":["AREA_VARIANTS","LineAreaChart"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACF,uDAA6B;AAC7B;AACA;ACfA,8BAA8B;ADiB9B;AACA;AEEA,IAAM,cAAA,kBAAgB,IAAI,GAAA,CAAqB,CAAC,MAAA,EAAQ,YAAY,CAAC,CAAA;AAQrE,SAAS,MAAA,CAAO,KAAA,EAAsC;AACpD,EAAA,GAAA,CAAI,MAAA,IAAU,IAAA,EAAM,OAAO,IAAA;AAC3B,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,GAAA,CAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAA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,CAAM,kBAAA;AAAA,UAC1B,OAAA,EAAS,KAAA,CAAM;AAAA,QAAA;AAAA,MACjB;AAAA,IAAA;AAAA,EACF,CAAA;AAEJ,CAAC,CAAA;ADwGD;AACE;AACF,sCAAC","file":"/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/line-area/index.js","sourcesContent":[null,"import { memo, useMemo } from \"react\";\nimport { useSeedsChartSetup, ChartRenderer } from \"../shared/chartBase\";\nimport { buildLineAreaChartOptions } from \"./adapter\";\nimport { LineAreaChartContainer } from \"./styles\";\nimport type { LineAreaChartProps, LineAreaVariant } from \"./types\";\n\nconst AREA_VARIANTS = new Set<LineAreaVariant>([\"area\", \"areaspline\"]);\n\nexport const LineAreaChart = memo(function LineAreaChart(\n props: LineAreaChartProps\n) {\n const { colors, patterns } = useSeedsChartSetup({\n series: props.series,\n includePatterns: true,\n });\n const { options, annotationLookup, tooltipTimezone } = useMemo(\n () => buildLineAreaChartOptions(props),\n [props]\n );\n const hasOnClick = Boolean(props.onClick);\n\n return (\n <LineAreaChartContainer\n $colors={colors}\n $patterns={patterns}\n $hasOnClick={hasOnClick}\n $isArea={AREA_VARIANTS.has(props.variant)}\n className={props.className}\n >\n <ChartRenderer\n options={options}\n series={props.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 onReady={props.onReady}\n />\n </LineAreaChartContainer>\n );\n});\n","import { buildAnnotationConfig } from \"../shared/annotations\";\nimport type { ChartAnnotationLookup } from \"../shared/annotations\";\nimport type {\n SeedsChartDataPoint,\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 { ChartDataPoint } from \"../shared/axis\";\nimport type { LineAreaChartProps, LineAreaVariant } from \"./types\";\n\n// `stacking` is meaningful only for filled variants; on `line`/`spline` it's a\n// no-op, so the adapter drops it rather than emitting a misleading option.\nconst AREA_VARIANTS = new Set<LineAreaVariant>([\"area\", \"areaspline\"]);\n\ntype SeriesPoint =\n | number\n | null\n | [number, number | null]\n | SeedsChartDataPoint;\n\nfunction pointY(point: ChartDataPoint): number | null {\n if (point === null) return null;\n if (typeof point === \"number\") return point;\n if (Array.isArray(point)) return point[1];\n return point.y;\n}\n\n// Mirrors v1's marker handling: point markers are hidden by default (set on\n// `plotOptions.series`), but an *isolated* non-null point — one with a null (or\n// the chart edge) on both sides — gets a circle marker so a point with no\n// connecting line segment stays visible. Connected points pass through\n// unchanged so the line/area renders dot-free, matching v1 and the designs.\nfunction withIsolatedPointMarkers(\n data: ReadonlyArray<ChartDataPoint>\n): SeriesPoint[] {\n return data.map((point, i): SeriesPoint => {\n if (point === null) return null; // explicit gap\n if (pointY(point) === null) return point; // tuple/object with null y — a gap\n const prevY = i === 0 ? null : pointY(data[i - 1]!);\n const nextY = i === data.length - 1 ? null : pointY(data[i + 1]!);\n if (prevY !== null || nextY !== null) return point; // connected → no marker\n const marker = { enabled: true, symbol: \"circle\" as const };\n if (typeof point === \"number\") return { y: point, marker };\n if (Array.isArray(point)) return { x: point[0], y: point[1], marker };\n return { ...point, marker };\n });\n}\n\nexport function buildLineAreaChartOptions(props: LineAreaChartProps): {\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 tooltipTimezone = resolveTooltipTimezone(props.xAxis, props.timezone);\n const isStacked = AREA_VARIANTS.has(props.variant) && Boolean(props.stacking);\n const { annotations, lookup: annotationLookup } = buildAnnotationConfig(\n props.annotations\n );\n\n const options: SeedsChartOptions = {\n ...buildBaseChartOptions({\n type: props.variant,\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 // Anchor the value axis to 0 (like v1/bar/area): line/spline otherwise\n // auto-scale above 0, which truncates the axis and pushes the annotation\n // anchor (y: 0) out of range. `soft` still extends for negative data.\n softMin: 0,\n softMax: 0,\n gridLineWidth: props.yAxis?.showGridLines === false ? 0 : 1,\n title: { text: props.yAxis?.title ?? \"\" },\n // Zero-config default: abbreviate value-axis ticks (1.20K / 1.20M / 1.20B).\n labels: {\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: {\n animation: false,\n // Hide point markers by default (matching v1 + designs); isolated points\n // re-enable their own marker via `withIsolatedPointMarkers`.\n marker: { enabled: false },\n ...(props.onClick\n ? {\n point: {\n events: {\n click: (event) => props.onClick!({ position: event.point.x }),\n },\n },\n }\n : {}),\n },\n // Type-scoped stacking: only the (area) variant stacks. `isStacked` already\n // guarantees `props.variant` is an area variant here, so the computed key is\n // always a valid plotOptions slot. Matches bar's per-type placement and keeps\n // line/spline unstacked.\n ...(isStacked ? { [props.variant]: { stacking: props.stacking } } : {}),\n },\n series: props.series.map((s) => ({\n type: props.variant,\n name: s.name,\n data: withIsolatedPointMarkers(s.data),\n })),\n ...(annotations ? { annotations } : {}),\n };\n\n return { options, annotationLookup, tooltipTimezone };\n}\n","import styled from \"styled-components\";\nimport { lineChartStyles, areaChartStyles } from \"../../styles/chartStyles\";\nimport type {\n TypeChartStyleColor,\n TypeChartStyleHasOnClick,\n TypeChartStylePattern,\n} from \"../../types\";\n\ntype StyleProps = Readonly<{\n $colors: ReadonlyArray<TypeChartStyleColor>;\n $patterns: ReadonlyArray<TypeChartStylePattern>;\n $hasOnClick: TypeChartStyleHasOnClick;\n /** `area`/`areaspline` fill below the line; `line`/`spline` show only the stroke. */\n $isArea: boolean;\n}>;\n\n// Plain styled `div` — not `Box`. Per the DS Tailwind direction, components\n// render semantic elements internally (and accept `className`) rather than\n// depending on the `Box` component. The container background — previously Box's\n// `bg` prop — is set explicitly here.\n//\n// The line/area CSS is still v1's styled-components layer (`chartStyles.ts`);\n// migrating those styles to CSS modules is a tracked clean-up follow-up.\nexport const LineAreaChartContainer = styled.div<StyleProps>`\n background-color: ${({ theme }) => theme.colors.container.background.base};\n ${(props) => (props.$isArea ? areaChartStyles : lineChartStyles)}\n`;\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/line-area/index.js","../../src/charts/line-area/LineAreaChart.tsx","../../src/charts/line-area/adapter.ts","../../src/charts/line-area/styles.ts"],"names":["AREA_VARIANTS","LineAreaChart"],"mappings":"AAAA;AACE;AACA;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACF,uDAA6B;AAC7B;AACA;ACnBA,8BAA8B;ADqB9B;AACA;AEFA,IAAM,cAAA,kBAAgB,IAAI,GAAA,CAAqB,CAAC,MAAA,EAAQ,YAAY,CAAC,CAAA;AAQrE,SAAS,MAAA,CAAO,KAAA,EAAsC;AACpD,EAAA,GAAA,CAAI,MAAA,IAAU,IAAA,EAAM,OAAO,IAAA;AAC3B,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,GAAA,CAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAO,KAAA,CAAM,CAAC,CAAA;AACxC,EAAA,OAAO,KAAA,CAAM,CAAA;AACf;AAOA,SAAS,wB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AAA,EAAS,KAAA,CAAM;AAAA,QAAA;AAAA,MACjB;AAAA,IAAA;AAAA,EACF,CAAA;AAEJ,CAAC,CAAA;AD4GD;AACE;AACF,sCAAC","file":"/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/line-area/index.js","sourcesContent":[null,"import { memo, useMemo } from \"react\";\nimport { useSeedsChartSetup, ChartRenderer } from \"../shared/chartBase\";\nimport { buildLineAreaChartOptions } from \"./adapter\";\nimport { LineAreaChartContainer } from \"./styles\";\nimport type { LineAreaChartProps, LineAreaVariant } from \"./types\";\n\nconst AREA_VARIANTS = new Set<LineAreaVariant>([\"area\", \"areaspline\"]);\n\nexport const LineAreaChart = memo(function LineAreaChart(\n props: LineAreaChartProps\n) {\n const { colors, patterns } = useSeedsChartSetup({\n series: props.series,\n includePatterns: true,\n });\n const { options, annotationLookup, tooltipTimezone } = useMemo(\n () => buildLineAreaChartOptions(props),\n [props]\n );\n const hasOnClick = Boolean(props.onClick);\n\n return (\n <LineAreaChartContainer\n $colors={colors}\n $patterns={patterns}\n $hasOnClick={hasOnClick}\n $isArea={AREA_VARIANTS.has(props.variant)}\n className={props.className}\n >\n <ChartRenderer\n options={options}\n series={props.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 </LineAreaChartContainer>\n );\n});\n","import { buildAnnotationConfig } from \"../shared/annotations\";\nimport type { ChartAnnotationLookup } from \"../shared/annotations\";\nimport type {\n SeedsChartDataPoint,\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 { ChartDataPoint } from \"../shared/axis\";\nimport type { LineAreaChartProps, LineAreaVariant } from \"./types\";\n\n// `stacking` is meaningful only for filled variants; on `line`/`spline` it's a\n// no-op, so the adapter drops it rather than emitting a misleading option.\nconst AREA_VARIANTS = new Set<LineAreaVariant>([\"area\", \"areaspline\"]);\n\ntype SeriesPoint =\n | number\n | null\n | [number, number | null]\n | SeedsChartDataPoint;\n\nfunction pointY(point: ChartDataPoint): number | null {\n if (point === null) return null;\n if (typeof point === \"number\") return point;\n if (Array.isArray(point)) return point[1];\n return point.y;\n}\n\n// Mirrors v1's marker handling: point markers are hidden by default (set on\n// `plotOptions.series`), but an *isolated* non-null point — one with a null (or\n// the chart edge) on both sides — gets a circle marker so a point with no\n// connecting line segment stays visible. Connected points pass through\n// unchanged so the line/area renders dot-free, matching v1 and the designs.\nfunction withIsolatedPointMarkers(\n data: ReadonlyArray<ChartDataPoint>\n): SeriesPoint[] {\n return data.map((point, i): SeriesPoint => {\n if (point === null) return null; // explicit gap\n if (pointY(point) === null) return point; // tuple/object with null y — a gap\n const prevY = i === 0 ? null : pointY(data[i - 1]!);\n const nextY = i === data.length - 1 ? null : pointY(data[i + 1]!);\n if (prevY !== null || nextY !== null) return point; // connected → no marker\n const marker = { enabled: true, symbol: \"circle\" as const };\n if (typeof point === \"number\") return { y: point, marker };\n if (Array.isArray(point)) return { x: point[0], y: point[1], marker };\n return { ...point, marker };\n });\n}\n\nexport function buildLineAreaChartOptions(props: LineAreaChartProps): {\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 tooltipTimezone = resolveTooltipTimezone(props.xAxis, props.timezone);\n const isStacked = AREA_VARIANTS.has(props.variant) && Boolean(props.stacking);\n const { annotations, lookup: annotationLookup } = buildAnnotationConfig(\n props.annotations\n );\n\n const options: SeedsChartOptions = {\n ...buildBaseChartOptions({\n type: props.variant,\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 // Anchor the value axis to 0 (like v1/bar/area): line/spline otherwise\n // auto-scale above 0, which truncates the axis and pushes the annotation\n // anchor (y: 0) out of range. `soft` still extends for negative data.\n softMin: 0,\n softMax: 0,\n gridLineWidth: props.yAxis?.showGridLines === false ? 0 : 1,\n title: { text: props.yAxis?.title ?? \"\" },\n // Zero-config default: abbreviate value-axis ticks (1.20K / 1.20M / 1.20B).\n labels: {\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: {\n animation: false,\n // Hide point markers by default (matching v1 + designs); isolated points\n // re-enable their own marker via `withIsolatedPointMarkers`.\n marker: { enabled: false },\n ...(props.onClick\n ? {\n point: {\n events: {\n click: (event) => props.onClick!({ position: event.point.x }),\n },\n },\n }\n : {}),\n },\n // Type-scoped stacking: only the (area) variant stacks. `isStacked` already\n // guarantees `props.variant` is an area variant here, so the computed key is\n // always a valid plotOptions slot. Matches bar's per-type placement and keeps\n // line/spline unstacked.\n ...(isStacked ? { [props.variant]: { stacking: props.stacking } } : {}),\n },\n series: props.series.map((s) => ({\n type: props.variant,\n name: s.name,\n data: withIsolatedPointMarkers(s.data),\n })),\n ...(annotations ? { annotations } : {}),\n };\n\n return { options, annotationLookup, tooltipTimezone };\n}\n","import styled from \"styled-components\";\nimport { lineChartStyles, areaChartStyles } from \"../../styles/chartStyles\";\nimport type {\n TypeChartStyleColor,\n TypeChartStyleHasOnClick,\n TypeChartStylePattern,\n} from \"../../types\";\n\ntype StyleProps = Readonly<{\n $colors: ReadonlyArray<TypeChartStyleColor>;\n $patterns: ReadonlyArray<TypeChartStylePattern>;\n $hasOnClick: TypeChartStyleHasOnClick;\n /** `area`/`areaspline` fill below the line; `line`/`spline` show only the stroke. */\n $isArea: boolean;\n}>;\n\n// Plain styled `div` — not `Box`. Per the DS Tailwind direction, components\n// render semantic elements internally (and accept `className`) rather than\n// depending on the `Box` component. The container background — previously Box's\n// `bg` prop — is set explicitly here.\n//\n// The line/area CSS is still v1's styled-components layer (`chartStyles.ts`);\n// migrating those styles to CSS modules is a tracked clean-up follow-up.\nexport const LineAreaChartContainer = styled.div<StyleProps>`\n background-color: ${({ theme }) => theme.colors.container.background.base};\n ${(props) => (props.$isArea ? areaChartStyles : lineChartStyles)}\n`;\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { C as ChartTooltipProps } from '../chartBase-Cn_5CUJi.mjs';
|
|
4
|
+
import { C as ChartExportHandle } from '../chartExport-CKYpuhik.mjs';
|
|
5
|
+
import { C as ChartDataPoint, c as DimensionalAxis } from '../axis-WOeYkTO1.mjs';
|
|
6
|
+
export { a as CategoryAxis, D as DatetimeAxis } from '../axis-WOeYkTO1.mjs';
|
|
7
|
+
import '@sproutsocial/seeds-react-icon';
|
|
8
|
+
import '../types-DxrhdAdn.mjs';
|
|
9
|
+
import 'highcharts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Trend direction derived from a series (first vs. last finite value): rising →
|
|
13
|
+
* `"positive"`, falling → `"negative"`, flat → `"neutral"`.
|
|
14
|
+
*/
|
|
15
|
+
type Trend = "positive" | "negative" | "neutral";
|
|
16
|
+
|
|
17
|
+
/** A single sparkline value, or a `[timestamp, value]` / `{ x, y }` point on a datetime axis. */
|
|
18
|
+
type SparklineDataPoint = ChartDataPoint;
|
|
19
|
+
/** Visual encoding of the sparkline. `"line"` draws a stroke; `"bar"` draws columns. */
|
|
20
|
+
type SparklineVariant = "line" | "bar";
|
|
21
|
+
/**
|
|
22
|
+
* Trend direction, derived from the data (first vs. last finite value). Drives
|
|
23
|
+
* the single color the whole sparkline renders in.
|
|
24
|
+
*/
|
|
25
|
+
type SparklineTrend = Trend;
|
|
26
|
+
type SparklineXAxis = DimensionalAxis;
|
|
27
|
+
interface SparklineChartProps {
|
|
28
|
+
/** Wired into Highcharts' `accessibility.description`. */
|
|
29
|
+
description: string;
|
|
30
|
+
/** `"line"` (stroke) or `"bar"` (columns). */
|
|
31
|
+
variant: SparklineVariant;
|
|
32
|
+
/**
|
|
33
|
+
* The single data series. Bare numbers render on an index/category axis;
|
|
34
|
+
* `[timestamp, value]` tuples (or `{ x, y }`) render on a datetime axis when
|
|
35
|
+
* `xAxis.type` is `"datetime"`.
|
|
36
|
+
*/
|
|
37
|
+
data: Array<SparklineDataPoint>;
|
|
38
|
+
/**
|
|
39
|
+
* Tailwind utilities (or any class names) applied to the wrapper — the intended
|
|
40
|
+
* way to size the sparkline (e.g. `"h-6 w-32"`). Defaults come from `sparkline.css`.
|
|
41
|
+
*/
|
|
42
|
+
className?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Optional axis config. Omit for the default hidden index axis; pass a
|
|
45
|
+
* datetime axis to place `[timestamp, value]` points in time.
|
|
46
|
+
*/
|
|
47
|
+
xAxis?: SparklineXAxis;
|
|
48
|
+
/** IANA timezone for datetime-axis tooltips. Default `"UTC"`. Ignored for category axes. */
|
|
49
|
+
timezone?: string;
|
|
50
|
+
/** Appended to each tooltip value (e.g. `"%"`, `" MT"`). */
|
|
51
|
+
valueSuffix?: string;
|
|
52
|
+
/** Override for the default hover tooltip content. */
|
|
53
|
+
tooltip?: (args: ChartTooltipProps) => ReactNode;
|
|
54
|
+
/** Override for the value shown when a data point is null. Defaults to an em-dash. */
|
|
55
|
+
invalidNumberLabel?: ReactNode;
|
|
56
|
+
/** Fired once per chart instance with a handle for PNG/SVG/PDF/CSV downloads. Re-fires only on remount. */
|
|
57
|
+
onReady?: (handle: ChartExportHandle) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* SparklineChart — a compact, axis-less inline micro-chart in a `"line"` or
|
|
62
|
+
* `"bar"` variant. The whole sparkline is colored by trend (auto-computed from
|
|
63
|
+
* the data): green when rising, red when falling, neutral-gray when flat.
|
|
64
|
+
*
|
|
65
|
+
* Unlike the other v2 chart families this one carries no `styled-components`:
|
|
66
|
+
* the wrapper is a plain `<div>` that accepts `className` (Tailwind sizing), and
|
|
67
|
+
* the Highcharts styling lives in `sparkline.css`. Consumers must import
|
|
68
|
+
* `@sproutsocial/seeds-react-data-viz/sparkline.css` once. The single trend
|
|
69
|
+
* color is resolved from the JS theme and passed down as the
|
|
70
|
+
* `--seeds-sparkline-color` CSS variable, so light/dark works without depending
|
|
71
|
+
* on the theme's CSS-variable stylesheet.
|
|
72
|
+
*/
|
|
73
|
+
declare const SparklineChart: react.NamedExoticComponent<SparklineChartProps>;
|
|
74
|
+
|
|
75
|
+
export { ChartExportHandle, SparklineChart, type SparklineChartProps, type SparklineDataPoint, type SparklineTrend, type SparklineVariant, type SparklineXAxis };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { C as ChartTooltipProps } from '../chartBase-C-l7yYGx.js';
|
|
4
|
+
import { C as ChartExportHandle } from '../chartExport-CKYpuhik.js';
|
|
5
|
+
import { C as ChartDataPoint, c as DimensionalAxis } from '../axis-WOeYkTO1.js';
|
|
6
|
+
export { a as CategoryAxis, D as DatetimeAxis } from '../axis-WOeYkTO1.js';
|
|
7
|
+
import '@sproutsocial/seeds-react-icon';
|
|
8
|
+
import '../types-DxrhdAdn.js';
|
|
9
|
+
import 'highcharts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Trend direction derived from a series (first vs. last finite value): rising →
|
|
13
|
+
* `"positive"`, falling → `"negative"`, flat → `"neutral"`.
|
|
14
|
+
*/
|
|
15
|
+
type Trend = "positive" | "negative" | "neutral";
|
|
16
|
+
|
|
17
|
+
/** A single sparkline value, or a `[timestamp, value]` / `{ x, y }` point on a datetime axis. */
|
|
18
|
+
type SparklineDataPoint = ChartDataPoint;
|
|
19
|
+
/** Visual encoding of the sparkline. `"line"` draws a stroke; `"bar"` draws columns. */
|
|
20
|
+
type SparklineVariant = "line" | "bar";
|
|
21
|
+
/**
|
|
22
|
+
* Trend direction, derived from the data (first vs. last finite value). Drives
|
|
23
|
+
* the single color the whole sparkline renders in.
|
|
24
|
+
*/
|
|
25
|
+
type SparklineTrend = Trend;
|
|
26
|
+
type SparklineXAxis = DimensionalAxis;
|
|
27
|
+
interface SparklineChartProps {
|
|
28
|
+
/** Wired into Highcharts' `accessibility.description`. */
|
|
29
|
+
description: string;
|
|
30
|
+
/** `"line"` (stroke) or `"bar"` (columns). */
|
|
31
|
+
variant: SparklineVariant;
|
|
32
|
+
/**
|
|
33
|
+
* The single data series. Bare numbers render on an index/category axis;
|
|
34
|
+
* `[timestamp, value]` tuples (or `{ x, y }`) render on a datetime axis when
|
|
35
|
+
* `xAxis.type` is `"datetime"`.
|
|
36
|
+
*/
|
|
37
|
+
data: Array<SparklineDataPoint>;
|
|
38
|
+
/**
|
|
39
|
+
* Tailwind utilities (or any class names) applied to the wrapper — the intended
|
|
40
|
+
* way to size the sparkline (e.g. `"h-6 w-32"`). Defaults come from `sparkline.css`.
|
|
41
|
+
*/
|
|
42
|
+
className?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Optional axis config. Omit for the default hidden index axis; pass a
|
|
45
|
+
* datetime axis to place `[timestamp, value]` points in time.
|
|
46
|
+
*/
|
|
47
|
+
xAxis?: SparklineXAxis;
|
|
48
|
+
/** IANA timezone for datetime-axis tooltips. Default `"UTC"`. Ignored for category axes. */
|
|
49
|
+
timezone?: string;
|
|
50
|
+
/** Appended to each tooltip value (e.g. `"%"`, `" MT"`). */
|
|
51
|
+
valueSuffix?: string;
|
|
52
|
+
/** Override for the default hover tooltip content. */
|
|
53
|
+
tooltip?: (args: ChartTooltipProps) => ReactNode;
|
|
54
|
+
/** Override for the value shown when a data point is null. Defaults to an em-dash. */
|
|
55
|
+
invalidNumberLabel?: ReactNode;
|
|
56
|
+
/** Fired once per chart instance with a handle for PNG/SVG/PDF/CSV downloads. Re-fires only on remount. */
|
|
57
|
+
onReady?: (handle: ChartExportHandle) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* SparklineChart — a compact, axis-less inline micro-chart in a `"line"` or
|
|
62
|
+
* `"bar"` variant. The whole sparkline is colored by trend (auto-computed from
|
|
63
|
+
* the data): green when rising, red when falling, neutral-gray when flat.
|
|
64
|
+
*
|
|
65
|
+
* Unlike the other v2 chart families this one carries no `styled-components`:
|
|
66
|
+
* the wrapper is a plain `<div>` that accepts `className` (Tailwind sizing), and
|
|
67
|
+
* the Highcharts styling lives in `sparkline.css`. Consumers must import
|
|
68
|
+
* `@sproutsocial/seeds-react-data-viz/sparkline.css` once. The single trend
|
|
69
|
+
* color is resolved from the JS theme and passed down as the
|
|
70
|
+
* `--seeds-sparkline-color` CSS variable, so light/dark works without depending
|
|
71
|
+
* on the theme's CSS-variable stylesheet.
|
|
72
|
+
*/
|
|
73
|
+
declare const SparklineChart: react.NamedExoticComponent<SparklineChartProps>;
|
|
74
|
+
|
|
75
|
+
export { ChartExportHandle, SparklineChart, type SparklineChartProps, type SparklineDataPoint, type SparklineTrend, type SparklineVariant, type SparklineXAxis };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunk6D7P3IOTjs = require('../chunk-6D7P3IOT.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunk2K7PFHIMjs = require('../chunk-2K7PFHIM.js');
|
|
9
|
+
require('../chunk-WEKDYQ4T.js');
|
|
10
|
+
|
|
11
|
+
// src/charts/sparkline/SparklineChart.tsx
|
|
12
|
+
var _react = require('react');
|
|
13
|
+
var _styledcomponents = require('styled-components');
|
|
14
|
+
|
|
15
|
+
// src/charts/sparkline/adapter.ts
|
|
16
|
+
function highchartsType(variant) {
|
|
17
|
+
return variant === "bar" ? "column" : "line";
|
|
18
|
+
}
|
|
19
|
+
var SPARKLINE_SERIES_NAME = "sparkline";
|
|
20
|
+
function buildSparklineChartOptions(props) {
|
|
21
|
+
const type = highchartsType(props.variant);
|
|
22
|
+
const tooltipTimezone = props.xAxis ? _chunk6D7P3IOTjs.resolveTooltipTimezone.call(void 0, props.xAxis, props.timezone) : void 0;
|
|
23
|
+
const xAxis = props.xAxis ? {
|
|
24
|
+
..._chunk6D7P3IOTjs.buildDimensionalAxis.call(void 0, props.xAxis, _nullishCoalesce(tooltipTimezone, () => ( "UTC"))),
|
|
25
|
+
visible: false
|
|
26
|
+
} : { type: "linear", visible: false };
|
|
27
|
+
const base = _chunk2K7PFHIMjs.buildBaseChartOptions.call(void 0, {
|
|
28
|
+
type,
|
|
29
|
+
description: props.description,
|
|
30
|
+
valueSuffix: props.valueSuffix,
|
|
31
|
+
timezone: tooltipTimezone
|
|
32
|
+
});
|
|
33
|
+
const options = {
|
|
34
|
+
...base,
|
|
35
|
+
// Zero the outer spacing so the plot fills the (consumer-sized) wrapper.
|
|
36
|
+
chart: { type, styledMode: true, animation: false, spacing: [0, 0, 0, 0] },
|
|
37
|
+
xAxis,
|
|
38
|
+
yAxis: { visible: false },
|
|
39
|
+
plotOptions: {
|
|
40
|
+
series: {
|
|
41
|
+
animation: false,
|
|
42
|
+
// Decorative micro-chart: no per-point markers on the line.
|
|
43
|
+
marker: { enabled: false }
|
|
44
|
+
},
|
|
45
|
+
// Tight padding so bars read as a compact cluster.
|
|
46
|
+
column: {
|
|
47
|
+
pointPadding: 0.05,
|
|
48
|
+
groupPadding: 0.05,
|
|
49
|
+
borderWidth: 0,
|
|
50
|
+
borderRadius: 3
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
series: [
|
|
54
|
+
{
|
|
55
|
+
type,
|
|
56
|
+
name: SPARKLINE_SERIES_NAME,
|
|
57
|
+
data: [...props.data]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
return { options, tooltipTimezone };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/charts/shared/trend.ts
|
|
65
|
+
function yValue(point) {
|
|
66
|
+
if (point == null) return null;
|
|
67
|
+
if (typeof point === "number") return point;
|
|
68
|
+
if (Array.isArray(point)) return point[1];
|
|
69
|
+
return point.y;
|
|
70
|
+
}
|
|
71
|
+
function computeTrend(data) {
|
|
72
|
+
const finite = data.map(yValue).filter((v) => v != null && Number.isFinite(v));
|
|
73
|
+
if (finite.length < 2) return "neutral";
|
|
74
|
+
const first = finite[0];
|
|
75
|
+
const last = finite[finite.length - 1];
|
|
76
|
+
if (last > first) return "positive";
|
|
77
|
+
if (last < first) return "negative";
|
|
78
|
+
return "neutral";
|
|
79
|
+
}
|
|
80
|
+
function resolveTrendColor(theme, trend) {
|
|
81
|
+
const decorative = theme.colors.container.border.decorative;
|
|
82
|
+
if (trend === "positive") return decorative.green;
|
|
83
|
+
if (trend === "negative") return decorative.red;
|
|
84
|
+
return decorative.neutral;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/charts/sparkline/SparklineChart.tsx
|
|
88
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
89
|
+
var SparklineChart = _react.memo.call(void 0, function SparklineChart2(props) {
|
|
90
|
+
const theme = _styledcomponents.useTheme.call(void 0, );
|
|
91
|
+
const trend = computeTrend(props.data);
|
|
92
|
+
const trendColor = resolveTrendColor(theme, trend);
|
|
93
|
+
const { options, tooltipTimezone } = buildSparklineChartOptions(props);
|
|
94
|
+
const className = [
|
|
95
|
+
"seeds-sparkline",
|
|
96
|
+
`seeds-sparkline-${props.variant}`,
|
|
97
|
+
props.className
|
|
98
|
+
].filter(Boolean).join(" ");
|
|
99
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
className,
|
|
103
|
+
style: { "--seeds-sparkline-color": trendColor },
|
|
104
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
105
|
+
_chunk2K7PFHIMjs.ChartRenderer,
|
|
106
|
+
{
|
|
107
|
+
options,
|
|
108
|
+
series: [{ name: SPARKLINE_SERIES_NAME, color: trendColor }],
|
|
109
|
+
colors: [trendColor],
|
|
110
|
+
tooltip: props.tooltip,
|
|
111
|
+
timezone: tooltipTimezone,
|
|
112
|
+
invalidNumberLabel: props.invalidNumberLabel,
|
|
113
|
+
hideLegend: true,
|
|
114
|
+
onReady: props.onReady
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
exports.SparklineChart = SparklineChart;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/sparkline/index.js","../../src/charts/sparkline/SparklineChart.tsx","../../src/charts/sparkline/adapter.ts","../../src/charts/shared/trend.ts"],"names":["SparklineChart"],"mappings":"AAAA;AACE;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACVA,8BAAyC;AACzC,qDAAyB;ADYzB;AACA;AELA,SAAS,cAAA,CAAe,OAAA,EAA2C;AACjE,EAAA,OAAO,QAAA,IAAY,MAAA,EAAQ,SAAA,EAAW,MAAA;AACxC;AAEA,IAAM,sBAAA,EAAwB,WAAA;AAEvB,SAAS,0BAAA,CAA2B,KAAA,EAI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SAAA,CAAU,MAAA,CAAO,UAAA;AACjD,EAAA,GAAA,CAAI,MAAA,IAAU,UAAA,EAAY,OAAO,UAAA,CAAW,KAAA;AAC5C,EAAA,GAAA,CAAI,MAAA,IAAU,UAAA,EAAY,OAAO,UAAA,CAAW,GAAA;AAC5C,EAAA,OAAO,UAAA,CAAW,OAAA;AACpB;AHgCA;AACA;ACpCM,+CAAA;AA7BC,IAAM,eAAA,EAAiB,yBAAA,SAAcA,eAAAA,CAC1C,KAAA,EACA;AAOA,EAAA,MAAM,MAAA,EAAQ,wCAAA,CAAS;AAEvB,EAAA,MAAM,MAAA,EAAQ,YAAA,CAAa,KAAA,CAAM,IAAI,CAAA;AACrC,EAAA,MAAM,WAAA,EAAa,iBAAA,CAAkB,KAAA,EAAO,KAAK,CAAA;AAEjD,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAgB,EAAA,EAAI,0BAAA,CAA2B,KAAK,CAAA;AAErE,EAAA,MAAM,UAAA,EAAY;AAAA,IAChB,iBAAA;AAAA,IACA,CAAA,gBAAA,EAAmB,KAAA,CAAM,OAAO,CAAA,CAAA;AAC1B,IAAA;AAGG,EAAA;AAGT,EAAA;AAAC,IAAA;AAAA,IAAA;AACC,MAAA;AACS,MAAA;AAET,MAAA;AAAC,QAAA;AAAA,QAAA;AACC,UAAA;AACiB,UAAA;AACE,UAAA;AACJ,UAAA;AACL,UAAA;AACgB,UAAA;AAChB,UAAA;AACK,UAAA;AAAA,QAAA;AACjB,MAAA;AAAA,IAAA;AACF,EAAA;AAEH;ADyDoC;AACA;AACA","file":"/home/runner/_work/seeds/seeds/seeds-react/seeds-react-data-viz/dist/sparkline/index.js","sourcesContent":[null,"import { memo, type CSSProperties } from \"react\";\nimport { useTheme } from \"styled-components\";\nimport type { TypeTheme } from \"@sproutsocial/seeds-react-theme\";\nimport { ChartRenderer } from \"../shared/chartBase\";\nimport { buildSparklineChartOptions, SPARKLINE_SERIES_NAME } from \"./adapter\";\nimport { computeTrend, resolveTrendColor } from \"./trend\";\nimport type { SparklineChartProps } from \"./types\";\n\n/**\n * SparklineChart — a compact, axis-less inline micro-chart in a `\"line\"` or\n * `\"bar\"` variant. The whole sparkline is colored by trend (auto-computed from\n * the data): green when rising, red when falling, neutral-gray when flat.\n *\n * Unlike the other v2 chart families this one carries no `styled-components`:\n * the wrapper is a plain `<div>` that accepts `className` (Tailwind sizing), and\n * the Highcharts styling lives in `sparkline.css`. Consumers must import\n * `@sproutsocial/seeds-react-data-viz/sparkline.css` once. The single trend\n * color is resolved from the JS theme and passed down as the\n * `--seeds-sparkline-color` CSS variable, so light/dark works without depending\n * on the theme's CSS-variable stylesheet.\n */\nexport const SparklineChart = memo(function SparklineChart(\n props: SparklineChartProps\n) {\n // The active theme resolves the single trend color. We read it directly rather\n // than via useSeedsChartSetup — the sparkline has no categorical palette or\n // series-limit concerns, so the hook's series machinery (and its dummy series\n // input) would be dead weight. ChartRenderer below is itself a styled-\n // component, so this adds no new dependency; the \"no styled-components\" trait\n // of this family is about the wrapper being a plain <div> + static CSS.\n const theme = useTheme() as TypeTheme;\n\n const trend = computeTrend(props.data);\n const trendColor = resolveTrendColor(theme, trend);\n\n const { options, tooltipTimezone } = buildSparklineChartOptions(props);\n\n const className = [\n \"seeds-sparkline\",\n `seeds-sparkline-${props.variant}`,\n props.className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div\n className={className}\n style={{ \"--seeds-sparkline-color\": trendColor } as CSSProperties}\n >\n <ChartRenderer\n options={options}\n series={[{ name: SPARKLINE_SERIES_NAME, color: trendColor }]}\n colors={[trendColor]}\n tooltip={props.tooltip}\n timezone={tooltipTimezone}\n invalidNumberLabel={props.invalidNumberLabel}\n hideLegend\n onReady={props.onReady}\n />\n </div>\n );\n});\n","import type { SeedsChartOptions, SeedsChartType } from \"../shared/chartBase\";\nimport { buildBaseChartOptions } from \"../shared/baseChartOptions\";\nimport {\n buildDimensionalAxis,\n resolveTooltipTimezone,\n} from \"../shared/axisOptions\";\nimport type { SparklineChartProps, SparklineVariant } from \"./types\";\n\n// A sparkline line is a `line`; a sparkline bar is a `column` (vertical bars).\nfunction highchartsType(variant: SparklineVariant): SeedsChartType {\n return variant === \"bar\" ? \"column\" : \"line\";\n}\n\nconst SPARKLINE_SERIES_NAME = \"sparkline\";\n\nexport function buildSparklineChartOptions(props: SparklineChartProps): {\n options: SeedsChartOptions;\n /** Resolved timezone for the tooltip date formatter; undefined without a datetime axis. */\n tooltipTimezone: string | undefined;\n} {\n const type = highchartsType(props.variant);\n const tooltipTimezone = props.xAxis\n ? resolveTooltipTimezone(props.xAxis, props.timezone)\n : undefined;\n\n // A configured axis is placed but hidden (labels/line/ticks off). Without one\n // we fall back to a hidden linear index axis.\n const xAxis = props.xAxis\n ? {\n ...buildDimensionalAxis(props.xAxis, tooltipTimezone ?? \"UTC\"),\n visible: false,\n }\n : { type: \"linear\" as const, visible: false };\n\n const base = buildBaseChartOptions({\n type,\n description: props.description,\n valueSuffix: props.valueSuffix,\n timezone: tooltipTimezone,\n });\n\n const options: SeedsChartOptions = {\n ...base,\n // Zero the outer spacing so the plot fills the (consumer-sized) wrapper.\n chart: { type, styledMode: true, animation: false, spacing: [0, 0, 0, 0] },\n xAxis,\n yAxis: { visible: false },\n plotOptions: {\n series: {\n animation: false,\n // Decorative micro-chart: no per-point markers on the line.\n marker: { enabled: false },\n },\n // Tight padding so bars read as a compact cluster.\n column: {\n pointPadding: 0.05,\n groupPadding: 0.05,\n borderWidth: 0,\n borderRadius: 3,\n },\n },\n series: [\n {\n type,\n name: SPARKLINE_SERIES_NAME,\n data: [...props.data],\n },\n ],\n };\n\n return { options, tooltipTimezone };\n}\n\nexport { SPARKLINE_SERIES_NAME };\n","import type { TypeTheme } from \"@sproutsocial/seeds-react-theme\";\nimport type { ChartDataPoint } from \"./axis\";\n\n// Family-agnostic trend helpers, shared across chart families. First used by the\n// sparkline (colored entirely by its trend direction); reusable by any chart\n// that wants a sentiment/directional color from a single series (e.g. a\n// sentiment chart).\n\n/**\n * Trend direction derived from a series (first vs. last finite value): rising →\n * `\"positive\"`, falling → `\"negative\"`, flat → `\"neutral\"`.\n */\nexport type Trend = \"positive\" | \"negative\" | \"neutral\";\n\n/** Extract the numeric y-value from a bare number, tuple, or `{ x, y }` point. */\nfunction yValue(point: ChartDataPoint): number | null {\n if (point == null) return null;\n if (typeof point === \"number\") return point;\n if (Array.isArray(point)) return point[1];\n return point.y;\n}\n\n/**\n * Derive the trend from the series by comparing the first finite value to the\n * last finite value: rising → `\"positive\"`, falling → `\"negative\"`, equal (or\n * fewer than two finite values) → `\"neutral\"`.\n */\nexport function computeTrend(data: ReadonlyArray<ChartDataPoint>): Trend {\n const finite = data\n .map(yValue)\n .filter((v): v is number => v != null && Number.isFinite(v));\n\n if (finite.length < 2) return \"neutral\";\n\n const first = finite[0]!;\n const last = finite[finite.length - 1]!;\n\n if (last > first) return \"positive\";\n if (last < first) return \"negative\";\n return \"neutral\";\n}\n\n/**\n * Resolve the trend to a Seeds decorative highlight/accent color: positive →\n * vibrant green (green-500), negative → vibrant red (red-600), neutral → middle\n * gray (neutral-600). These highlight tones are theme-stable — the same value in\n * light and dark — and are designed to read as accents on either surface.\n */\nexport function resolveTrendColor(theme: TypeTheme, trend: Trend): string {\n const decorative = theme.colors.container.border.decorative;\n if (trend === \"positive\") return decorative.green;\n if (trend === \"negative\") return decorative.red;\n return decorative.neutral;\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds SparklineChart styles.
|
|
3
|
+
*
|
|
4
|
+
* Unlike the other seeds-react-data-viz charts (which inject styles at runtime
|
|
5
|
+
* via styled-components), SparklineChart ships its styling as this plain CSS
|
|
6
|
+
* file. Consumers must import it once:
|
|
7
|
+
*
|
|
8
|
+
* import "@sproutsocial/seeds-react-data-viz/sparkline.css";
|
|
9
|
+
*
|
|
10
|
+
* The single trend color is provided by the component as the
|
|
11
|
+
* `--seeds-sparkline-color` custom property (set inline from the JS theme, so it
|
|
12
|
+
* follows light/dark without depending on the theme CSS-variable stylesheet).
|
|
13
|
+
* Size the chart by passing Tailwind utilities (or any class names) via
|
|
14
|
+
* `className` — the defaults below are overridable.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
.seeds-sparkline {
|
|
18
|
+
/* Compact inline micro-chart by default (matching the Highcharts sparkline
|
|
19
|
+
demo). Reach for the line/bar chart families when a full-size chart is
|
|
20
|
+
needed; override these with `className` for anything in between. */
|
|
21
|
+
display: inline-block;
|
|
22
|
+
width: 120px;
|
|
23
|
+
height: 24px;
|
|
24
|
+
vertical-align: middle;
|
|
25
|
+
/* Safety net: a chart that mis-measures its container never spills past the
|
|
26
|
+
sized wrapper. */
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* highcharts-react-official renders the chart into a bare <div> with no
|
|
31
|
+
intrinsic size, and Highcharts measures that element to size the chart. Left
|
|
32
|
+
at its default `height: auto` the measured height collapses to 0, so
|
|
33
|
+
Highcharts falls back to its built-in 400px default and overflows the
|
|
34
|
+
wrapper. Force the render container (and the chart's own inner container +
|
|
35
|
+
root svg) to fill the sized `.seeds-sparkline` wrapper so Highcharts measures
|
|
36
|
+
a concrete height instead. */
|
|
37
|
+
.seeds-sparkline > div,
|
|
38
|
+
.seeds-sparkline .highcharts-container,
|
|
39
|
+
.seeds-sparkline .highcharts-root {
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* A sparkline is a decorative overlay — no chart/plot background or border, so
|
|
45
|
+
it sits transparently on any surface. */
|
|
46
|
+
.seeds-sparkline .highcharts-background,
|
|
47
|
+
.seeds-sparkline .highcharts-plot-background {
|
|
48
|
+
fill: transparent;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.seeds-sparkline .highcharts-plot-border,
|
|
52
|
+
.seeds-sparkline .highcharts-plot-line {
|
|
53
|
+
stroke: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Highcharts renders in styledMode, so fills/strokes come from CSS. Everything
|
|
57
|
+
in a sparkline is the one trend color. Rounded joins/caps give the line a
|
|
58
|
+
slightly smoother, softer read. */
|
|
59
|
+
.seeds-sparkline .highcharts-graph {
|
|
60
|
+
stroke: var(--seeds-sparkline-color);
|
|
61
|
+
stroke-width: 2px;
|
|
62
|
+
stroke-linejoin: round;
|
|
63
|
+
stroke-linecap: round;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Bars/points carry no border — the fill alone is the trend color. */
|
|
67
|
+
.seeds-sparkline .highcharts-point {
|
|
68
|
+
fill: var(--seeds-sparkline-color);
|
|
69
|
+
stroke: none;
|
|
70
|
+
stroke-width: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Decorative micro-chart: no data-point markers on the line. */
|
|
74
|
+
.seeds-sparkline .highcharts-markers {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-data-viz",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Seeds React Data Viz Components",
|
|
5
5
|
"author": "Sprout Social, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,17 @@
|
|
|
23
23
|
"import": "./dist/esm/line-area/index.js",
|
|
24
24
|
"require": "./dist/line-area/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./donut": {
|
|
27
|
+
"types": "./dist/donut/index.d.ts",
|
|
28
|
+
"import": "./dist/esm/donut/index.js",
|
|
29
|
+
"require": "./dist/donut/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./sparkline": {
|
|
32
|
+
"types": "./dist/sparkline/index.d.ts",
|
|
33
|
+
"import": "./dist/esm/sparkline/index.js",
|
|
34
|
+
"require": "./dist/sparkline/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./sparkline.css": "./dist/sparkline.css",
|
|
26
37
|
"./export": {
|
|
27
38
|
"types": "./dist/export/index.d.ts",
|
|
28
39
|
"import": "./dist/esm/export/index.js",
|
|
@@ -33,7 +44,7 @@
|
|
|
33
44
|
"dist"
|
|
34
45
|
],
|
|
35
46
|
"scripts": {
|
|
36
|
-
"build": "tsup --dts",
|
|
47
|
+
"build": "tsup --dts && cp src/charts/sparkline/sparkline.css dist/sparkline.css",
|
|
37
48
|
"build:debug": "tsup --dts --metafile",
|
|
38
49
|
"dev": "tsup --watch --dts",
|
|
39
50
|
"clean": "rm -rf .turbo dist",
|