@classic-homes/charts-core 0.5.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 +156 -8
- package/dist/index.d.cts +97 -5
- package/dist/index.d.ts +97 -5
- package/dist/index.js +142 -9
- package/dist/types/index.d.cts +72 -5
- package/dist/types/index.d.ts +72 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -806,6 +806,133 @@ function mergeChartOption(generated, override) {
|
|
|
806
806
|
return merged;
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
+
// src/utils/ghost.ts
|
|
810
|
+
var GHOST_LINE_OPACITY = 0.6;
|
|
811
|
+
var GHOST_BAR_OPACITY = 0.35;
|
|
812
|
+
var GHOST_STACK = "\0ghost";
|
|
813
|
+
function isGhostSeries(source) {
|
|
814
|
+
return source?.variant === "ghost";
|
|
815
|
+
}
|
|
816
|
+
function hasGhostSeries(series) {
|
|
817
|
+
return !!series?.some(isGhostSeries);
|
|
818
|
+
}
|
|
819
|
+
function withoutGhostSeries(series) {
|
|
820
|
+
return series.filter((s) => !isGhostSeries(s));
|
|
821
|
+
}
|
|
822
|
+
function ghostStackId(stack, source) {
|
|
823
|
+
if (stack === void 0 || !isGhostSeries(source) || stack.endsWith(GHOST_STACK)) return stack;
|
|
824
|
+
return `${stack}${GHOST_STACK}`;
|
|
825
|
+
}
|
|
826
|
+
var isPlainObject3 = (item) => typeof item === "object" && item !== null && !Array.isArray(item);
|
|
827
|
+
function withoutItemLabels(data) {
|
|
828
|
+
if (!Array.isArray(data)) return data;
|
|
829
|
+
return data.map(
|
|
830
|
+
(item) => isPlainObject3(item) && item.label ? { ...item, label: { ...item.label, show: false } } : item
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
function withGhostSeries(series, sources) {
|
|
834
|
+
if (!hasGhostSeries(sources)) return series;
|
|
835
|
+
return series.map((s, index) => {
|
|
836
|
+
const source = sources[index];
|
|
837
|
+
if (!isGhostSeries(source)) return s;
|
|
838
|
+
const common = {
|
|
839
|
+
...s,
|
|
840
|
+
stack: ghostStackId(s.stack, source),
|
|
841
|
+
data: withoutItemLabels(s.data),
|
|
842
|
+
label: { ...s.label, show: false }
|
|
843
|
+
};
|
|
844
|
+
if (s.type === "bar") {
|
|
845
|
+
return {
|
|
846
|
+
...common,
|
|
847
|
+
itemStyle: { ...s.itemStyle, opacity: GHOST_BAR_OPACITY },
|
|
848
|
+
emphasis: {
|
|
849
|
+
...s.emphasis,
|
|
850
|
+
itemStyle: { ...s.emphasis?.itemStyle, opacity: GHOST_BAR_OPACITY + 0.2 }
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
return {
|
|
855
|
+
...common,
|
|
856
|
+
showSymbol: false,
|
|
857
|
+
areaStyle: void 0,
|
|
858
|
+
lineStyle: { ...s.lineStyle, type: "dashed", opacity: GHOST_LINE_OPACITY },
|
|
859
|
+
itemStyle: { ...s.itemStyle, opacity: GHOST_LINE_OPACITY },
|
|
860
|
+
emphasis: {
|
|
861
|
+
...s.emphasis,
|
|
862
|
+
areaStyle: void 0
|
|
863
|
+
},
|
|
864
|
+
z: (s.z ?? 2) - 1
|
|
865
|
+
};
|
|
866
|
+
});
|
|
867
|
+
}
|
|
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
|
+
|
|
809
936
|
// src/utils/stats.ts
|
|
810
937
|
var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
811
938
|
var clean = (value) => Number(value.toPrecision(12));
|
|
@@ -958,20 +1085,26 @@ function waterfallLayout(steps) {
|
|
|
958
1085
|
}
|
|
959
1086
|
function toPercentStack(series) {
|
|
960
1087
|
const length = Math.max(0, ...series.map((s) => s.data.length));
|
|
961
|
-
const
|
|
1088
|
+
const sumOf = (ghost) => Array.from(
|
|
962
1089
|
{ length },
|
|
963
1090
|
(_, index) => series.reduce((sum, s) => {
|
|
1091
|
+
if (s.variant === "ghost" !== ghost) return sum;
|
|
964
1092
|
const value = s.data[index];
|
|
965
1093
|
return sum + (isFiniteNumber(value) ? Math.abs(value) : 0);
|
|
966
1094
|
}, 0)
|
|
967
1095
|
);
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1096
|
+
const totals = sumOf(false);
|
|
1097
|
+
const ghostTotals = sumOf(true);
|
|
1098
|
+
return series.map((s) => {
|
|
1099
|
+
const sums = s.variant === "ghost" ? ghostTotals : totals;
|
|
1100
|
+
return {
|
|
1101
|
+
...s,
|
|
1102
|
+
data: s.data.map((value, index) => {
|
|
1103
|
+
if (!isFiniteNumber(value)) return null;
|
|
1104
|
+
return sums[index] === 0 ? 0 : clean(value / sums[index] * 100);
|
|
1105
|
+
})
|
|
1106
|
+
};
|
|
1107
|
+
});
|
|
975
1108
|
}
|
|
976
1109
|
function stackTotals(series, stacked) {
|
|
977
1110
|
const length = Math.max(0, ...series.map((s) => s.data.length));
|
|
@@ -1750,8 +1883,11 @@ function downloadCsv(table, filename) {
|
|
|
1750
1883
|
}
|
|
1751
1884
|
|
|
1752
1885
|
exports.DEFAULT_FORECAST_LABEL = DEFAULT_FORECAST_LABEL;
|
|
1886
|
+
exports.GHOST_BAR_OPACITY = GHOST_BAR_OPACITY;
|
|
1887
|
+
exports.GHOST_LINE_OPACITY = GHOST_LINE_OPACITY;
|
|
1753
1888
|
exports.THEME_DARK = THEME_DARK;
|
|
1754
1889
|
exports.THEME_LIGHT = THEME_LIGHT;
|
|
1890
|
+
exports.UNSELECTED_OPACITY = UNSELECTED_OPACITY;
|
|
1755
1891
|
exports.abbreviateNumber = abbreviateNumber;
|
|
1756
1892
|
exports.allSeriesEmpty = allSeriesEmpty;
|
|
1757
1893
|
exports.anchorCenterGraphic = anchorCenterGraphic;
|
|
@@ -1778,6 +1914,7 @@ exports.createTooltipFormatter = createTooltipFormatter;
|
|
|
1778
1914
|
exports.darkChartColors = darkChartColors;
|
|
1779
1915
|
exports.darkTheme = darkTheme;
|
|
1780
1916
|
exports.describeForecast = describeForecast;
|
|
1917
|
+
exports.describeSelection = describeSelection;
|
|
1781
1918
|
exports.downloadCsv = downloadCsv;
|
|
1782
1919
|
exports.downloadFile = downloadFile;
|
|
1783
1920
|
exports.escapeHtml = escapeHtml;
|
|
@@ -1808,11 +1945,14 @@ exports.generateWaterfallDescription = generateWaterfallDescription;
|
|
|
1808
1945
|
exports.getChartColors = getChartColors;
|
|
1809
1946
|
exports.getLegendItems = getLegendItems;
|
|
1810
1947
|
exports.getReplaceMerge = getReplaceMerge;
|
|
1948
|
+
exports.ghostStackId = ghostStackId;
|
|
1811
1949
|
exports.gridInset = gridInset;
|
|
1812
1950
|
exports.hasForecast = hasForecast;
|
|
1951
|
+
exports.hasGhostSeries = hasGhostSeries;
|
|
1813
1952
|
exports.hasPointLabels = hasPointLabels;
|
|
1814
1953
|
exports.heatmapTable = heatmapTable;
|
|
1815
1954
|
exports.histogramTable = histogramTable;
|
|
1955
|
+
exports.isGhostSeries = isGhostSeries;
|
|
1816
1956
|
exports.itemLabelLookup = itemLabelLookup;
|
|
1817
1957
|
exports.legendCenter = legendCenter;
|
|
1818
1958
|
exports.lightChartColors = lightChartColors;
|
|
@@ -1828,6 +1968,8 @@ exports.resolveChartHeight = resolveChartHeight;
|
|
|
1828
1968
|
exports.resolveValueFormatter = resolveValueFormatter;
|
|
1829
1969
|
exports.sankeyTable = sankeyTable;
|
|
1830
1970
|
exports.scatterTable = scatterTable;
|
|
1971
|
+
exports.selectionSet = selectionSet;
|
|
1972
|
+
exports.selectionShowsSymbols = selectionShowsSymbols;
|
|
1831
1973
|
exports.seriesLabelLookup = seriesLabelLookup;
|
|
1832
1974
|
exports.sliceTable = sliceTable;
|
|
1833
1975
|
exports.stackTotals = stackTotals;
|
|
@@ -1844,6 +1986,12 @@ exports.withEndLabelInset = withEndLabelInset;
|
|
|
1844
1986
|
exports.withForecastBars = withForecastBars;
|
|
1845
1987
|
exports.withForecastLines = withForecastLines;
|
|
1846
1988
|
exports.withForecastPoints = withForecastPoints;
|
|
1989
|
+
exports.withGhostSeries = withGhostSeries;
|
|
1847
1990
|
exports.withPointLabels = withPointLabels;
|
|
1848
1991
|
exports.withReferenceMarks = withReferenceMarks;
|
|
1992
|
+
exports.withSelectedBars = withSelectedBars;
|
|
1993
|
+
exports.withSelectedPoints = withSelectedPoints;
|
|
1994
|
+
exports.withSelectedSlices = withSelectedSlices;
|
|
1995
|
+
exports.withSelectionDescription = withSelectionDescription;
|
|
1849
1996
|
exports.withZoomInset = withZoomInset;
|
|
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, 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,97 @@ 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
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Ghost series: a faded reference drawn beside the real data, such as the
|
|
221
|
+
* prior period in a period-over-period comparison. Lines and areas draw
|
|
222
|
+
* dashed and faded with no fill or points; bars draw faded beside the solid
|
|
223
|
+
* ones (in a parallel stack group) rather than stacked onto them. Ghost
|
|
224
|
+
* series carry no value labels and are left out of bar totals.
|
|
225
|
+
*/
|
|
226
|
+
type AnyObject$2 = Record<string, any>;
|
|
227
|
+
/** The variant field a series may carry */
|
|
228
|
+
interface GhostSource {
|
|
229
|
+
variant?: 'ghost';
|
|
230
|
+
}
|
|
231
|
+
/** Opacity of a ghost line, its points and its legend icon */
|
|
232
|
+
declare const GHOST_LINE_OPACITY = 0.6;
|
|
233
|
+
/** Opacity of ghost bars */
|
|
234
|
+
declare const GHOST_BAR_OPACITY = 0.35;
|
|
235
|
+
/** Whether a series is a ghost (faded reference) series */
|
|
236
|
+
declare function isGhostSeries(source: GhostSource | undefined): boolean;
|
|
237
|
+
/** Whether any series is a ghost series */
|
|
238
|
+
declare function hasGhostSeries(series: readonly GhostSource[] | undefined): boolean;
|
|
239
|
+
/** The series that are not ghosts (for totals and value labels) */
|
|
240
|
+
declare function withoutGhostSeries<S extends GhostSource>(series: readonly S[]): S[];
|
|
241
|
+
/**
|
|
242
|
+
* A series' stack id, moved into a parallel group for ghost series so they
|
|
243
|
+
* stack among themselves (side by side with the real stack) and never onto
|
|
244
|
+
* real series. Unstacked series stay unstacked.
|
|
245
|
+
*/
|
|
246
|
+
declare function ghostStackId(stack: string | undefined, source: GhostSource | undefined): string | undefined;
|
|
247
|
+
/**
|
|
248
|
+
* Restyle the ECharts series built for ghost sources (matched by index):
|
|
249
|
+
*
|
|
250
|
+
* - line (and area) series: dashed, faded line and points, no area fill,
|
|
251
|
+
* no points by default, drawn under the real series
|
|
252
|
+
* - bar series: same colour at {@link GHOST_BAR_OPACITY}, in a parallel
|
|
253
|
+
* stack group so they pair side by side with the real bars
|
|
254
|
+
*
|
|
255
|
+
* Ghost series lose their value labels (series and per-point). Series
|
|
256
|
+
* without a ghost source are returned unchanged. Apply after building the
|
|
257
|
+
* series and before reference marks, forecast lines or totals are added.
|
|
258
|
+
*/
|
|
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;
|
|
218
308
|
|
|
219
309
|
/**
|
|
220
310
|
* Builders for the label, axis, tooltip and legend parts of a chart option.
|
|
@@ -515,10 +605,12 @@ interface WaterfallBar {
|
|
|
515
605
|
declare function waterfallLayout(steps: WaterfallStep[]): WaterfallBar[];
|
|
516
606
|
/**
|
|
517
607
|
* Convert stacked series to each category's share of 100%. Missing values
|
|
518
|
-
* stay missing; a category whose values sum to zero gets zeros.
|
|
608
|
+
* stay missing; a category whose values sum to zero gets zeros. Ghost
|
|
609
|
+
* series (`variant: 'ghost'`) share their own 100%, apart from the rest.
|
|
519
610
|
*/
|
|
520
611
|
declare function toPercentStack<S extends {
|
|
521
612
|
data: (number | null)[];
|
|
613
|
+
variant?: 'ghost';
|
|
522
614
|
}>(series: S[]): S[];
|
|
523
615
|
/**
|
|
524
616
|
* Each stack's total by category, keyed by stack id. A series stacks under
|
|
@@ -744,4 +836,4 @@ declare function downloadFile(content: string, filename: string, mimeType?: stri
|
|
|
744
836
|
*/
|
|
745
837
|
declare function downloadCsv(table: ChartDataTable, filename: string): void;
|
|
746
838
|
|
|
747
|
-
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, 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, gridInset, hasForecast, hasPointLabels, heatmapTable, histogramTable, 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, withPointLabels, withReferenceMarks, withZoomInset };
|
|
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, 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,97 @@ 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
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Ghost series: a faded reference drawn beside the real data, such as the
|
|
221
|
+
* prior period in a period-over-period comparison. Lines and areas draw
|
|
222
|
+
* dashed and faded with no fill or points; bars draw faded beside the solid
|
|
223
|
+
* ones (in a parallel stack group) rather than stacked onto them. Ghost
|
|
224
|
+
* series carry no value labels and are left out of bar totals.
|
|
225
|
+
*/
|
|
226
|
+
type AnyObject$2 = Record<string, any>;
|
|
227
|
+
/** The variant field a series may carry */
|
|
228
|
+
interface GhostSource {
|
|
229
|
+
variant?: 'ghost';
|
|
230
|
+
}
|
|
231
|
+
/** Opacity of a ghost line, its points and its legend icon */
|
|
232
|
+
declare const GHOST_LINE_OPACITY = 0.6;
|
|
233
|
+
/** Opacity of ghost bars */
|
|
234
|
+
declare const GHOST_BAR_OPACITY = 0.35;
|
|
235
|
+
/** Whether a series is a ghost (faded reference) series */
|
|
236
|
+
declare function isGhostSeries(source: GhostSource | undefined): boolean;
|
|
237
|
+
/** Whether any series is a ghost series */
|
|
238
|
+
declare function hasGhostSeries(series: readonly GhostSource[] | undefined): boolean;
|
|
239
|
+
/** The series that are not ghosts (for totals and value labels) */
|
|
240
|
+
declare function withoutGhostSeries<S extends GhostSource>(series: readonly S[]): S[];
|
|
241
|
+
/**
|
|
242
|
+
* A series' stack id, moved into a parallel group for ghost series so they
|
|
243
|
+
* stack among themselves (side by side with the real stack) and never onto
|
|
244
|
+
* real series. Unstacked series stay unstacked.
|
|
245
|
+
*/
|
|
246
|
+
declare function ghostStackId(stack: string | undefined, source: GhostSource | undefined): string | undefined;
|
|
247
|
+
/**
|
|
248
|
+
* Restyle the ECharts series built for ghost sources (matched by index):
|
|
249
|
+
*
|
|
250
|
+
* - line (and area) series: dashed, faded line and points, no area fill,
|
|
251
|
+
* no points by default, drawn under the real series
|
|
252
|
+
* - bar series: same colour at {@link GHOST_BAR_OPACITY}, in a parallel
|
|
253
|
+
* stack group so they pair side by side with the real bars
|
|
254
|
+
*
|
|
255
|
+
* Ghost series lose their value labels (series and per-point). Series
|
|
256
|
+
* without a ghost source are returned unchanged. Apply after building the
|
|
257
|
+
* series and before reference marks, forecast lines or totals are added.
|
|
258
|
+
*/
|
|
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;
|
|
218
308
|
|
|
219
309
|
/**
|
|
220
310
|
* Builders for the label, axis, tooltip and legend parts of a chart option.
|
|
@@ -515,10 +605,12 @@ interface WaterfallBar {
|
|
|
515
605
|
declare function waterfallLayout(steps: WaterfallStep[]): WaterfallBar[];
|
|
516
606
|
/**
|
|
517
607
|
* Convert stacked series to each category's share of 100%. Missing values
|
|
518
|
-
* stay missing; a category whose values sum to zero gets zeros.
|
|
608
|
+
* stay missing; a category whose values sum to zero gets zeros. Ghost
|
|
609
|
+
* series (`variant: 'ghost'`) share their own 100%, apart from the rest.
|
|
519
610
|
*/
|
|
520
611
|
declare function toPercentStack<S extends {
|
|
521
612
|
data: (number | null)[];
|
|
613
|
+
variant?: 'ghost';
|
|
522
614
|
}>(series: S[]): S[];
|
|
523
615
|
/**
|
|
524
616
|
* Each stack's total by category, keyed by stack id. A series stacks under
|
|
@@ -744,4 +836,4 @@ declare function downloadFile(content: string, filename: string, mimeType?: stri
|
|
|
744
836
|
*/
|
|
745
837
|
declare function downloadCsv(table: ChartDataTable, filename: string): void;
|
|
746
838
|
|
|
747
|
-
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, 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, gridInset, hasForecast, hasPointLabels, heatmapTable, histogramTable, 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, withPointLabels, withReferenceMarks, withZoomInset };
|
|
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
|
@@ -485,6 +485,133 @@ function mergeChartOption(generated, override) {
|
|
|
485
485
|
return merged;
|
|
486
486
|
}
|
|
487
487
|
|
|
488
|
+
// src/utils/ghost.ts
|
|
489
|
+
var GHOST_LINE_OPACITY = 0.6;
|
|
490
|
+
var GHOST_BAR_OPACITY = 0.35;
|
|
491
|
+
var GHOST_STACK = "\0ghost";
|
|
492
|
+
function isGhostSeries(source) {
|
|
493
|
+
return source?.variant === "ghost";
|
|
494
|
+
}
|
|
495
|
+
function hasGhostSeries(series) {
|
|
496
|
+
return !!series?.some(isGhostSeries);
|
|
497
|
+
}
|
|
498
|
+
function withoutGhostSeries(series) {
|
|
499
|
+
return series.filter((s) => !isGhostSeries(s));
|
|
500
|
+
}
|
|
501
|
+
function ghostStackId(stack, source) {
|
|
502
|
+
if (stack === void 0 || !isGhostSeries(source) || stack.endsWith(GHOST_STACK)) return stack;
|
|
503
|
+
return `${stack}${GHOST_STACK}`;
|
|
504
|
+
}
|
|
505
|
+
var isPlainObject3 = (item) => typeof item === "object" && item !== null && !Array.isArray(item);
|
|
506
|
+
function withoutItemLabels(data) {
|
|
507
|
+
if (!Array.isArray(data)) return data;
|
|
508
|
+
return data.map(
|
|
509
|
+
(item) => isPlainObject3(item) && item.label ? { ...item, label: { ...item.label, show: false } } : item
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
function withGhostSeries(series, sources) {
|
|
513
|
+
if (!hasGhostSeries(sources)) return series;
|
|
514
|
+
return series.map((s, index) => {
|
|
515
|
+
const source = sources[index];
|
|
516
|
+
if (!isGhostSeries(source)) return s;
|
|
517
|
+
const common = {
|
|
518
|
+
...s,
|
|
519
|
+
stack: ghostStackId(s.stack, source),
|
|
520
|
+
data: withoutItemLabels(s.data),
|
|
521
|
+
label: { ...s.label, show: false }
|
|
522
|
+
};
|
|
523
|
+
if (s.type === "bar") {
|
|
524
|
+
return {
|
|
525
|
+
...common,
|
|
526
|
+
itemStyle: { ...s.itemStyle, opacity: GHOST_BAR_OPACITY },
|
|
527
|
+
emphasis: {
|
|
528
|
+
...s.emphasis,
|
|
529
|
+
itemStyle: { ...s.emphasis?.itemStyle, opacity: GHOST_BAR_OPACITY + 0.2 }
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
...common,
|
|
535
|
+
showSymbol: false,
|
|
536
|
+
areaStyle: void 0,
|
|
537
|
+
lineStyle: { ...s.lineStyle, type: "dashed", opacity: GHOST_LINE_OPACITY },
|
|
538
|
+
itemStyle: { ...s.itemStyle, opacity: GHOST_LINE_OPACITY },
|
|
539
|
+
emphasis: {
|
|
540
|
+
...s.emphasis,
|
|
541
|
+
areaStyle: void 0
|
|
542
|
+
},
|
|
543
|
+
z: (s.z ?? 2) - 1
|
|
544
|
+
};
|
|
545
|
+
});
|
|
546
|
+
}
|
|
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
|
+
|
|
488
615
|
// src/utils/stats.ts
|
|
489
616
|
var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
490
617
|
var clean = (value) => Number(value.toPrecision(12));
|
|
@@ -637,20 +764,26 @@ function waterfallLayout(steps) {
|
|
|
637
764
|
}
|
|
638
765
|
function toPercentStack(series) {
|
|
639
766
|
const length = Math.max(0, ...series.map((s) => s.data.length));
|
|
640
|
-
const
|
|
767
|
+
const sumOf = (ghost) => Array.from(
|
|
641
768
|
{ length },
|
|
642
769
|
(_, index) => series.reduce((sum, s) => {
|
|
770
|
+
if (s.variant === "ghost" !== ghost) return sum;
|
|
643
771
|
const value = s.data[index];
|
|
644
772
|
return sum + (isFiniteNumber(value) ? Math.abs(value) : 0);
|
|
645
773
|
}, 0)
|
|
646
774
|
);
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
775
|
+
const totals = sumOf(false);
|
|
776
|
+
const ghostTotals = sumOf(true);
|
|
777
|
+
return series.map((s) => {
|
|
778
|
+
const sums = s.variant === "ghost" ? ghostTotals : totals;
|
|
779
|
+
return {
|
|
780
|
+
...s,
|
|
781
|
+
data: s.data.map((value, index) => {
|
|
782
|
+
if (!isFiniteNumber(value)) return null;
|
|
783
|
+
return sums[index] === 0 ? 0 : clean(value / sums[index] * 100);
|
|
784
|
+
})
|
|
785
|
+
};
|
|
786
|
+
});
|
|
654
787
|
}
|
|
655
788
|
function stackTotals(series, stacked) {
|
|
656
789
|
const length = Math.max(0, ...series.map((s) => s.data.length));
|
|
@@ -1428,4 +1561,4 @@ function downloadCsv(table, filename) {
|
|
|
1428
1561
|
);
|
|
1429
1562
|
}
|
|
1430
1563
|
|
|
1431
|
-
export { DEFAULT_FORECAST_LABEL, 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, gridInset, hasForecast, hasPointLabels, heatmapTable, histogramTable, 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, withPointLabels, withReferenceMarks, withZoomInset };
|
|
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
|
@@ -33,6 +33,13 @@ interface LineSeriesData {
|
|
|
33
33
|
forecastFrom?: number;
|
|
34
34
|
/** Tooltip tag for forecast values (defaults to 'Forecast') */
|
|
35
35
|
forecastLabel?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Draw the series as a faded reference (e.g. the prior period beside the
|
|
38
|
+
* current one): lines and areas dashed and faded with no fill or points,
|
|
39
|
+
* bars faded beside the solid ones rather than stacked onto them. Ghost
|
|
40
|
+
* series carry no value labels and are left out of bar totals.
|
|
41
|
+
*/
|
|
42
|
+
variant?: 'ghost';
|
|
36
43
|
}
|
|
37
44
|
interface BarChartData {
|
|
38
45
|
/** Category labels */
|
|
@@ -63,6 +70,13 @@ interface BarSeriesData {
|
|
|
63
70
|
forecastFrom?: number;
|
|
64
71
|
/** Tooltip tag for forecast values (defaults to 'Forecast') */
|
|
65
72
|
forecastLabel?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Draw the series as a faded reference (e.g. the prior period beside the
|
|
75
|
+
* current one): lines and areas dashed and faded with no fill or points,
|
|
76
|
+
* bars faded beside the solid ones rather than stacked onto them. Ghost
|
|
77
|
+
* series carry no value labels and are left out of bar totals.
|
|
78
|
+
*/
|
|
79
|
+
variant?: 'ghost';
|
|
66
80
|
}
|
|
67
81
|
interface PieSliceData {
|
|
68
82
|
/** Slice name (shown in legend/tooltip) */
|
|
@@ -103,6 +117,13 @@ interface AreaSeriesData {
|
|
|
103
117
|
forecastFrom?: number;
|
|
104
118
|
/** Tooltip tag for forecast values (defaults to 'Forecast') */
|
|
105
119
|
forecastLabel?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Draw the series as a faded reference (e.g. the prior period beside the
|
|
122
|
+
* current one): lines and areas dashed and faded with no fill or points,
|
|
123
|
+
* bars faded beside the solid ones rather than stacked onto them. Ghost
|
|
124
|
+
* series carry no value labels and are left out of bar totals.
|
|
125
|
+
*/
|
|
126
|
+
variant?: 'ghost';
|
|
106
127
|
}
|
|
107
128
|
interface ScatterChartData {
|
|
108
129
|
/** Data series */
|
|
@@ -252,6 +273,13 @@ interface CategorySeriesData {
|
|
|
252
273
|
forecastFrom?: number;
|
|
253
274
|
/** Tooltip tag for forecast values (defaults to 'Forecast') */
|
|
254
275
|
forecastLabel?: string;
|
|
276
|
+
/**
|
|
277
|
+
* Draw the series as a faded reference (e.g. the prior period beside the
|
|
278
|
+
* current one): lines and areas dashed and faded with no fill or points,
|
|
279
|
+
* bars faded beside the solid ones rather than stacked onto them. Ghost
|
|
280
|
+
* series carry no value labels and are left out of bar totals.
|
|
281
|
+
*/
|
|
282
|
+
variant?: 'ghost';
|
|
255
283
|
}
|
|
256
284
|
interface ComboChartData {
|
|
257
285
|
/** Category labels */
|
|
@@ -814,10 +842,19 @@ interface RowHeightProps {
|
|
|
814
842
|
/** Height per category row for `height="auto"` (defaults to 28) */
|
|
815
843
|
rowHeight?: number;
|
|
816
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
|
+
}
|
|
817
854
|
/**
|
|
818
855
|
* Line chart specific props
|
|
819
856
|
*/
|
|
820
|
-
interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
857
|
+
interface LineChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
821
858
|
/** Show data labels */
|
|
822
859
|
showLabels?: boolean;
|
|
823
860
|
/** Chart data */
|
|
@@ -840,7 +877,7 @@ interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
|
|
|
840
877
|
/**
|
|
841
878
|
* Bar chart specific props
|
|
842
879
|
*/
|
|
843
|
-
interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
|
|
880
|
+
interface BarChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
|
|
844
881
|
/** Chart data */
|
|
845
882
|
data: BarChartData;
|
|
846
883
|
/**
|
|
@@ -866,7 +903,7 @@ interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProp
|
|
|
866
903
|
/**
|
|
867
904
|
* Pie chart specific props
|
|
868
905
|
*/
|
|
869
|
-
interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps {
|
|
906
|
+
interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, SelectableChartProps {
|
|
870
907
|
/** Chart data */
|
|
871
908
|
data: PieSliceData[];
|
|
872
909
|
/** Show slice labels */
|
|
@@ -892,7 +929,7 @@ interface DonutChartProps extends Omit<PieChartProps, 'innerRadius'> {
|
|
|
892
929
|
/**
|
|
893
930
|
* Area chart specific props
|
|
894
931
|
*/
|
|
895
|
-
interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
932
|
+
interface AreaChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
896
933
|
/** Show data labels */
|
|
897
934
|
showLabels?: boolean;
|
|
898
935
|
/** Chart data */
|
|
@@ -905,6 +942,8 @@ interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
|
|
|
905
942
|
connectNulls?: boolean;
|
|
906
943
|
/** Use gradient fill */
|
|
907
944
|
gradient?: boolean;
|
|
945
|
+
/** Show data points on the area's line (needed for clicks on a point) */
|
|
946
|
+
showDataPoints?: boolean;
|
|
908
947
|
/** Click event handler */
|
|
909
948
|
onClick?: (params: DataPointEventParams) => void;
|
|
910
949
|
/** Hover event handler */
|
|
@@ -1198,6 +1237,34 @@ interface StatDelta {
|
|
|
1198
1237
|
/** Text after the change, e.g. 'vs last year' */
|
|
1199
1238
|
label?: string;
|
|
1200
1239
|
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Delta text: the change between two values as a coloured ▲/▼ with the
|
|
1242
|
+
* change and a "vs previous" label (the change line of `StatCard`, for KPI
|
|
1243
|
+
* rows, table cells and other inline use). Renders nothing when either value
|
|
1244
|
+
* is missing.
|
|
1245
|
+
*/
|
|
1246
|
+
interface DeltaTextProps {
|
|
1247
|
+
/** The current value */
|
|
1248
|
+
current: number | null | undefined;
|
|
1249
|
+
/** The value being compared against (e.g. last year's) */
|
|
1250
|
+
previous: number | null | undefined;
|
|
1251
|
+
/**
|
|
1252
|
+
* How the change is shown: 'percent' (+12%), 'absolute' (+12, using
|
|
1253
|
+
* `valueFormat`) or 'both' (defaults to 'percent'). A change from zero
|
|
1254
|
+
* has no percentage, so it shows the absolute change.
|
|
1255
|
+
*/
|
|
1256
|
+
display?: 'percent' | 'absolute' | 'both';
|
|
1257
|
+
/** Which direction is good, for colouring (defaults to 'up'); 'none' stays neutral */
|
|
1258
|
+
goodWhen?: 'up' | 'down' | 'none';
|
|
1259
|
+
/** How absolute changes and the previous value are written */
|
|
1260
|
+
valueFormat?: ValueFormat;
|
|
1261
|
+
/** Locale for `valueFormat` and the percentage (defaults to 'en-US') */
|
|
1262
|
+
locale?: string;
|
|
1263
|
+
/** Text after the change (defaults to 'vs <previous>'; '' hides it) */
|
|
1264
|
+
label?: string;
|
|
1265
|
+
/** Custom CSS class */
|
|
1266
|
+
class?: string;
|
|
1267
|
+
}
|
|
1201
1268
|
/**
|
|
1202
1269
|
* Stat card: a headline metric with its change and trend
|
|
1203
1270
|
*/
|
|
@@ -1232,4 +1299,4 @@ interface StatCardProps {
|
|
|
1232
1299
|
class?: string;
|
|
1233
1300
|
}
|
|
1234
1301
|
|
|
1235
|
-
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, 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
|
@@ -33,6 +33,13 @@ interface LineSeriesData {
|
|
|
33
33
|
forecastFrom?: number;
|
|
34
34
|
/** Tooltip tag for forecast values (defaults to 'Forecast') */
|
|
35
35
|
forecastLabel?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Draw the series as a faded reference (e.g. the prior period beside the
|
|
38
|
+
* current one): lines and areas dashed and faded with no fill or points,
|
|
39
|
+
* bars faded beside the solid ones rather than stacked onto them. Ghost
|
|
40
|
+
* series carry no value labels and are left out of bar totals.
|
|
41
|
+
*/
|
|
42
|
+
variant?: 'ghost';
|
|
36
43
|
}
|
|
37
44
|
interface BarChartData {
|
|
38
45
|
/** Category labels */
|
|
@@ -63,6 +70,13 @@ interface BarSeriesData {
|
|
|
63
70
|
forecastFrom?: number;
|
|
64
71
|
/** Tooltip tag for forecast values (defaults to 'Forecast') */
|
|
65
72
|
forecastLabel?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Draw the series as a faded reference (e.g. the prior period beside the
|
|
75
|
+
* current one): lines and areas dashed and faded with no fill or points,
|
|
76
|
+
* bars faded beside the solid ones rather than stacked onto them. Ghost
|
|
77
|
+
* series carry no value labels and are left out of bar totals.
|
|
78
|
+
*/
|
|
79
|
+
variant?: 'ghost';
|
|
66
80
|
}
|
|
67
81
|
interface PieSliceData {
|
|
68
82
|
/** Slice name (shown in legend/tooltip) */
|
|
@@ -103,6 +117,13 @@ interface AreaSeriesData {
|
|
|
103
117
|
forecastFrom?: number;
|
|
104
118
|
/** Tooltip tag for forecast values (defaults to 'Forecast') */
|
|
105
119
|
forecastLabel?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Draw the series as a faded reference (e.g. the prior period beside the
|
|
122
|
+
* current one): lines and areas dashed and faded with no fill or points,
|
|
123
|
+
* bars faded beside the solid ones rather than stacked onto them. Ghost
|
|
124
|
+
* series carry no value labels and are left out of bar totals.
|
|
125
|
+
*/
|
|
126
|
+
variant?: 'ghost';
|
|
106
127
|
}
|
|
107
128
|
interface ScatterChartData {
|
|
108
129
|
/** Data series */
|
|
@@ -252,6 +273,13 @@ interface CategorySeriesData {
|
|
|
252
273
|
forecastFrom?: number;
|
|
253
274
|
/** Tooltip tag for forecast values (defaults to 'Forecast') */
|
|
254
275
|
forecastLabel?: string;
|
|
276
|
+
/**
|
|
277
|
+
* Draw the series as a faded reference (e.g. the prior period beside the
|
|
278
|
+
* current one): lines and areas dashed and faded with no fill or points,
|
|
279
|
+
* bars faded beside the solid ones rather than stacked onto them. Ghost
|
|
280
|
+
* series carry no value labels and are left out of bar totals.
|
|
281
|
+
*/
|
|
282
|
+
variant?: 'ghost';
|
|
255
283
|
}
|
|
256
284
|
interface ComboChartData {
|
|
257
285
|
/** Category labels */
|
|
@@ -814,10 +842,19 @@ interface RowHeightProps {
|
|
|
814
842
|
/** Height per category row for `height="auto"` (defaults to 28) */
|
|
815
843
|
rowHeight?: number;
|
|
816
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
|
+
}
|
|
817
854
|
/**
|
|
818
855
|
* Line chart specific props
|
|
819
856
|
*/
|
|
820
|
-
interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
857
|
+
interface LineChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
821
858
|
/** Show data labels */
|
|
822
859
|
showLabels?: boolean;
|
|
823
860
|
/** Chart data */
|
|
@@ -840,7 +877,7 @@ interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
|
|
|
840
877
|
/**
|
|
841
878
|
* Bar chart specific props
|
|
842
879
|
*/
|
|
843
|
-
interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
|
|
880
|
+
interface BarChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
|
|
844
881
|
/** Chart data */
|
|
845
882
|
data: BarChartData;
|
|
846
883
|
/**
|
|
@@ -866,7 +903,7 @@ interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProp
|
|
|
866
903
|
/**
|
|
867
904
|
* Pie chart specific props
|
|
868
905
|
*/
|
|
869
|
-
interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps {
|
|
906
|
+
interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, SelectableChartProps {
|
|
870
907
|
/** Chart data */
|
|
871
908
|
data: PieSliceData[];
|
|
872
909
|
/** Show slice labels */
|
|
@@ -892,7 +929,7 @@ interface DonutChartProps extends Omit<PieChartProps, 'innerRadius'> {
|
|
|
892
929
|
/**
|
|
893
930
|
* Area chart specific props
|
|
894
931
|
*/
|
|
895
|
-
interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
932
|
+
interface AreaChartProps extends BaseChartProps, SelectableChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
|
|
896
933
|
/** Show data labels */
|
|
897
934
|
showLabels?: boolean;
|
|
898
935
|
/** Chart data */
|
|
@@ -905,6 +942,8 @@ interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
|
|
|
905
942
|
connectNulls?: boolean;
|
|
906
943
|
/** Use gradient fill */
|
|
907
944
|
gradient?: boolean;
|
|
945
|
+
/** Show data points on the area's line (needed for clicks on a point) */
|
|
946
|
+
showDataPoints?: boolean;
|
|
908
947
|
/** Click event handler */
|
|
909
948
|
onClick?: (params: DataPointEventParams) => void;
|
|
910
949
|
/** Hover event handler */
|
|
@@ -1198,6 +1237,34 @@ interface StatDelta {
|
|
|
1198
1237
|
/** Text after the change, e.g. 'vs last year' */
|
|
1199
1238
|
label?: string;
|
|
1200
1239
|
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Delta text: the change between two values as a coloured ▲/▼ with the
|
|
1242
|
+
* change and a "vs previous" label (the change line of `StatCard`, for KPI
|
|
1243
|
+
* rows, table cells and other inline use). Renders nothing when either value
|
|
1244
|
+
* is missing.
|
|
1245
|
+
*/
|
|
1246
|
+
interface DeltaTextProps {
|
|
1247
|
+
/** The current value */
|
|
1248
|
+
current: number | null | undefined;
|
|
1249
|
+
/** The value being compared against (e.g. last year's) */
|
|
1250
|
+
previous: number | null | undefined;
|
|
1251
|
+
/**
|
|
1252
|
+
* How the change is shown: 'percent' (+12%), 'absolute' (+12, using
|
|
1253
|
+
* `valueFormat`) or 'both' (defaults to 'percent'). A change from zero
|
|
1254
|
+
* has no percentage, so it shows the absolute change.
|
|
1255
|
+
*/
|
|
1256
|
+
display?: 'percent' | 'absolute' | 'both';
|
|
1257
|
+
/** Which direction is good, for colouring (defaults to 'up'); 'none' stays neutral */
|
|
1258
|
+
goodWhen?: 'up' | 'down' | 'none';
|
|
1259
|
+
/** How absolute changes and the previous value are written */
|
|
1260
|
+
valueFormat?: ValueFormat;
|
|
1261
|
+
/** Locale for `valueFormat` and the percentage (defaults to 'en-US') */
|
|
1262
|
+
locale?: string;
|
|
1263
|
+
/** Text after the change (defaults to 'vs <previous>'; '' hides it) */
|
|
1264
|
+
label?: string;
|
|
1265
|
+
/** Custom CSS class */
|
|
1266
|
+
class?: string;
|
|
1267
|
+
}
|
|
1201
1268
|
/**
|
|
1202
1269
|
* Stat card: a headline metric with its change and trend
|
|
1203
1270
|
*/
|
|
@@ -1232,4 +1299,4 @@ interface StatCardProps {
|
|
|
1232
1299
|
class?: string;
|
|
1233
1300
|
}
|
|
1234
1301
|
|
|
1235
|
-
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, 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 };
|