@optilogic/charts 1.3.11 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +353 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +355 -31
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/cartesian/area-chart.tsx +11 -0
- package/src/cartesian/bar-chart.tsx +109 -12
- package/src/cartesian/composed-chart.tsx +11 -0
- package/src/cartesian/line-chart.tsx +12 -2
- package/src/cartesian/scatter-chart.tsx +22 -0
- package/src/cartesian/waterfall-chart.tsx +11 -0
- package/src/dashboard/chart-builder.tsx +47 -5
- package/src/dashboard/chart-renderer.tsx +1 -1
- package/src/index.ts +5 -1
- package/src/radial/donut-chart.tsx +6 -0
- package/src/radial/pie-chart.tsx +6 -0
- package/src/radial/radar-chart.tsx +11 -0
- package/src/radial/radial-bar-chart.tsx +6 -0
- package/src/shared/chart-container.tsx +133 -6
- package/src/shared/formatters.ts +20 -0
- package/src/specialized/funnel-chart.tsx +6 -0
- package/src/specialized/gantt-chart.tsx +25 -0
- package/src/specialized/heatmap-chart.tsx +40 -5
- package/src/specialized/sankey-chart.tsx +17 -0
- package/src/specialized/treemap-chart.tsx +31 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { TooltipProps } from 'recharts';
|
|
4
|
+
import { ConditionalFormat } from '@optilogic/core';
|
|
4
5
|
|
|
5
6
|
/** Theme-aware chart colors from CSS variables */
|
|
6
7
|
declare const CHART_COLORS: readonly ["hsl(var(--chart-1))", "hsl(var(--chart-2))", "hsl(var(--chart-3))", "hsl(var(--chart-4))", "hsl(var(--chart-5))", "hsl(var(--chart-6))", "hsl(var(--chart-7))", "hsl(var(--chart-8))", "hsl(var(--chart-9))", "hsl(var(--chart-10))", "hsl(var(--chart-11))", "hsl(var(--chart-12))"];
|
|
@@ -84,6 +85,11 @@ interface ChartLegendContentProps {
|
|
|
84
85
|
declare const ChartLegendContent: React.NamedExoticComponent<ChartLegendContentProps>;
|
|
85
86
|
declare function resolveLegendConfig(legend: boolean | ChartLegend | undefined): ChartLegend | null;
|
|
86
87
|
|
|
88
|
+
/** Column descriptor for the screen-reader data-table fallback. */
|
|
89
|
+
interface ChartTableColumn {
|
|
90
|
+
key: string;
|
|
91
|
+
label: string;
|
|
92
|
+
}
|
|
87
93
|
interface ChartContainerProps {
|
|
88
94
|
children: React.ReactNode;
|
|
89
95
|
className?: string;
|
|
@@ -93,6 +99,34 @@ interface ChartContainerProps {
|
|
|
93
99
|
emptyMessage?: string;
|
|
94
100
|
title?: string;
|
|
95
101
|
description?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Accessible name for the visual chart region (SC 1.1.1). Falls back to
|
|
104
|
+
* `title` when omitted.
|
|
105
|
+
*/
|
|
106
|
+
ariaLabel?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Accessible description for the chart. Falls back to `description` when
|
|
109
|
+
* omitted. Exposed to assistive tech via `aria-describedby`.
|
|
110
|
+
*/
|
|
111
|
+
ariaDescription?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Row data rendered as a visually-hidden `<table>` so screen-reader users can
|
|
114
|
+
* access the underlying numbers (SC 1.1.1, 1.3.1). Requires `tableColumns`.
|
|
115
|
+
* Accepts any object row; cells are read by `tableColumns[].key`.
|
|
116
|
+
*/
|
|
117
|
+
tableData?: ReadonlyArray<object>;
|
|
118
|
+
/** Column definitions for the data-table fallback. Requires `tableData`. */
|
|
119
|
+
tableColumns?: Array<ChartTableColumn>;
|
|
120
|
+
/**
|
|
121
|
+
* Makes each data point actionable (a "visualization link"). When provided, a
|
|
122
|
+
* keyboard- and screen-reader-reachable list of buttons is rendered — one per
|
|
123
|
+
* `tableData` row — that is visually hidden until focused (skip-link pattern),
|
|
124
|
+
* so pointer users click the chart while keyboard users tab to the same
|
|
125
|
+
* actions without an invisible-focus trap (WCAG SC 2.1.1, 2.4.7).
|
|
126
|
+
*/
|
|
127
|
+
onRowActivate?: (row: object, index: number) => void;
|
|
128
|
+
/** Accessible label for a row's action. Defaults to the first column's value. */
|
|
129
|
+
rowActionLabel?: (row: object, index: number) => string;
|
|
96
130
|
}
|
|
97
131
|
declare const ChartContainer: React.ForwardRefExoticComponent<ChartContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
98
132
|
|
|
@@ -153,6 +187,14 @@ interface BarChartSeries {
|
|
|
153
187
|
color?: string;
|
|
154
188
|
stackId?: string;
|
|
155
189
|
radius?: number | [number, number, number, number];
|
|
190
|
+
/**
|
|
191
|
+
* Per-datum conditional formatting — a value-based color scale or ordered
|
|
192
|
+
* rules. The resolved `background` (or `color`) becomes each bar's fill, so
|
|
193
|
+
* bars follow the active theme. `className`-only formats do not apply to bars.
|
|
194
|
+
* Color is supplementary; the value stays available via the tooltip and the
|
|
195
|
+
* chart's accessible data table.
|
|
196
|
+
*/
|
|
197
|
+
conditionalFormat?: ConditionalFormat<Record<string, unknown>>;
|
|
156
198
|
}
|
|
157
199
|
interface BarChartProps extends BaseChartProps {
|
|
158
200
|
data: Record<string, unknown>[];
|
|
@@ -167,6 +209,12 @@ interface BarChartProps extends BaseChartProps {
|
|
|
167
209
|
barGap?: number;
|
|
168
210
|
barCategoryGap?: number | string;
|
|
169
211
|
loading?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* "Visualization link" — called when a data point is activated (a bar is
|
|
214
|
+
* clicked, or its keyboard/screen-reader link is triggered). Router-agnostic:
|
|
215
|
+
* navigate to a dashboard or open an external URL from your handler.
|
|
216
|
+
*/
|
|
217
|
+
onDataPointClick?: (datum: Record<string, unknown>, index: number) => void;
|
|
170
218
|
}
|
|
171
219
|
declare const BarChart: React.ForwardRefExoticComponent<BarChartProps & React.RefAttributes<HTMLDivElement>>;
|
|
172
220
|
|
|
@@ -534,4 +582,4 @@ interface ChartBuilderProps {
|
|
|
534
582
|
}
|
|
535
583
|
declare const ChartBuilder: React.NamedExoticComponent<ChartBuilderProps>;
|
|
536
584
|
|
|
537
|
-
export { AreaChart, type AreaChartProps, type AreaChartSeries, BarChart, type BarChartProps, type BarChartSeries, type BaseChartProps, CHART_COLORS, ChartBuilder, type ChartBuilderProps, type ChartConfig, type ChartConfigSeries, ChartContainer, type ChartContainerProps, type ChartGrid, type ChartLegend, ChartLegendContent, type ChartMargin, ChartRenderer, type ChartRendererProps, type ChartTooltipConfig, ChartTooltipContent, type ChartTooltipContentProps, type ChartTooltipProp, type ChartXAxis, type ChartYAxis, ComposedChart, type ComposedChartProps, type ComposedChartSeries, DonutChart, type DonutChartDatum, type DonutChartProps, FunnelChart, type FunnelChartProps, type FunnelDatum, GanttChart, type GanttChartProps, type GanttMilestone, type GanttTask, type GanttTimeScale, type HeatmapCell, HeatmapChart, type HeatmapChartProps, type HeatmapColorScale, KPICard, type KPICardProps, LineChart, type LineChartProps, type LineChartSeries, PieChart, type PieChartDatum, type PieChartProps, RadarChart, type RadarChartProps, type RadarChartSeries, RadialBarChart, type RadialBarChartProps, type RadialBarDatum, SankeyChart, type SankeyChartData, type SankeyChartProps, type SankeyLink, type SankeyNode, ScatterChart, type ScatterChartProps, type ScatterChartSeries, ScenarioComparison, type ScenarioComparisonMode, type ScenarioComparisonProps, type ScenarioData, type SemanticColorName, Sparkline, type SparklineProps, type SparklineVariant, type TooltipFormatter, TreemapChart, type TreemapChartProps, type TreemapDatum, type UseLiveDataConfig, type UseLiveDataReturn, WaterfallChart, type WaterfallChartProps, type WaterfallItem, formatCompact, formatCurrency, formatDuration, formatPercent, formatUnit, getChartColor, getSemanticColor, resolveLegendConfig, resolveTooltipProps, useLiveData };
|
|
585
|
+
export { AreaChart, type AreaChartProps, type AreaChartSeries, BarChart, type BarChartProps, type BarChartSeries, type BaseChartProps, CHART_COLORS, ChartBuilder, type ChartBuilderProps, type ChartConfig, type ChartConfigSeries, ChartContainer, type ChartContainerProps, type ChartGrid, type ChartLegend, ChartLegendContent, type ChartMargin, ChartRenderer, type ChartRendererProps, type ChartTableColumn, type ChartTooltipConfig, ChartTooltipContent, type ChartTooltipContentProps, type ChartTooltipProp, type ChartXAxis, type ChartYAxis, ComposedChart, type ComposedChartProps, type ComposedChartSeries, DonutChart, type DonutChartDatum, type DonutChartProps, FunnelChart, type FunnelChartProps, type FunnelDatum, GanttChart, type GanttChartProps, type GanttMilestone, type GanttTask, type GanttTimeScale, type HeatmapCell, HeatmapChart, type HeatmapChartProps, type HeatmapColorScale, KPICard, type KPICardProps, LineChart, type LineChartProps, type LineChartSeries, PieChart, type PieChartDatum, type PieChartProps, RadarChart, type RadarChartProps, type RadarChartSeries, RadialBarChart, type RadialBarChartProps, type RadialBarDatum, SankeyChart, type SankeyChartData, type SankeyChartProps, type SankeyLink, type SankeyNode, ScatterChart, type ScatterChartProps, type ScatterChartSeries, ScenarioComparison, type ScenarioComparisonMode, type ScenarioComparisonProps, type ScenarioData, type SemanticColorName, Sparkline, type SparklineProps, type SparklineVariant, type TooltipFormatter, TreemapChart, type TreemapChartProps, type TreemapDatum, type UseLiveDataConfig, type UseLiveDataReturn, WaterfallChart, type WaterfallChartProps, type WaterfallItem, formatCompact, formatCurrency, formatDuration, formatPercent, formatUnit, getChartColor, getSemanticColor, resolveLegendConfig, resolveTooltipProps, useLiveData };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { TooltipProps } from 'recharts';
|
|
4
|
+
import { ConditionalFormat } from '@optilogic/core';
|
|
4
5
|
|
|
5
6
|
/** Theme-aware chart colors from CSS variables */
|
|
6
7
|
declare const CHART_COLORS: readonly ["hsl(var(--chart-1))", "hsl(var(--chart-2))", "hsl(var(--chart-3))", "hsl(var(--chart-4))", "hsl(var(--chart-5))", "hsl(var(--chart-6))", "hsl(var(--chart-7))", "hsl(var(--chart-8))", "hsl(var(--chart-9))", "hsl(var(--chart-10))", "hsl(var(--chart-11))", "hsl(var(--chart-12))"];
|
|
@@ -84,6 +85,11 @@ interface ChartLegendContentProps {
|
|
|
84
85
|
declare const ChartLegendContent: React.NamedExoticComponent<ChartLegendContentProps>;
|
|
85
86
|
declare function resolveLegendConfig(legend: boolean | ChartLegend | undefined): ChartLegend | null;
|
|
86
87
|
|
|
88
|
+
/** Column descriptor for the screen-reader data-table fallback. */
|
|
89
|
+
interface ChartTableColumn {
|
|
90
|
+
key: string;
|
|
91
|
+
label: string;
|
|
92
|
+
}
|
|
87
93
|
interface ChartContainerProps {
|
|
88
94
|
children: React.ReactNode;
|
|
89
95
|
className?: string;
|
|
@@ -93,6 +99,34 @@ interface ChartContainerProps {
|
|
|
93
99
|
emptyMessage?: string;
|
|
94
100
|
title?: string;
|
|
95
101
|
description?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Accessible name for the visual chart region (SC 1.1.1). Falls back to
|
|
104
|
+
* `title` when omitted.
|
|
105
|
+
*/
|
|
106
|
+
ariaLabel?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Accessible description for the chart. Falls back to `description` when
|
|
109
|
+
* omitted. Exposed to assistive tech via `aria-describedby`.
|
|
110
|
+
*/
|
|
111
|
+
ariaDescription?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Row data rendered as a visually-hidden `<table>` so screen-reader users can
|
|
114
|
+
* access the underlying numbers (SC 1.1.1, 1.3.1). Requires `tableColumns`.
|
|
115
|
+
* Accepts any object row; cells are read by `tableColumns[].key`.
|
|
116
|
+
*/
|
|
117
|
+
tableData?: ReadonlyArray<object>;
|
|
118
|
+
/** Column definitions for the data-table fallback. Requires `tableData`. */
|
|
119
|
+
tableColumns?: Array<ChartTableColumn>;
|
|
120
|
+
/**
|
|
121
|
+
* Makes each data point actionable (a "visualization link"). When provided, a
|
|
122
|
+
* keyboard- and screen-reader-reachable list of buttons is rendered — one per
|
|
123
|
+
* `tableData` row — that is visually hidden until focused (skip-link pattern),
|
|
124
|
+
* so pointer users click the chart while keyboard users tab to the same
|
|
125
|
+
* actions without an invisible-focus trap (WCAG SC 2.1.1, 2.4.7).
|
|
126
|
+
*/
|
|
127
|
+
onRowActivate?: (row: object, index: number) => void;
|
|
128
|
+
/** Accessible label for a row's action. Defaults to the first column's value. */
|
|
129
|
+
rowActionLabel?: (row: object, index: number) => string;
|
|
96
130
|
}
|
|
97
131
|
declare const ChartContainer: React.ForwardRefExoticComponent<ChartContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
98
132
|
|
|
@@ -153,6 +187,14 @@ interface BarChartSeries {
|
|
|
153
187
|
color?: string;
|
|
154
188
|
stackId?: string;
|
|
155
189
|
radius?: number | [number, number, number, number];
|
|
190
|
+
/**
|
|
191
|
+
* Per-datum conditional formatting — a value-based color scale or ordered
|
|
192
|
+
* rules. The resolved `background` (or `color`) becomes each bar's fill, so
|
|
193
|
+
* bars follow the active theme. `className`-only formats do not apply to bars.
|
|
194
|
+
* Color is supplementary; the value stays available via the tooltip and the
|
|
195
|
+
* chart's accessible data table.
|
|
196
|
+
*/
|
|
197
|
+
conditionalFormat?: ConditionalFormat<Record<string, unknown>>;
|
|
156
198
|
}
|
|
157
199
|
interface BarChartProps extends BaseChartProps {
|
|
158
200
|
data: Record<string, unknown>[];
|
|
@@ -167,6 +209,12 @@ interface BarChartProps extends BaseChartProps {
|
|
|
167
209
|
barGap?: number;
|
|
168
210
|
barCategoryGap?: number | string;
|
|
169
211
|
loading?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* "Visualization link" — called when a data point is activated (a bar is
|
|
214
|
+
* clicked, or its keyboard/screen-reader link is triggered). Router-agnostic:
|
|
215
|
+
* navigate to a dashboard or open an external URL from your handler.
|
|
216
|
+
*/
|
|
217
|
+
onDataPointClick?: (datum: Record<string, unknown>, index: number) => void;
|
|
170
218
|
}
|
|
171
219
|
declare const BarChart: React.ForwardRefExoticComponent<BarChartProps & React.RefAttributes<HTMLDivElement>>;
|
|
172
220
|
|
|
@@ -534,4 +582,4 @@ interface ChartBuilderProps {
|
|
|
534
582
|
}
|
|
535
583
|
declare const ChartBuilder: React.NamedExoticComponent<ChartBuilderProps>;
|
|
536
584
|
|
|
537
|
-
export { AreaChart, type AreaChartProps, type AreaChartSeries, BarChart, type BarChartProps, type BarChartSeries, type BaseChartProps, CHART_COLORS, ChartBuilder, type ChartBuilderProps, type ChartConfig, type ChartConfigSeries, ChartContainer, type ChartContainerProps, type ChartGrid, type ChartLegend, ChartLegendContent, type ChartMargin, ChartRenderer, type ChartRendererProps, type ChartTooltipConfig, ChartTooltipContent, type ChartTooltipContentProps, type ChartTooltipProp, type ChartXAxis, type ChartYAxis, ComposedChart, type ComposedChartProps, type ComposedChartSeries, DonutChart, type DonutChartDatum, type DonutChartProps, FunnelChart, type FunnelChartProps, type FunnelDatum, GanttChart, type GanttChartProps, type GanttMilestone, type GanttTask, type GanttTimeScale, type HeatmapCell, HeatmapChart, type HeatmapChartProps, type HeatmapColorScale, KPICard, type KPICardProps, LineChart, type LineChartProps, type LineChartSeries, PieChart, type PieChartDatum, type PieChartProps, RadarChart, type RadarChartProps, type RadarChartSeries, RadialBarChart, type RadialBarChartProps, type RadialBarDatum, SankeyChart, type SankeyChartData, type SankeyChartProps, type SankeyLink, type SankeyNode, ScatterChart, type ScatterChartProps, type ScatterChartSeries, ScenarioComparison, type ScenarioComparisonMode, type ScenarioComparisonProps, type ScenarioData, type SemanticColorName, Sparkline, type SparklineProps, type SparklineVariant, type TooltipFormatter, TreemapChart, type TreemapChartProps, type TreemapDatum, type UseLiveDataConfig, type UseLiveDataReturn, WaterfallChart, type WaterfallChartProps, type WaterfallItem, formatCompact, formatCurrency, formatDuration, formatPercent, formatUnit, getChartColor, getSemanticColor, resolveLegendConfig, resolveTooltipProps, useLiveData };
|
|
585
|
+
export { AreaChart, type AreaChartProps, type AreaChartSeries, BarChart, type BarChartProps, type BarChartSeries, type BaseChartProps, CHART_COLORS, ChartBuilder, type ChartBuilderProps, type ChartConfig, type ChartConfigSeries, ChartContainer, type ChartContainerProps, type ChartGrid, type ChartLegend, ChartLegendContent, type ChartMargin, ChartRenderer, type ChartRendererProps, type ChartTableColumn, type ChartTooltipConfig, ChartTooltipContent, type ChartTooltipContentProps, type ChartTooltipProp, type ChartXAxis, type ChartYAxis, ComposedChart, type ComposedChartProps, type ComposedChartSeries, DonutChart, type DonutChartDatum, type DonutChartProps, FunnelChart, type FunnelChartProps, type FunnelDatum, GanttChart, type GanttChartProps, type GanttMilestone, type GanttTask, type GanttTimeScale, type HeatmapCell, HeatmapChart, type HeatmapChartProps, type HeatmapColorScale, KPICard, type KPICardProps, LineChart, type LineChartProps, type LineChartSeries, PieChart, type PieChartDatum, type PieChartProps, RadarChart, type RadarChartProps, type RadarChartSeries, RadialBarChart, type RadialBarChartProps, type RadialBarDatum, SankeyChart, type SankeyChartData, type SankeyChartProps, type SankeyLink, type SankeyNode, ScatterChart, type ScatterChartProps, type ScatterChartSeries, ScenarioComparison, type ScenarioComparisonMode, type ScenarioComparisonProps, type ScenarioData, type SemanticColorName, Sparkline, type SparklineProps, type SparklineVariant, type TooltipFormatter, TreemapChart, type TreemapChartProps, type TreemapDatum, type UseLiveDataConfig, type UseLiveDataReturn, WaterfallChart, type WaterfallChartProps, type WaterfallItem, formatCompact, formatCurrency, formatDuration, formatPercent, formatUnit, getChartColor, getSemanticColor, resolveLegendConfig, resolveTooltipProps, useLiveData };
|