@classic-homes/charts-core 0.6.0 → 0.7.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 +75 -0
- package/dist/index.d.cts +54 -6
- package/dist/index.d.ts +54 -6
- package/dist/index.js +68 -1
- package/dist/types/index.d.cts +16 -5
- package/dist/types/index.d.ts +16 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -866,6 +866,73 @@ function withGhostSeries(series, sources) {
|
|
|
866
866
|
});
|
|
867
867
|
}
|
|
868
868
|
|
|
869
|
+
// src/utils/selection.ts
|
|
870
|
+
var UNSELECTED_OPACITY = 0.3;
|
|
871
|
+
function selectionSet(selected) {
|
|
872
|
+
if (selected == null) return void 0;
|
|
873
|
+
const names = typeof selected === "string" ? [selected] : selected;
|
|
874
|
+
const set = new Set(names.filter((name) => name !== ""));
|
|
875
|
+
return set.size ? set : void 0;
|
|
876
|
+
}
|
|
877
|
+
var isPlainObject4 = (item) => typeof item === "object" && item !== null && !Array.isArray(item);
|
|
878
|
+
function withItem2(item, extra) {
|
|
879
|
+
if (isPlainObject4(item) && "value" in item) {
|
|
880
|
+
return {
|
|
881
|
+
...item,
|
|
882
|
+
...extra,
|
|
883
|
+
itemStyle: { ...item.itemStyle, ...extra.itemStyle }
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
return { value: item, ...extra };
|
|
887
|
+
}
|
|
888
|
+
function opacityOf(item, seriesOpacity) {
|
|
889
|
+
const opacity = isPlainObject4(item) ? item.itemStyle?.opacity : void 0;
|
|
890
|
+
return typeof opacity === "number" ? opacity : seriesOpacity;
|
|
891
|
+
}
|
|
892
|
+
function withSelectedBars(data, categories, selected, seriesOpacity = 1) {
|
|
893
|
+
const set = selectionSet(selected);
|
|
894
|
+
if (!set) return [...data];
|
|
895
|
+
return data.map(
|
|
896
|
+
(item, index) => set.has(String(categories[index])) ? item : withItem2(item, {
|
|
897
|
+
itemStyle: { opacity: opacityOf(item, seriesOpacity) * UNSELECTED_OPACITY }
|
|
898
|
+
})
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
function withSelectedPoints(data, categories, selected, options = {}) {
|
|
902
|
+
const set = selectionSet(selected);
|
|
903
|
+
if (!set) return [...data];
|
|
904
|
+
const size = Math.max(options.pointSize ?? 0, 6) + 4;
|
|
905
|
+
return data.map(
|
|
906
|
+
(item, index) => set.has(String(categories[index])) ? withItem2(item, {
|
|
907
|
+
symbol: "circle",
|
|
908
|
+
symbolSize: size,
|
|
909
|
+
itemStyle: {
|
|
910
|
+
borderWidth: 2,
|
|
911
|
+
...options.ringColor && { borderColor: options.ringColor }
|
|
912
|
+
}
|
|
913
|
+
}) : item
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
function selectionShowsSymbols(selected) {
|
|
917
|
+
return selectionSet(selected) !== void 0;
|
|
918
|
+
}
|
|
919
|
+
function withSelectedSlices(items, selected) {
|
|
920
|
+
const set = selectionSet(selected);
|
|
921
|
+
if (!set) return [...items];
|
|
922
|
+
return items.map(
|
|
923
|
+
(item) => set.has(item.name) ? item : { ...item, itemStyle: { ...item.itemStyle, opacity: UNSELECTED_OPACITY } }
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
function describeSelection(selected) {
|
|
927
|
+
const set = selectionSet(selected);
|
|
928
|
+
return set ? `Selected: ${[...set].join(", ")}` : void 0;
|
|
929
|
+
}
|
|
930
|
+
function withSelectionDescription(description, selected) {
|
|
931
|
+
const note = describeSelection(selected);
|
|
932
|
+
if (!note) return description;
|
|
933
|
+
return description ? `${description.replace(/\.?\s*$/, "")}. ${note}.` : `${note}.`;
|
|
934
|
+
}
|
|
935
|
+
|
|
869
936
|
// src/utils/stats.ts
|
|
870
937
|
var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
871
938
|
var clean = (value) => Number(value.toPrecision(12));
|
|
@@ -1820,6 +1887,7 @@ exports.GHOST_BAR_OPACITY = GHOST_BAR_OPACITY;
|
|
|
1820
1887
|
exports.GHOST_LINE_OPACITY = GHOST_LINE_OPACITY;
|
|
1821
1888
|
exports.THEME_DARK = THEME_DARK;
|
|
1822
1889
|
exports.THEME_LIGHT = THEME_LIGHT;
|
|
1890
|
+
exports.UNSELECTED_OPACITY = UNSELECTED_OPACITY;
|
|
1823
1891
|
exports.abbreviateNumber = abbreviateNumber;
|
|
1824
1892
|
exports.allSeriesEmpty = allSeriesEmpty;
|
|
1825
1893
|
exports.anchorCenterGraphic = anchorCenterGraphic;
|
|
@@ -1846,6 +1914,7 @@ exports.createTooltipFormatter = createTooltipFormatter;
|
|
|
1846
1914
|
exports.darkChartColors = darkChartColors;
|
|
1847
1915
|
exports.darkTheme = darkTheme;
|
|
1848
1916
|
exports.describeForecast = describeForecast;
|
|
1917
|
+
exports.describeSelection = describeSelection;
|
|
1849
1918
|
exports.downloadCsv = downloadCsv;
|
|
1850
1919
|
exports.downloadFile = downloadFile;
|
|
1851
1920
|
exports.escapeHtml = escapeHtml;
|
|
@@ -1899,6 +1968,8 @@ exports.resolveChartHeight = resolveChartHeight;
|
|
|
1899
1968
|
exports.resolveValueFormatter = resolveValueFormatter;
|
|
1900
1969
|
exports.sankeyTable = sankeyTable;
|
|
1901
1970
|
exports.scatterTable = scatterTable;
|
|
1971
|
+
exports.selectionSet = selectionSet;
|
|
1972
|
+
exports.selectionShowsSymbols = selectionShowsSymbols;
|
|
1902
1973
|
exports.seriesLabelLookup = seriesLabelLookup;
|
|
1903
1974
|
exports.sliceTable = sliceTable;
|
|
1904
1975
|
exports.stackTotals = stackTotals;
|
|
@@ -1918,5 +1989,9 @@ exports.withForecastPoints = withForecastPoints;
|
|
|
1918
1989
|
exports.withGhostSeries = withGhostSeries;
|
|
1919
1990
|
exports.withPointLabels = withPointLabels;
|
|
1920
1991
|
exports.withReferenceMarks = withReferenceMarks;
|
|
1992
|
+
exports.withSelectedBars = withSelectedBars;
|
|
1993
|
+
exports.withSelectedPoints = withSelectedPoints;
|
|
1994
|
+
exports.withSelectedSlices = withSelectedSlices;
|
|
1995
|
+
exports.withSelectionDescription = withSelectionDescription;
|
|
1921
1996
|
exports.withZoomInset = withZoomInset;
|
|
1922
1997
|
exports.withoutGhostSeries = withoutGhostSeries;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ChartSemanticColors, EChartsTheme, THEME_DARK, THEME_LIGHT, colorWithAlpha, darkChartColors, darkTheme, generateDarkTheme, generateLightTheme, getChartColors, lightChartColors, lightTheme } from './theme/index.cjs';
|
|
2
2
|
import { ValueFormat, CategoryChartData, BarChartData, BoxPlotStats, BulletItem, HistogramBucket, LineChartData, PieSliceData, ScatterChartData, WaterfallStep, ChartFormatter, LabelFormatterParams, TooltipFormatterParams, AxisConfig, ChartLegendConfig, ReferenceBand, ReferenceLine, LegendItem, HistogramBin, CategorySeriesData, ChartDataTable, CandlestickData, HeatmapData, RadarChartData, RadarIndicator, SankeyData, TreemapNode } from './types/index.cjs';
|
|
3
|
-
export { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BulletChartProps, CandlestickChartProps, CandlestickEventParams, CandlestickItem, ChartEventHandlers, ChartExportConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DeltaTextProps, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapEventParams, HistogramChartProps, LabelChartProps, LegendChartProps, LegendRenderProps, LineChartProps, LineSeriesData, PieChartProps, RadarChartProps, RadarSeriesData, ReferenceChartProps, RowHeightProps, SankeyChartProps, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartProps, ScatterSeriesData, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TreemapChartProps, TreemapEventParams, TreemapLevel, ValueFormatPreset, WaterfallChartProps, ZoomChartProps } from './types/index.cjs';
|
|
3
|
+
export { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BulletChartProps, CandlestickChartProps, CandlestickEventParams, CandlestickItem, ChartEventHandlers, ChartExportConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DeltaTextProps, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapEventParams, HistogramChartProps, LabelChartProps, LegendChartProps, LegendRenderProps, LineChartProps, LineSeriesData, PieChartProps, RadarChartProps, RadarSeriesData, ReferenceChartProps, RowHeightProps, SankeyChartProps, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartProps, ScatterSeriesData, SelectableChartProps, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TreemapChartProps, TreemapEventParams, TreemapLevel, ValueFormatPreset, WaterfallChartProps, ZoomChartProps } from './types/index.cjs';
|
|
4
4
|
import 'echarts';
|
|
5
5
|
import 'echarts/core';
|
|
6
6
|
|
|
@@ -157,7 +157,7 @@ declare function mergeChartOption<T extends object>(generated: T, override: obje
|
|
|
157
157
|
* with hollow points, bars draw it faded with a dashed outline, and the
|
|
158
158
|
* tooltip tags its values.
|
|
159
159
|
*/
|
|
160
|
-
type AnyObject$
|
|
160
|
+
type AnyObject$3 = Record<string, any>;
|
|
161
161
|
declare const DEFAULT_FORECAST_LABEL = "Forecast";
|
|
162
162
|
/** The forecast fields a series may carry */
|
|
163
163
|
interface ForecastSource {
|
|
@@ -214,7 +214,7 @@ interface ForecastLineOptions {
|
|
|
214
214
|
* the series unchanged when none has a forecast. Apply reference marks
|
|
215
215
|
* before this, so they attach to the series rather than the companions.
|
|
216
216
|
*/
|
|
217
|
-
declare function withForecastLines<S extends AnyObject$
|
|
217
|
+
declare function withForecastLines<S extends AnyObject$3>(series: S[], sources: readonly ForecastSource[], { colors }: ForecastLineOptions): AnyObject$3[];
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
220
|
* Ghost series: a faded reference drawn beside the real data, such as the
|
|
@@ -223,7 +223,7 @@ declare function withForecastLines<S extends AnyObject$2>(series: S[], sources:
|
|
|
223
223
|
* ones (in a parallel stack group) rather than stacked onto them. Ghost
|
|
224
224
|
* series carry no value labels and are left out of bar totals.
|
|
225
225
|
*/
|
|
226
|
-
type AnyObject$
|
|
226
|
+
type AnyObject$2 = Record<string, any>;
|
|
227
227
|
/** The variant field a series may carry */
|
|
228
228
|
interface GhostSource {
|
|
229
229
|
variant?: 'ghost';
|
|
@@ -256,7 +256,55 @@ declare function ghostStackId(stack: string | undefined, source: GhostSource | u
|
|
|
256
256
|
* without a ghost source are returned unchanged. Apply after building the
|
|
257
257
|
* series and before reference marks, forecast lines or totals are added.
|
|
258
258
|
*/
|
|
259
|
-
declare function withGhostSeries<S extends AnyObject$
|
|
259
|
+
declare function withGhostSeries<S extends AnyObject$2>(series: S[], sources: readonly (GhostSource | undefined)[]): S[];
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Selected categories (or pie slices): the rest of the chart recedes so the
|
|
263
|
+
* chosen ones stand out — the visual half of cross-filtering, where clicking
|
|
264
|
+
* a bar filters the other charts on a page and highlights it in its own.
|
|
265
|
+
*
|
|
266
|
+
* Selection is controlled: the chart shows what the `selected` prop says and
|
|
267
|
+
* never toggles on its own. Everything is per data item, so changing the
|
|
268
|
+
* selection only changes series values and the chart animates in place.
|
|
269
|
+
*/
|
|
270
|
+
type AnyObject$1 = Record<string, any>;
|
|
271
|
+
/** What a chart's `selected` prop accepts: one name, several, or none */
|
|
272
|
+
type ChartSelection = string | readonly string[] | null | undefined;
|
|
273
|
+
/** Opacity of items outside the selection */
|
|
274
|
+
declare const UNSELECTED_OPACITY = 0.3;
|
|
275
|
+
/** The selected names, or `undefined` when nothing is selected */
|
|
276
|
+
declare function selectionSet(selected: ChartSelection): ReadonlySet<string> | undefined;
|
|
277
|
+
/**
|
|
278
|
+
* Bars outside the selection fade. `data` lines up with `categories` by
|
|
279
|
+
* index (as `pairWithCategories` leaves it); unchanged without a selection.
|
|
280
|
+
* `seriesOpacity` is the series' own opacity (a ghost series is already
|
|
281
|
+
* faded), which an item opacity would otherwise replace.
|
|
282
|
+
*/
|
|
283
|
+
declare function withSelectedBars(data: readonly unknown[], categories: readonly string[], selected: ChartSelection, seriesOpacity?: number): unknown[];
|
|
284
|
+
interface SelectedPointOptions {
|
|
285
|
+
/** The series' own point size (0 when its points are hidden) */
|
|
286
|
+
pointSize?: number;
|
|
287
|
+
/** Ring colour around a selected point (the chart surface) */
|
|
288
|
+
ringColor?: string;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Line / area points at selected categories: shown even when the series
|
|
292
|
+
* hides its points, larger, and ringed in the surface colour. The series
|
|
293
|
+
* must set `showSymbol: true` (see `selectionShowsSymbols`) for points it
|
|
294
|
+
* otherwise hides; `symbolSize` 0 keeps the rest hidden.
|
|
295
|
+
*/
|
|
296
|
+
declare function withSelectedPoints(data: readonly unknown[], categories: readonly string[], selected: ChartSelection, options?: SelectedPointOptions): unknown[];
|
|
297
|
+
/** Whether a line / area series must turn its symbols on to show selected points */
|
|
298
|
+
declare function selectionShowsSymbols(selected: ChartSelection): boolean;
|
|
299
|
+
/** Pie / donut slices outside the selection fade; `items` are ECharts pie data items */
|
|
300
|
+
declare function withSelectedSlices<T extends {
|
|
301
|
+
name: string;
|
|
302
|
+
itemStyle?: AnyObject$1;
|
|
303
|
+
}>(items: readonly T[], selected: ChartSelection): T[];
|
|
304
|
+
/** Accessible description of the selection ("Selected: Aspen, Birch"), or undefined */
|
|
305
|
+
declare function describeSelection(selected: ChartSelection): string | undefined;
|
|
306
|
+
/** A chart description with the selection appended, for screen readers */
|
|
307
|
+
declare function withSelectionDescription(description: string | undefined, selected: ChartSelection): string | undefined;
|
|
260
308
|
|
|
261
309
|
/**
|
|
262
310
|
* Builders for the label, axis, tooltip and legend parts of a chart option.
|
|
@@ -788,4 +836,4 @@ declare function downloadFile(content: string, filename: string, mimeType?: stri
|
|
|
788
836
|
*/
|
|
789
837
|
declare function downloadCsv(table: ChartDataTable, filename: string): void;
|
|
790
838
|
|
|
791
|
-
export { type Accessor, type Aggregate, type AutoHeightOptions, AxisConfig, BarChartData, type BinValuesOptions, BoxPlotStats, type BuildDataLabelOptions, type BuildLegendOptions, type BuildTooltipOptions, BulletItem, CandlestickData, CategoryChartData, CategorySeriesData, ChartDataTable, ChartFormatter, type ChartFormatterOptions, type ChartFormatters, ChartLegendConfig, DEFAULT_FORECAST_LABEL, type Delta, type ForecastLineOptions, type ForecastSource, type FromRecordsOptions, GHOST_BAR_OPACITY, GHOST_LINE_OPACITY, type GhostSource, HeatmapData, HistogramBin, HistogramBucket, LabelFormatterParams, LegendItem, LineChartData, PieSliceData, type PointLabelLookup, RadarChartData, RadarIndicator, ReferenceBand, ReferenceLine, type ReferenceMarkOptions, SankeyData, ScatterChartData, type StackTotalOptions, type ToSliceDataOptions, TooltipFormatterParams, TreemapNode, ValueFormat, type WaterfallBar, WaterfallStep, abbreviateNumber, allSeriesEmpty, anchorCenterGraphic, barCornerRadius, binValues, boxPlotTable, boxplotStats, buildAxis, buildDataLabel, buildDataZoom, buildLegend, buildMarkArea, buildMarkLine, buildStackTotalSeries, buildTooltip, bulletTable, candlestickTable, categoryTable, chartFilename, chartFormatters, computeDelta, createTooltipFormatter, describeForecast, downloadCsv, downloadFile, escapeHtml, forecastStart, forecastTagLookup, formatCurrency, formatDate, formatNumber, formatPercent, formatTableCell, formatTooltipValue, formatValue, fromRecords, generateAreaChartDescription, generateBarChartDescription, generateBoxPlotDescription, generateBulletDescription, generateComboChartDescription, generateDataTable, generateDotPlotDescription, generateHistogramDescription, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription, generateWaterfallDescription, getLegendItems, getReplaceMerge, ghostStackId, gridInset, hasForecast, hasGhostSeries, hasPointLabels, heatmapTable, histogramTable, isGhostSeries, itemLabelLookup, legendCenter, mergeChartOption, nameLabelLookup, niceStep, pairWithCategories, pointLabel, quantile, radarTable, resolveChartHeight, resolveValueFormatter, sankeyTable, scatterTable, seriesLabelLookup, sliceTable, stackTotals, tableToCsv, toPercentStack, toSliceData, treemapTable, trendLine, valueAxisConfig, valueLabelFormatter, waterfallLayout, waterfallTable, withEndLabelInset, withForecastBars, withForecastLines, withForecastPoints, withGhostSeries, withPointLabels, withReferenceMarks, withZoomInset, withoutGhostSeries };
|
|
839
|
+
export { type Accessor, type Aggregate, type AutoHeightOptions, AxisConfig, BarChartData, type BinValuesOptions, BoxPlotStats, type BuildDataLabelOptions, type BuildLegendOptions, type BuildTooltipOptions, BulletItem, CandlestickData, CategoryChartData, CategorySeriesData, ChartDataTable, ChartFormatter, type ChartFormatterOptions, type ChartFormatters, ChartLegendConfig, type ChartSelection, DEFAULT_FORECAST_LABEL, type Delta, type ForecastLineOptions, type ForecastSource, type FromRecordsOptions, GHOST_BAR_OPACITY, GHOST_LINE_OPACITY, type GhostSource, HeatmapData, HistogramBin, HistogramBucket, LabelFormatterParams, LegendItem, LineChartData, PieSliceData, type PointLabelLookup, RadarChartData, RadarIndicator, ReferenceBand, ReferenceLine, type ReferenceMarkOptions, SankeyData, ScatterChartData, type SelectedPointOptions, type StackTotalOptions, type ToSliceDataOptions, TooltipFormatterParams, TreemapNode, UNSELECTED_OPACITY, ValueFormat, type WaterfallBar, WaterfallStep, abbreviateNumber, allSeriesEmpty, anchorCenterGraphic, barCornerRadius, binValues, boxPlotTable, boxplotStats, buildAxis, buildDataLabel, buildDataZoom, buildLegend, buildMarkArea, buildMarkLine, buildStackTotalSeries, buildTooltip, bulletTable, candlestickTable, categoryTable, chartFilename, chartFormatters, computeDelta, createTooltipFormatter, describeForecast, describeSelection, downloadCsv, downloadFile, escapeHtml, forecastStart, forecastTagLookup, formatCurrency, formatDate, formatNumber, formatPercent, formatTableCell, formatTooltipValue, formatValue, fromRecords, generateAreaChartDescription, generateBarChartDescription, generateBoxPlotDescription, generateBulletDescription, generateComboChartDescription, generateDataTable, generateDotPlotDescription, generateHistogramDescription, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription, generateWaterfallDescription, getLegendItems, getReplaceMerge, ghostStackId, gridInset, hasForecast, hasGhostSeries, hasPointLabels, heatmapTable, histogramTable, isGhostSeries, itemLabelLookup, legendCenter, mergeChartOption, nameLabelLookup, niceStep, pairWithCategories, pointLabel, quantile, radarTable, resolveChartHeight, resolveValueFormatter, sankeyTable, scatterTable, selectionSet, selectionShowsSymbols, seriesLabelLookup, sliceTable, stackTotals, tableToCsv, toPercentStack, toSliceData, treemapTable, trendLine, valueAxisConfig, valueLabelFormatter, waterfallLayout, waterfallTable, withEndLabelInset, withForecastBars, withForecastLines, withForecastPoints, withGhostSeries, withPointLabels, withReferenceMarks, withSelectedBars, withSelectedPoints, withSelectedSlices, withSelectionDescription, withZoomInset, withoutGhostSeries };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ChartSemanticColors, EChartsTheme, THEME_DARK, THEME_LIGHT, colorWithAlpha, darkChartColors, darkTheme, generateDarkTheme, generateLightTheme, getChartColors, lightChartColors, lightTheme } from './theme/index.js';
|
|
2
2
|
import { ValueFormat, CategoryChartData, BarChartData, BoxPlotStats, BulletItem, HistogramBucket, LineChartData, PieSliceData, ScatterChartData, WaterfallStep, ChartFormatter, LabelFormatterParams, TooltipFormatterParams, AxisConfig, ChartLegendConfig, ReferenceBand, ReferenceLine, LegendItem, HistogramBin, CategorySeriesData, ChartDataTable, CandlestickData, HeatmapData, RadarChartData, RadarIndicator, SankeyData, TreemapNode } from './types/index.js';
|
|
3
|
-
export { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BulletChartProps, CandlestickChartProps, CandlestickEventParams, CandlestickItem, ChartEventHandlers, ChartExportConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DeltaTextProps, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapEventParams, HistogramChartProps, LabelChartProps, LegendChartProps, LegendRenderProps, LineChartProps, LineSeriesData, PieChartProps, RadarChartProps, RadarSeriesData, ReferenceChartProps, RowHeightProps, SankeyChartProps, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartProps, ScatterSeriesData, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TreemapChartProps, TreemapEventParams, TreemapLevel, ValueFormatPreset, WaterfallChartProps, ZoomChartProps } from './types/index.js';
|
|
3
|
+
export { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BulletChartProps, CandlestickChartProps, CandlestickEventParams, CandlestickItem, ChartEventHandlers, ChartExportConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DeltaTextProps, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapEventParams, HistogramChartProps, LabelChartProps, LegendChartProps, LegendRenderProps, LineChartProps, LineSeriesData, PieChartProps, RadarChartProps, RadarSeriesData, ReferenceChartProps, RowHeightProps, SankeyChartProps, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartProps, ScatterSeriesData, SelectableChartProps, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TreemapChartProps, TreemapEventParams, TreemapLevel, ValueFormatPreset, WaterfallChartProps, ZoomChartProps } from './types/index.js';
|
|
4
4
|
import 'echarts';
|
|
5
5
|
import 'echarts/core';
|
|
6
6
|
|
|
@@ -157,7 +157,7 @@ declare function mergeChartOption<T extends object>(generated: T, override: obje
|
|
|
157
157
|
* with hollow points, bars draw it faded with a dashed outline, and the
|
|
158
158
|
* tooltip tags its values.
|
|
159
159
|
*/
|
|
160
|
-
type AnyObject$
|
|
160
|
+
type AnyObject$3 = Record<string, any>;
|
|
161
161
|
declare const DEFAULT_FORECAST_LABEL = "Forecast";
|
|
162
162
|
/** The forecast fields a series may carry */
|
|
163
163
|
interface ForecastSource {
|
|
@@ -214,7 +214,7 @@ interface ForecastLineOptions {
|
|
|
214
214
|
* the series unchanged when none has a forecast. Apply reference marks
|
|
215
215
|
* before this, so they attach to the series rather than the companions.
|
|
216
216
|
*/
|
|
217
|
-
declare function withForecastLines<S extends AnyObject$
|
|
217
|
+
declare function withForecastLines<S extends AnyObject$3>(series: S[], sources: readonly ForecastSource[], { colors }: ForecastLineOptions): AnyObject$3[];
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
220
|
* Ghost series: a faded reference drawn beside the real data, such as the
|
|
@@ -223,7 +223,7 @@ declare function withForecastLines<S extends AnyObject$2>(series: S[], sources:
|
|
|
223
223
|
* ones (in a parallel stack group) rather than stacked onto them. Ghost
|
|
224
224
|
* series carry no value labels and are left out of bar totals.
|
|
225
225
|
*/
|
|
226
|
-
type AnyObject$
|
|
226
|
+
type AnyObject$2 = Record<string, any>;
|
|
227
227
|
/** The variant field a series may carry */
|
|
228
228
|
interface GhostSource {
|
|
229
229
|
variant?: 'ghost';
|
|
@@ -256,7 +256,55 @@ declare function ghostStackId(stack: string | undefined, source: GhostSource | u
|
|
|
256
256
|
* without a ghost source are returned unchanged. Apply after building the
|
|
257
257
|
* series and before reference marks, forecast lines or totals are added.
|
|
258
258
|
*/
|
|
259
|
-
declare function withGhostSeries<S extends AnyObject$
|
|
259
|
+
declare function withGhostSeries<S extends AnyObject$2>(series: S[], sources: readonly (GhostSource | undefined)[]): S[];
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Selected categories (or pie slices): the rest of the chart recedes so the
|
|
263
|
+
* chosen ones stand out — the visual half of cross-filtering, where clicking
|
|
264
|
+
* a bar filters the other charts on a page and highlights it in its own.
|
|
265
|
+
*
|
|
266
|
+
* Selection is controlled: the chart shows what the `selected` prop says and
|
|
267
|
+
* never toggles on its own. Everything is per data item, so changing the
|
|
268
|
+
* selection only changes series values and the chart animates in place.
|
|
269
|
+
*/
|
|
270
|
+
type AnyObject$1 = Record<string, any>;
|
|
271
|
+
/** What a chart's `selected` prop accepts: one name, several, or none */
|
|
272
|
+
type ChartSelection = string | readonly string[] | null | undefined;
|
|
273
|
+
/** Opacity of items outside the selection */
|
|
274
|
+
declare const UNSELECTED_OPACITY = 0.3;
|
|
275
|
+
/** The selected names, or `undefined` when nothing is selected */
|
|
276
|
+
declare function selectionSet(selected: ChartSelection): ReadonlySet<string> | undefined;
|
|
277
|
+
/**
|
|
278
|
+
* Bars outside the selection fade. `data` lines up with `categories` by
|
|
279
|
+
* index (as `pairWithCategories` leaves it); unchanged without a selection.
|
|
280
|
+
* `seriesOpacity` is the series' own opacity (a ghost series is already
|
|
281
|
+
* faded), which an item opacity would otherwise replace.
|
|
282
|
+
*/
|
|
283
|
+
declare function withSelectedBars(data: readonly unknown[], categories: readonly string[], selected: ChartSelection, seriesOpacity?: number): unknown[];
|
|
284
|
+
interface SelectedPointOptions {
|
|
285
|
+
/** The series' own point size (0 when its points are hidden) */
|
|
286
|
+
pointSize?: number;
|
|
287
|
+
/** Ring colour around a selected point (the chart surface) */
|
|
288
|
+
ringColor?: string;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Line / area points at selected categories: shown even when the series
|
|
292
|
+
* hides its points, larger, and ringed in the surface colour. The series
|
|
293
|
+
* must set `showSymbol: true` (see `selectionShowsSymbols`) for points it
|
|
294
|
+
* otherwise hides; `symbolSize` 0 keeps the rest hidden.
|
|
295
|
+
*/
|
|
296
|
+
declare function withSelectedPoints(data: readonly unknown[], categories: readonly string[], selected: ChartSelection, options?: SelectedPointOptions): unknown[];
|
|
297
|
+
/** Whether a line / area series must turn its symbols on to show selected points */
|
|
298
|
+
declare function selectionShowsSymbols(selected: ChartSelection): boolean;
|
|
299
|
+
/** Pie / donut slices outside the selection fade; `items` are ECharts pie data items */
|
|
300
|
+
declare function withSelectedSlices<T extends {
|
|
301
|
+
name: string;
|
|
302
|
+
itemStyle?: AnyObject$1;
|
|
303
|
+
}>(items: readonly T[], selected: ChartSelection): T[];
|
|
304
|
+
/** Accessible description of the selection ("Selected: Aspen, Birch"), or undefined */
|
|
305
|
+
declare function describeSelection(selected: ChartSelection): string | undefined;
|
|
306
|
+
/** A chart description with the selection appended, for screen readers */
|
|
307
|
+
declare function withSelectionDescription(description: string | undefined, selected: ChartSelection): string | undefined;
|
|
260
308
|
|
|
261
309
|
/**
|
|
262
310
|
* Builders for the label, axis, tooltip and legend parts of a chart option.
|
|
@@ -788,4 +836,4 @@ declare function downloadFile(content: string, filename: string, mimeType?: stri
|
|
|
788
836
|
*/
|
|
789
837
|
declare function downloadCsv(table: ChartDataTable, filename: string): void;
|
|
790
838
|
|
|
791
|
-
export { type Accessor, type Aggregate, type AutoHeightOptions, AxisConfig, BarChartData, type BinValuesOptions, BoxPlotStats, type BuildDataLabelOptions, type BuildLegendOptions, type BuildTooltipOptions, BulletItem, CandlestickData, CategoryChartData, CategorySeriesData, ChartDataTable, ChartFormatter, type ChartFormatterOptions, type ChartFormatters, ChartLegendConfig, DEFAULT_FORECAST_LABEL, type Delta, type ForecastLineOptions, type ForecastSource, type FromRecordsOptions, GHOST_BAR_OPACITY, GHOST_LINE_OPACITY, type GhostSource, HeatmapData, HistogramBin, HistogramBucket, LabelFormatterParams, LegendItem, LineChartData, PieSliceData, type PointLabelLookup, RadarChartData, RadarIndicator, ReferenceBand, ReferenceLine, type ReferenceMarkOptions, SankeyData, ScatterChartData, type StackTotalOptions, type ToSliceDataOptions, TooltipFormatterParams, TreemapNode, ValueFormat, type WaterfallBar, WaterfallStep, abbreviateNumber, allSeriesEmpty, anchorCenterGraphic, barCornerRadius, binValues, boxPlotTable, boxplotStats, buildAxis, buildDataLabel, buildDataZoom, buildLegend, buildMarkArea, buildMarkLine, buildStackTotalSeries, buildTooltip, bulletTable, candlestickTable, categoryTable, chartFilename, chartFormatters, computeDelta, createTooltipFormatter, describeForecast, downloadCsv, downloadFile, escapeHtml, forecastStart, forecastTagLookup, formatCurrency, formatDate, formatNumber, formatPercent, formatTableCell, formatTooltipValue, formatValue, fromRecords, generateAreaChartDescription, generateBarChartDescription, generateBoxPlotDescription, generateBulletDescription, generateComboChartDescription, generateDataTable, generateDotPlotDescription, generateHistogramDescription, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription, generateWaterfallDescription, getLegendItems, getReplaceMerge, ghostStackId, gridInset, hasForecast, hasGhostSeries, hasPointLabels, heatmapTable, histogramTable, isGhostSeries, itemLabelLookup, legendCenter, mergeChartOption, nameLabelLookup, niceStep, pairWithCategories, pointLabel, quantile, radarTable, resolveChartHeight, resolveValueFormatter, sankeyTable, scatterTable, seriesLabelLookup, sliceTable, stackTotals, tableToCsv, toPercentStack, toSliceData, treemapTable, trendLine, valueAxisConfig, valueLabelFormatter, waterfallLayout, waterfallTable, withEndLabelInset, withForecastBars, withForecastLines, withForecastPoints, withGhostSeries, withPointLabels, withReferenceMarks, withZoomInset, withoutGhostSeries };
|
|
839
|
+
export { type Accessor, type Aggregate, type AutoHeightOptions, AxisConfig, BarChartData, type BinValuesOptions, BoxPlotStats, type BuildDataLabelOptions, type BuildLegendOptions, type BuildTooltipOptions, BulletItem, CandlestickData, CategoryChartData, CategorySeriesData, ChartDataTable, ChartFormatter, type ChartFormatterOptions, type ChartFormatters, ChartLegendConfig, type ChartSelection, DEFAULT_FORECAST_LABEL, type Delta, type ForecastLineOptions, type ForecastSource, type FromRecordsOptions, GHOST_BAR_OPACITY, GHOST_LINE_OPACITY, type GhostSource, HeatmapData, HistogramBin, HistogramBucket, LabelFormatterParams, LegendItem, LineChartData, PieSliceData, type PointLabelLookup, RadarChartData, RadarIndicator, ReferenceBand, ReferenceLine, type ReferenceMarkOptions, SankeyData, ScatterChartData, type SelectedPointOptions, type StackTotalOptions, type ToSliceDataOptions, TooltipFormatterParams, TreemapNode, UNSELECTED_OPACITY, ValueFormat, type WaterfallBar, WaterfallStep, abbreviateNumber, allSeriesEmpty, anchorCenterGraphic, barCornerRadius, binValues, boxPlotTable, boxplotStats, buildAxis, buildDataLabel, buildDataZoom, buildLegend, buildMarkArea, buildMarkLine, buildStackTotalSeries, buildTooltip, bulletTable, candlestickTable, categoryTable, chartFilename, chartFormatters, computeDelta, createTooltipFormatter, describeForecast, describeSelection, downloadCsv, downloadFile, escapeHtml, forecastStart, forecastTagLookup, formatCurrency, formatDate, formatNumber, formatPercent, formatTableCell, formatTooltipValue, formatValue, fromRecords, generateAreaChartDescription, generateBarChartDescription, generateBoxPlotDescription, generateBulletDescription, generateComboChartDescription, generateDataTable, generateDotPlotDescription, generateHistogramDescription, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription, generateWaterfallDescription, getLegendItems, getReplaceMerge, ghostStackId, gridInset, hasForecast, hasGhostSeries, hasPointLabels, heatmapTable, histogramTable, isGhostSeries, itemLabelLookup, legendCenter, mergeChartOption, nameLabelLookup, niceStep, pairWithCategories, pointLabel, quantile, radarTable, resolveChartHeight, resolveValueFormatter, sankeyTable, scatterTable, selectionSet, selectionShowsSymbols, seriesLabelLookup, sliceTable, stackTotals, tableToCsv, toPercentStack, toSliceData, treemapTable, trendLine, valueAxisConfig, valueLabelFormatter, waterfallLayout, waterfallTable, withEndLabelInset, withForecastBars, withForecastLines, withForecastPoints, withGhostSeries, withPointLabels, withReferenceMarks, withSelectedBars, withSelectedPoints, withSelectedSlices, withSelectionDescription, withZoomInset, withoutGhostSeries };
|
package/dist/index.js
CHANGED
|
@@ -545,6 +545,73 @@ function withGhostSeries(series, sources) {
|
|
|
545
545
|
});
|
|
546
546
|
}
|
|
547
547
|
|
|
548
|
+
// src/utils/selection.ts
|
|
549
|
+
var UNSELECTED_OPACITY = 0.3;
|
|
550
|
+
function selectionSet(selected) {
|
|
551
|
+
if (selected == null) return void 0;
|
|
552
|
+
const names = typeof selected === "string" ? [selected] : selected;
|
|
553
|
+
const set = new Set(names.filter((name) => name !== ""));
|
|
554
|
+
return set.size ? set : void 0;
|
|
555
|
+
}
|
|
556
|
+
var isPlainObject4 = (item) => typeof item === "object" && item !== null && !Array.isArray(item);
|
|
557
|
+
function withItem2(item, extra) {
|
|
558
|
+
if (isPlainObject4(item) && "value" in item) {
|
|
559
|
+
return {
|
|
560
|
+
...item,
|
|
561
|
+
...extra,
|
|
562
|
+
itemStyle: { ...item.itemStyle, ...extra.itemStyle }
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
return { value: item, ...extra };
|
|
566
|
+
}
|
|
567
|
+
function opacityOf(item, seriesOpacity) {
|
|
568
|
+
const opacity = isPlainObject4(item) ? item.itemStyle?.opacity : void 0;
|
|
569
|
+
return typeof opacity === "number" ? opacity : seriesOpacity;
|
|
570
|
+
}
|
|
571
|
+
function withSelectedBars(data, categories, selected, seriesOpacity = 1) {
|
|
572
|
+
const set = selectionSet(selected);
|
|
573
|
+
if (!set) return [...data];
|
|
574
|
+
return data.map(
|
|
575
|
+
(item, index) => set.has(String(categories[index])) ? item : withItem2(item, {
|
|
576
|
+
itemStyle: { opacity: opacityOf(item, seriesOpacity) * UNSELECTED_OPACITY }
|
|
577
|
+
})
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
function withSelectedPoints(data, categories, selected, options = {}) {
|
|
581
|
+
const set = selectionSet(selected);
|
|
582
|
+
if (!set) return [...data];
|
|
583
|
+
const size = Math.max(options.pointSize ?? 0, 6) + 4;
|
|
584
|
+
return data.map(
|
|
585
|
+
(item, index) => set.has(String(categories[index])) ? withItem2(item, {
|
|
586
|
+
symbol: "circle",
|
|
587
|
+
symbolSize: size,
|
|
588
|
+
itemStyle: {
|
|
589
|
+
borderWidth: 2,
|
|
590
|
+
...options.ringColor && { borderColor: options.ringColor }
|
|
591
|
+
}
|
|
592
|
+
}) : item
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
function selectionShowsSymbols(selected) {
|
|
596
|
+
return selectionSet(selected) !== void 0;
|
|
597
|
+
}
|
|
598
|
+
function withSelectedSlices(items, selected) {
|
|
599
|
+
const set = selectionSet(selected);
|
|
600
|
+
if (!set) return [...items];
|
|
601
|
+
return items.map(
|
|
602
|
+
(item) => set.has(item.name) ? item : { ...item, itemStyle: { ...item.itemStyle, opacity: UNSELECTED_OPACITY } }
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
function describeSelection(selected) {
|
|
606
|
+
const set = selectionSet(selected);
|
|
607
|
+
return set ? `Selected: ${[...set].join(", ")}` : void 0;
|
|
608
|
+
}
|
|
609
|
+
function withSelectionDescription(description, selected) {
|
|
610
|
+
const note = describeSelection(selected);
|
|
611
|
+
if (!note) return description;
|
|
612
|
+
return description ? `${description.replace(/\.?\s*$/, "")}. ${note}.` : `${note}.`;
|
|
613
|
+
}
|
|
614
|
+
|
|
548
615
|
// src/utils/stats.ts
|
|
549
616
|
var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
550
617
|
var clean = (value) => Number(value.toPrecision(12));
|
|
@@ -1494,4 +1561,4 @@ function downloadCsv(table, filename) {
|
|
|
1494
1561
|
);
|
|
1495
1562
|
}
|
|
1496
1563
|
|
|
1497
|
-
export { DEFAULT_FORECAST_LABEL, GHOST_BAR_OPACITY, GHOST_LINE_OPACITY, abbreviateNumber, allSeriesEmpty, anchorCenterGraphic, barCornerRadius, binValues, boxPlotTable, boxplotStats, buildAxis, buildDataLabel, buildDataZoom, buildLegend, buildMarkArea, buildMarkLine, buildStackTotalSeries, buildTooltip, bulletTable, candlestickTable, categoryTable, chartFilename, chartFormatters, computeDelta, createTooltipFormatter, describeForecast, downloadCsv, downloadFile, escapeHtml, forecastStart, forecastTagLookup, formatCurrency, formatDate, formatNumber, formatPercent, formatTableCell, formatTooltipValue, formatValue, fromRecords, generateAreaChartDescription, generateBarChartDescription, generateBoxPlotDescription, generateBulletDescription, generateComboChartDescription, generateDataTable, generateDotPlotDescription, generateHistogramDescription, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription, generateWaterfallDescription, getLegendItems, getReplaceMerge, ghostStackId, gridInset, hasForecast, hasGhostSeries, hasPointLabels, heatmapTable, histogramTable, isGhostSeries, itemLabelLookup, legendCenter, mergeChartOption, nameLabelLookup, niceStep, pairWithCategories, pointLabel, quantile, radarTable, resolveChartHeight, resolveValueFormatter, sankeyTable, scatterTable, seriesLabelLookup, sliceTable, stackTotals, tableToCsv, toPercentStack, toSliceData, treemapTable, trendLine, valueAxisConfig, valueLabelFormatter, waterfallLayout, waterfallTable, withEndLabelInset, withForecastBars, withForecastLines, withForecastPoints, withGhostSeries, withPointLabels, withReferenceMarks, withZoomInset, withoutGhostSeries };
|
|
1564
|
+
export { DEFAULT_FORECAST_LABEL, GHOST_BAR_OPACITY, GHOST_LINE_OPACITY, UNSELECTED_OPACITY, abbreviateNumber, allSeriesEmpty, anchorCenterGraphic, barCornerRadius, binValues, boxPlotTable, boxplotStats, buildAxis, buildDataLabel, buildDataZoom, buildLegend, buildMarkArea, buildMarkLine, buildStackTotalSeries, buildTooltip, bulletTable, candlestickTable, categoryTable, chartFilename, chartFormatters, computeDelta, createTooltipFormatter, describeForecast, describeSelection, downloadCsv, downloadFile, escapeHtml, forecastStart, forecastTagLookup, formatCurrency, formatDate, formatNumber, formatPercent, formatTableCell, formatTooltipValue, formatValue, fromRecords, generateAreaChartDescription, generateBarChartDescription, generateBoxPlotDescription, generateBulletDescription, generateComboChartDescription, generateDataTable, generateDotPlotDescription, generateHistogramDescription, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription, generateWaterfallDescription, getLegendItems, getReplaceMerge, ghostStackId, gridInset, hasForecast, hasGhostSeries, hasPointLabels, heatmapTable, histogramTable, isGhostSeries, itemLabelLookup, legendCenter, mergeChartOption, nameLabelLookup, niceStep, pairWithCategories, pointLabel, quantile, radarTable, resolveChartHeight, resolveValueFormatter, sankeyTable, scatterTable, selectionSet, selectionShowsSymbols, seriesLabelLookup, sliceTable, stackTotals, tableToCsv, toPercentStack, toSliceData, treemapTable, trendLine, valueAxisConfig, valueLabelFormatter, waterfallLayout, waterfallTable, withEndLabelInset, withForecastBars, withForecastLines, withForecastPoints, withGhostSeries, withPointLabels, withReferenceMarks, withSelectedBars, withSelectedPoints, withSelectedSlices, withSelectionDescription, withZoomInset, withoutGhostSeries };
|
package/dist/types/index.d.cts
CHANGED
|
@@ -842,10 +842,19 @@ interface RowHeightProps {
|
|
|
842
842
|
/** Height per category row for `height="auto"` (defaults to 28) */
|
|
843
843
|
rowHeight?: number;
|
|
844
844
|
}
|
|
845
|
+
/**
|
|
846
|
+
* Controlled selection: the named categories (bar / line / area) or slices
|
|
847
|
+
* (pie / donut) stand out and the rest recede. The chart never changes it on
|
|
848
|
+
* its own — set it from `onClick` to cross-filter.
|
|
849
|
+
*/
|
|
850
|
+
interface SelectableChartProps {
|
|
851
|
+
/** Selected category or slice names; empty / undefined = nothing selected */
|
|
852
|
+
selected?: string | readonly string[] | null;
|
|
853
|
+
}
|
|
845
854
|
/**
|
|
846
855
|
* Line chart specific props
|
|
847
856
|
*/
|
|
848
|
-
interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
857
|
+
interface LineChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
849
858
|
/** Show data labels */
|
|
850
859
|
showLabels?: boolean;
|
|
851
860
|
/** Chart data */
|
|
@@ -868,7 +877,7 @@ interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
|
|
|
868
877
|
/**
|
|
869
878
|
* Bar chart specific props
|
|
870
879
|
*/
|
|
871
|
-
interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
|
|
880
|
+
interface BarChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
|
|
872
881
|
/** Chart data */
|
|
873
882
|
data: BarChartData;
|
|
874
883
|
/**
|
|
@@ -894,7 +903,7 @@ interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProp
|
|
|
894
903
|
/**
|
|
895
904
|
* Pie chart specific props
|
|
896
905
|
*/
|
|
897
|
-
interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps {
|
|
906
|
+
interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, SelectableChartProps {
|
|
898
907
|
/** Chart data */
|
|
899
908
|
data: PieSliceData[];
|
|
900
909
|
/** Show slice labels */
|
|
@@ -920,7 +929,7 @@ interface DonutChartProps extends Omit<PieChartProps, 'innerRadius'> {
|
|
|
920
929
|
/**
|
|
921
930
|
* Area chart specific props
|
|
922
931
|
*/
|
|
923
|
-
interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
932
|
+
interface AreaChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
924
933
|
/** Show data labels */
|
|
925
934
|
showLabels?: boolean;
|
|
926
935
|
/** Chart data */
|
|
@@ -933,6 +942,8 @@ interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
|
|
|
933
942
|
connectNulls?: boolean;
|
|
934
943
|
/** Use gradient fill */
|
|
935
944
|
gradient?: boolean;
|
|
945
|
+
/** Show data points on the area's line (needed for clicks on a point) */
|
|
946
|
+
showDataPoints?: boolean;
|
|
936
947
|
/** Click event handler */
|
|
937
948
|
onClick?: (params: DataPointEventParams) => void;
|
|
938
949
|
/** Hover event handler */
|
|
@@ -1288,4 +1299,4 @@ interface StatCardProps {
|
|
|
1288
1299
|
class?: string;
|
|
1289
1300
|
}
|
|
1290
1301
|
|
|
1291
|
-
export type { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, AxisConfig, BarChartData, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BoxPlotStats, BulletChartProps, BulletItem, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, CategoryChartData, CategorySeriesData, ChartDataTable, ChartEventHandlers, ChartExportConfig, ChartFormatter, ChartLegendConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DeltaTextProps, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, HistogramBin, HistogramBucket, HistogramChartProps, LabelChartProps, LabelFormatterParams, LegendChartProps, LegendItem, LegendRenderProps, LineChartData, LineChartProps, LineSeriesData, PieChartProps, PieSliceData, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, ReferenceBand, ReferenceChartProps, ReferenceLine, RowHeightProps, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartData, ScatterChartProps, ScatterSeriesData, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TooltipFormatterParams, TreemapChartProps, TreemapEventParams, TreemapLevel, TreemapNode, ValueFormat, ValueFormatPreset, WaterfallChartProps, WaterfallStep, ZoomChartProps };
|
|
1302
|
+
export type { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, AxisConfig, BarChartData, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BoxPlotStats, BulletChartProps, BulletItem, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, CategoryChartData, CategorySeriesData, ChartDataTable, ChartEventHandlers, ChartExportConfig, ChartFormatter, ChartLegendConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DeltaTextProps, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, HistogramBin, HistogramBucket, HistogramChartProps, LabelChartProps, LabelFormatterParams, LegendChartProps, LegendItem, LegendRenderProps, LineChartData, LineChartProps, LineSeriesData, PieChartProps, PieSliceData, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, ReferenceBand, ReferenceChartProps, ReferenceLine, RowHeightProps, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartData, ScatterChartProps, ScatterSeriesData, SelectableChartProps, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TooltipFormatterParams, TreemapChartProps, TreemapEventParams, TreemapLevel, TreemapNode, ValueFormat, ValueFormatPreset, WaterfallChartProps, WaterfallStep, ZoomChartProps };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -842,10 +842,19 @@ interface RowHeightProps {
|
|
|
842
842
|
/** Height per category row for `height="auto"` (defaults to 28) */
|
|
843
843
|
rowHeight?: number;
|
|
844
844
|
}
|
|
845
|
+
/**
|
|
846
|
+
* Controlled selection: the named categories (bar / line / area) or slices
|
|
847
|
+
* (pie / donut) stand out and the rest recede. The chart never changes it on
|
|
848
|
+
* its own — set it from `onClick` to cross-filter.
|
|
849
|
+
*/
|
|
850
|
+
interface SelectableChartProps {
|
|
851
|
+
/** Selected category or slice names; empty / undefined = nothing selected */
|
|
852
|
+
selected?: string | readonly string[] | null;
|
|
853
|
+
}
|
|
845
854
|
/**
|
|
846
855
|
* Line chart specific props
|
|
847
856
|
*/
|
|
848
|
-
interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
857
|
+
interface LineChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
849
858
|
/** Show data labels */
|
|
850
859
|
showLabels?: boolean;
|
|
851
860
|
/** Chart data */
|
|
@@ -868,7 +877,7 @@ interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
|
|
|
868
877
|
/**
|
|
869
878
|
* Bar chart specific props
|
|
870
879
|
*/
|
|
871
|
-
interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
|
|
880
|
+
interface BarChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
|
|
872
881
|
/** Chart data */
|
|
873
882
|
data: BarChartData;
|
|
874
883
|
/**
|
|
@@ -894,7 +903,7 @@ interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProp
|
|
|
894
903
|
/**
|
|
895
904
|
* Pie chart specific props
|
|
896
905
|
*/
|
|
897
|
-
interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps {
|
|
906
|
+
interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, SelectableChartProps {
|
|
898
907
|
/** Chart data */
|
|
899
908
|
data: PieSliceData[];
|
|
900
909
|
/** Show slice labels */
|
|
@@ -920,7 +929,7 @@ interface DonutChartProps extends Omit<PieChartProps, 'innerRadius'> {
|
|
|
920
929
|
/**
|
|
921
930
|
* Area chart specific props
|
|
922
931
|
*/
|
|
923
|
-
interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
932
|
+
interface AreaChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
924
933
|
/** Show data labels */
|
|
925
934
|
showLabels?: boolean;
|
|
926
935
|
/** Chart data */
|
|
@@ -933,6 +942,8 @@ interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
|
|
|
933
942
|
connectNulls?: boolean;
|
|
934
943
|
/** Use gradient fill */
|
|
935
944
|
gradient?: boolean;
|
|
945
|
+
/** Show data points on the area's line (needed for clicks on a point) */
|
|
946
|
+
showDataPoints?: boolean;
|
|
936
947
|
/** Click event handler */
|
|
937
948
|
onClick?: (params: DataPointEventParams) => void;
|
|
938
949
|
/** Hover event handler */
|
|
@@ -1288,4 +1299,4 @@ interface StatCardProps {
|
|
|
1288
1299
|
class?: string;
|
|
1289
1300
|
}
|
|
1290
1301
|
|
|
1291
|
-
export type { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, AxisConfig, BarChartData, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BoxPlotStats, BulletChartProps, BulletItem, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, CategoryChartData, CategorySeriesData, ChartDataTable, ChartEventHandlers, ChartExportConfig, ChartFormatter, ChartLegendConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DeltaTextProps, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, HistogramBin, HistogramBucket, HistogramChartProps, LabelChartProps, LabelFormatterParams, LegendChartProps, LegendItem, LegendRenderProps, LineChartData, LineChartProps, LineSeriesData, PieChartProps, PieSliceData, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, ReferenceBand, ReferenceChartProps, ReferenceLine, RowHeightProps, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartData, ScatterChartProps, ScatterSeriesData, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TooltipFormatterParams, TreemapChartProps, TreemapEventParams, TreemapLevel, TreemapNode, ValueFormat, ValueFormatPreset, WaterfallChartProps, WaterfallStep, ZoomChartProps };
|
|
1302
|
+
export type { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, AxisConfig, BarChartData, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BoxPlotStats, BulletChartProps, BulletItem, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, CategoryChartData, CategorySeriesData, ChartDataTable, ChartEventHandlers, ChartExportConfig, ChartFormatter, ChartLegendConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DeltaTextProps, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, HistogramBin, HistogramBucket, HistogramChartProps, LabelChartProps, LabelFormatterParams, LegendChartProps, LegendItem, LegendRenderProps, LineChartData, LineChartProps, LineSeriesData, PieChartProps, PieSliceData, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, ReferenceBand, ReferenceChartProps, ReferenceLine, RowHeightProps, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartData, ScatterChartProps, ScatterSeriesData, SelectableChartProps, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TooltipFormatterParams, TreemapChartProps, TreemapEventParams, TreemapLevel, TreemapNode, ValueFormat, ValueFormatPreset, WaterfallChartProps, WaterfallStep, ZoomChartProps };
|