@vuu-ui/vuu-chart 4.0.0-beta.7 → 4.0.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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.0.0-beta.7",
2
+ "version": "4.0.0",
3
3
  "description": "support for apache echarts using vuu data",
4
4
  "main": "./src/index.js",
5
5
  "license": "Apache-2.0",
@@ -9,16 +9,16 @@
9
9
  "type-defs": "node ../../scripts/build-type-defs.mjs"
10
10
  },
11
11
  "devDependencies": {
12
- "@vuu-ui/vuu-data-types": "4.0.0-beta.7",
13
- "@vuu-ui/vuu-protocol-types": "4.0.0-beta.7",
14
- "@vuu-ui/vuu-data-local": "4.0.0-beta.7"
12
+ "@vuu-ui/vuu-data-types": "4.0.0",
13
+ "@vuu-ui/vuu-protocol-types": "4.0.0",
14
+ "@vuu-ui/vuu-data-local": "4.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@salt-ds/styles": "0.4.1",
17
+ "@salt-ds/styles": "0.4.2",
18
18
  "@salt-ds/window": "0.1.2",
19
- "@vuu-ui/vuu-context-menu": "4.0.0-beta.7",
20
- "@vuu-ui/vuu-ui-controls": "4.0.0-beta.7",
21
- "@vuu-ui/vuu-utils": "4.0.0-beta.7",
19
+ "@vuu-ui/vuu-context-menu": "4.0.0",
20
+ "@vuu-ui/vuu-ui-controls": "4.0.0",
21
+ "@vuu-ui/vuu-utils": "4.0.0",
22
22
  "clsx": "^2.0.0",
23
23
  "echarts": "6.1.0"
24
24
  },
package/src/Chart.js CHANGED
@@ -61,12 +61,14 @@ const Chart_Chart = ({ categoryColumnName, chartSettings = {
61
61
  useEffect(()=>{
62
62
  if (!chartElement) return;
63
63
  const chart = init(chartElement, null, chartSettings);
64
+ chartElement.echartsInstance = chart;
64
65
  chart.on("contextmenu", onContextMenu);
65
66
  chart.on("click", onClick);
66
67
  chart.on("mouseover", onMouseOver);
67
68
  chart.on("mouseout", onMouseOut);
68
69
  return ()=>{
69
70
  chart?.dispose();
71
+ delete chartElement.echartsInstance;
70
72
  };
71
73
  }, [
72
74
  chartElement,
@@ -120,7 +120,8 @@ class ChartSeries extends EventEmitter {
120
120
  name: seriesColumn,
121
121
  symbol,
122
122
  symbolSize: 20,
123
- type: "scatter"
123
+ type: "scatter",
124
+ z: 3
124
125
  };
125
126
  }
126
127
  if (scatterSeries) seriesMap.set(seriesColumn, [
@@ -0,0 +1,53 @@
1
+ import type { DataSource, DataSourceRow, DataSourceSubscribeCallback } from "@vuu-ui/vuu-data-types";
2
+ import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
+ import { type ColumnMap, EventEmitter } from "@vuu-ui/vuu-utils";
4
+ export declare const DEFAULT_MAX_ROWS = 1000;
5
+ export type ChartDataStoreEvents = {
6
+ update: () => void;
7
+ };
8
+ export interface ChartDataStoreOptions {
9
+ /**
10
+ * The number of rows requested from the DataSource (the viewport range
11
+ * will be 0 - maxRows). Default 1000.
12
+ */
13
+ maxRows?: number;
14
+ }
15
+ /**
16
+ * Subscribes to a single DataSource and keeps a dense, index-ordered copy of
17
+ * the rows within the subscribed range. Emits 'update' whenever rows or size
18
+ * change. Consumers (chart projections) read `rows` and `columnMap`.
19
+ *
20
+ * A DataSource supports a single subscriber, so each DataSource used by a
21
+ * chart should not be shared with another component (e.g. a Table).
22
+ */
23
+ export declare class ChartDataStore extends EventEmitter<ChartDataStoreEvents> {
24
+ #private;
25
+ constructor(dataSource: DataSource, { maxRows }?: ChartDataStoreOptions);
26
+ get columnMap(): ColumnMap;
27
+ get dataSource(): DataSource;
28
+ get isSubscribed(): boolean;
29
+ /**
30
+ * The rows currently held, in DataSource (index) order, with no gaps.
31
+ */
32
+ get rows(): DataSourceRow[];
33
+ get size(): number;
34
+ /**
35
+ * Incremented on every change, can be used to cheaply detect changes.
36
+ */
37
+ get version(): number;
38
+ getValue(row: DataSourceRow, columnName: string): VuuRowDataItemType | undefined;
39
+ subscribe(): void;
40
+ dispose(): void;
41
+ private changed;
42
+ handleData: DataSourceSubscribeCallback;
43
+ }
44
+ /**
45
+ * Manages one ChartDataStore per distinct DataSource instance.
46
+ */
47
+ export declare class ChartDataStores {
48
+ #private;
49
+ constructor(dataSources: DataSource[], options: ChartDataStoreOptions, onUpdate: () => void);
50
+ get(dataSource: DataSource): ChartDataStore;
51
+ subscribe(): void;
52
+ dispose(): void;
53
+ }
@@ -0,0 +1,28 @@
1
+ import type { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
+ import type { ColumnMap } from "@vuu-ui/vuu-utils";
4
+ import type { ChartTheme } from "../theme/chartTheme";
5
+ import type { Aggregation, ColorBy, MarkLineDef, RowMatch } from "../vuu-chart-types";
6
+ export declare const toNumber: (value: VuuRowDataItemType | bigint | undefined) => number | null;
7
+ export declare const getColumnValue: (row: DataSourceRow, columnMap: ColumnMap, columnName: string) => VuuRowDataItemType | undefined;
8
+ export declare const getNumber: (row: DataSourceRow, columnMap: ColumnMap, columnName: string) => number | null;
9
+ export declare const filterRows: (rows: DataSourceRow[], columnMap: ColumnMap, where?: RowMatch) => DataSourceRow[];
10
+ /**
11
+ * Returns rows sorted (stable) by a numeric column, ascending. If rows
12
+ * are already in order (the common case, when the DataSource is sorted),
13
+ * the original array is returned.
14
+ */
15
+ export declare const sortRowsByNumber: (rows: DataSourceRow[], columnMap: ColumnMap, columnName: string, descending?: boolean) => DataSourceRow[];
16
+ export declare const colorForRow: (row: DataSourceRow, columnMap: ColumnMap, colorBy: ColorBy, theme: ChartTheme) => string | undefined;
17
+ export declare class Aggregator {
18
+ #private;
19
+ count: number;
20
+ constructor(aggregation: Aggregation);
21
+ add(value: number | null): void;
22
+ get value(): number | null;
23
+ }
24
+ export declare const computeMarkLineValue: (def: MarkLineDef, values: Array<number | null>, weights?: Array<number | null>) => number | null;
25
+ /**
26
+ * Binary search, returns the index of the last value <= target, or -1.
27
+ */
28
+ export declare const findFloorIndex: (sortedValues: number[], target: number) => number;
@@ -37,6 +37,7 @@ export interface LineSeries extends SeriesBase {
37
37
  }
38
38
  export interface ScatterSeries extends SeriesBase {
39
39
  type: "scatter";
40
+ z?: number;
40
41
  }
41
42
  export type Series = LineSeries | ScatterSeries;
42
43
  export type ChartSelectionModel = "none" | "single" | "single-no-deselect" | "extended";
@@ -0,0 +1,9 @@
1
+ import type { VuuChartBaseProps } from "../vuu-chart-types";
2
+ import { type CandlestickChartOptions } from "./candlestick-model";
3
+ export interface CandlestickChartProps extends Omit<VuuChartBaseProps, "legend">, CandlestickChartOptions {
4
+ }
5
+ /**
6
+ * OHLC candlestick chart with optional volume pane and overlay series
7
+ * (e.g. a vwap line, or fills as scatter markers from a second DataSource).
8
+ */
9
+ export declare const CandlestickChart: ({ crosshair, dataSource, dataZoom, formatTime, legend, markLines, ohlcColumnNames, overlays, showTooltip, timeColumnName, volumeColumnName, volumePaneHeight, xAxisType, ...props }: CandlestickChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { VuuChartBaseProps } from "../vuu-chart-types";
2
+ import { type CartesianChartOptions } from "./cartesian-model";
3
+ export interface CartesianChartProps extends Omit<VuuChartBaseProps, "legend">, CartesianChartOptions {
4
+ }
5
+ /**
6
+ * Line, area (including stepped), bar (vertical, horizontal, stacked) and
7
+ * scatter series, on a category, time or value x axis. Series may be read
8
+ * from multiple DataSources.
9
+ */
10
+ export declare const CartesianChart: ({ aggregation, crosshair, dataSource, dataZoom, legend, orientation, series, showTooltip, xAxis, yAxes, ...props }: CartesianChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { VuuChartBaseProps } from "../vuu-chart-types";
2
+ import { type DepthChartOptions } from "./depth-model";
3
+ export interface DepthChartProps extends Omit<VuuChartBaseProps, "legend">, DepthChartOptions {
4
+ }
5
+ /**
6
+ * Market depth chart: stepped cumulative bid and ask areas, by price.
7
+ */
8
+ export declare const DepthChart: ({ askValue, bidValue, cumulativeSizeColumnName, dataSource, legend, priceColumnName, showMidPrice, showTooltip, sideColumnName, sizeColumnName, ...props }: DepthChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import type { VuuChartBaseProps } from "../vuu-chart-types";
2
+ import { type HeatmapChartOptions } from "./heatmap-model";
3
+ export interface HeatmapChartProps extends Omit<VuuChartBaseProps, "legend">, HeatmapChartOptions {
4
+ }
5
+ /**
6
+ * Heatmap of a value column by two dimensions, e.g. traded quantity by
7
+ * price level and time bucket.
8
+ */
9
+ export declare const HeatmapChart: ({ aggregation, colorScale, dataSource, dataZoom, formatTime, max, min, showTooltip, showVisualMap, valueColumnName, where, xAxis, yAxis, ...props }: HeatmapChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import type { VuuChartBaseProps } from "../vuu-chart-types";
2
+ import { type HierarchyChartOptions } from "./hierarchy-model";
3
+ export interface HierarchyChartProps extends Omit<VuuChartBaseProps, "legend">, HierarchyChartOptions {
4
+ }
5
+ /**
6
+ * Treemap, sunburst or pie breakdown of a value column, grouped by one or
7
+ * more columns e.g. exposure by sector -> ric.
8
+ */
9
+ export declare const HierarchyChart: ({ aggregation, colorMode, dataSource, donut, formatValue, groupByColumnNames, legend, showTooltip, type, valueColumnName, where, ...props }: HierarchyChartProps) => import("react/jsx-runtime").JSX.Element;
10
+ export type TreemapChartProps = Omit<HierarchyChartProps, "type" | "donut">;
11
+ export declare const TreemapChart: (props: TreemapChartProps) => import("react/jsx-runtime").JSX.Element;
12
+ export type SunburstChartProps = Omit<HierarchyChartProps, "type" | "donut">;
13
+ export declare const SunburstChart: (props: SunburstChartProps) => import("react/jsx-runtime").JSX.Element;
14
+ export type PieChartProps = Omit<HierarchyChartProps, "type">;
15
+ export declare const PieChart: (props: PieChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,62 @@
1
+ import type { DataSource } from "@vuu-ui/vuu-data-types";
2
+ import type { ChartModel } from "../engine/ChartModel";
3
+ import type { ColorBy, DataZoomOption, LegendPosition, MarkLineDef, RowMatch } from "../vuu-chart-types";
4
+ export interface OhlcColumnNames {
5
+ open: string;
6
+ high: string;
7
+ low: string;
8
+ close: string;
9
+ }
10
+ export interface CandlestickOverlayDef {
11
+ type: "line" | "scatter";
12
+ /** Column providing the (price) value */
13
+ columnName: string;
14
+ /** Default is columnName */
15
+ id?: string;
16
+ name?: string;
17
+ /**
18
+ * Read the overlay from a different DataSource (e.g. fills). Points are
19
+ * placed at the bar whose interval contains their timestamp.
20
+ */
21
+ dataSource?: DataSource;
22
+ /** Timestamp column of the overlay DataSource, default is timeColumnName */
23
+ timeColumnName?: string;
24
+ where?: RowMatch;
25
+ /** css colour or 'up' | 'down' | 'palette-n' */
26
+ color?: string;
27
+ colorBy?: ColorBy;
28
+ /** echarts symbol e.g 'circle', 'triangle', 'diamond', 'pin' */
29
+ symbol?: string;
30
+ symbolSize?: number;
31
+ markLines?: MarkLineDef[];
32
+ }
33
+ export interface CandlestickChartOptions {
34
+ /** Default 'both' */
35
+ dataZoom?: DataZoomOption;
36
+ /** Show axis crosshair with tooltip. Default true */
37
+ crosshair?: boolean;
38
+ /** DataSource providing OHLC bars, e.g the vuu 'bars' table */
39
+ dataSource: DataSource;
40
+ /** Formats time values (epoch millis) for axis labels */
41
+ formatTime?: (timestamp: number) => string;
42
+ legend?: LegendPosition;
43
+ /** Mark lines on the price axis, 'last' is the last close */
44
+ markLines?: MarkLineDef[];
45
+ /** Defaults to open, high, low, close */
46
+ ohlcColumnNames?: Partial<OhlcColumnNames>;
47
+ /** Additional series overlaid on the price chart */
48
+ overlays?: CandlestickOverlayDef[];
49
+ showTooltip?: boolean;
50
+ /** Bar start timestamp column (epoch millis). Default 'start' */
51
+ timeColumnName?: string;
52
+ /** If provided, volume bars are rendered in a pane below the price chart */
53
+ volumeColumnName?: string;
54
+ /** Height of the volume pane, as a percentage of chart height. Default 20 */
55
+ volumePaneHeight?: number;
56
+ /**
57
+ * 'category' (default) spaces bars evenly, with no gaps for periods
58
+ * without bars. 'time' uses a continuous time axis.
59
+ */
60
+ xAxisType?: "category" | "time";
61
+ }
62
+ export declare const createCandlestickModel: ({ crosshair, dataSource, dataZoom, formatTime, legend, markLines, ohlcColumnNames, overlays, showTooltip, timeColumnName, volumeColumnName, volumePaneHeight, xAxisType, }: CandlestickChartOptions) => ChartModel;
@@ -0,0 +1,78 @@
1
+ import type { DataSource } from "@vuu-ui/vuu-data-types";
2
+ import type { ChartModel } from "../engine/ChartModel";
3
+ import type { Aggregation, ColorBy, DataZoomOption, LegendPosition, MarkLineDef, RowMatch, XAxisType } from "../vuu-chart-types";
4
+ export type CartesianSeriesType = "line" | "area" | "bar" | "scatter";
5
+ export interface CartesianSeriesDef {
6
+ type: CartesianSeriesType;
7
+ /** Column providing the (y) value */
8
+ columnName: string;
9
+ /** Default is columnName. Used to identify series in echartsOptions overrides. */
10
+ id?: string;
11
+ /** Display name (legend/tooltip), default is columnName */
12
+ name?: string;
13
+ /**
14
+ * Read this series from a different DataSource than the chart default
15
+ * (e.g. to overlay fills on a price line).
16
+ */
17
+ dataSource?: DataSource;
18
+ /** x column, if different from the chart xAxis.columnName */
19
+ xColumnName?: string;
20
+ /** Restrict the rows used for this series e.g { side: "BUY" } */
21
+ where?: RowMatch;
22
+ /** index into yAxes, default 0 */
23
+ yAxisIndex?: number;
24
+ /** series with same stack name are stacked (bar, line, area) */
25
+ stack?: string;
26
+ /** stepped line/area */
27
+ step?: "start" | "middle" | "end";
28
+ smooth?: boolean;
29
+ /** default true for scatter, false for line/area */
30
+ showSymbol?: boolean;
31
+ symbolSize?: number;
32
+ /** css colour or 'up' | 'down' | 'palette-n' */
33
+ color?: string;
34
+ /** per point colour, by value of a column */
35
+ colorBy?: ColorBy;
36
+ /** area fill opacity (area series), default 0.25 */
37
+ areaOpacity?: number;
38
+ markLines?: MarkLineDef[];
39
+ }
40
+ export interface CartesianXAxisDef {
41
+ columnName: string;
42
+ /**
43
+ * 'time' expects epoch millisecond timestamps (vuu epochtimestamp),
44
+ * 'category' (default) uses distinct values in DataSource order,
45
+ * 'value' a numeric axis.
46
+ */
47
+ type?: XAxisType;
48
+ name?: string;
49
+ }
50
+ export interface CartesianYAxisDef {
51
+ name?: string;
52
+ position?: "left" | "right";
53
+ /** Do not force axis to include zero. Default true unless chart has bars */
54
+ scale?: boolean;
55
+ type?: "value" | "log";
56
+ min?: number;
57
+ max?: number;
58
+ }
59
+ export interface CartesianChartOptions {
60
+ /**
61
+ * Category axis only. Aggregate the values of rows that share the same
62
+ * category (e.g. sum notional by sector).
63
+ */
64
+ aggregation?: Aggregation;
65
+ /** Show axis crosshair with tooltip. Default true */
66
+ crosshair?: boolean;
67
+ dataSource: DataSource;
68
+ dataZoom?: DataZoomOption;
69
+ legend?: LegendPosition;
70
+ /** 'horizontal' places the category/x axis vertically (horizontal bars) */
71
+ orientation?: "vertical" | "horizontal";
72
+ series: CartesianSeriesDef[];
73
+ showTooltip?: boolean;
74
+ xAxis: CartesianXAxisDef;
75
+ yAxes?: CartesianYAxisDef[];
76
+ }
77
+ export declare const seriesIds: (series: CartesianSeriesDef[]) => string[];
78
+ export declare const createCartesianModel: ({ aggregation, crosshair, dataSource, dataZoom, legend, orientation, series, showTooltip, xAxis, yAxes, }: CartesianChartOptions) => ChartModel;
@@ -0,0 +1,43 @@
1
+ import type { DataSource, DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import type { ChartModel } from "../engine/ChartModel";
3
+ import type { LegendPosition } from "../vuu-chart-types";
4
+ export interface DepthChartOptions {
5
+ /** Value of sideColumnName for bids. Default 'BUY' */
6
+ bidValue?: string;
7
+ /** Value of sideColumnName for asks. Default 'SELL' */
8
+ askValue?: string;
9
+ /**
10
+ * Optional column with the cumulative size at each level (e.g. 'cumSize').
11
+ * If not provided, cumulative size is computed from sizeColumnName.
12
+ */
13
+ cumulativeSizeColumnName?: string;
14
+ /** DataSource of price levels, e.g the vuu 'depth' table */
15
+ dataSource: DataSource;
16
+ legend?: LegendPosition;
17
+ /** Default 'price' */
18
+ priceColumnName?: string;
19
+ /** Show a mark line at the mid price. Default true */
20
+ showMidPrice?: boolean;
21
+ showTooltip?: boolean;
22
+ /** Default 'side' */
23
+ sideColumnName?: string;
24
+ /** Default 'size' */
25
+ sizeColumnName?: string;
26
+ }
27
+ type Level = {
28
+ price: number;
29
+ size: number;
30
+ cum?: number;
31
+ row: DataSourceRow;
32
+ };
33
+ /**
34
+ * Builds cumulative depth points, from best price outwards. Bids are sorted
35
+ * by descending price, asks by ascending price.
36
+ */
37
+ export declare const cumulativeDepth: (levels: Level[], side: "bid" | "ask") => {
38
+ price: number;
39
+ cumSize: number;
40
+ row: DataSourceRow;
41
+ }[];
42
+ export declare const createDepthModel: ({ askValue, bidValue, cumulativeSizeColumnName, dataSource, legend, priceColumnName, showMidPrice, showTooltip, sideColumnName, sizeColumnName, }: DepthChartOptions) => ChartModel;
43
+ export {};
@@ -0,0 +1,43 @@
1
+ import type { DataSource } from "@vuu-ui/vuu-data-types";
2
+ import type { ChartModel } from "../engine/ChartModel";
3
+ import type { Aggregation, DataZoomOption, RowMatch } from "../vuu-chart-types";
4
+ export interface HeatmapAxisDef {
5
+ columnName: string;
6
+ /**
7
+ * Numeric values are rounded down to a multiple of bucketSize, e.g. 60000
8
+ * to bucket timestamps by minute, or 0.5 to bucket prices.
9
+ */
10
+ bucketSize?: number;
11
+ /**
12
+ * 'time' formats (epoch millis) values as times, 'value' sorts numeric
13
+ * values, 'category' (default for non numeric values) uses DataSource order.
14
+ */
15
+ type?: "time" | "value" | "category";
16
+ name?: string;
17
+ }
18
+ export interface HeatmapChartOptions {
19
+ /** How values falling in the same cell are combined. Default 'sum' */
20
+ aggregation?: Aggregation;
21
+ /**
22
+ * 'sequential' (default) maps low to high values onto theme.heatmapColors.
23
+ * 'diverging' maps negative values to the down colour and positive values
24
+ * to the up colour, symmetric around zero, e.g. for pnl.
25
+ */
26
+ colorScale?: "sequential" | "diverging";
27
+ dataSource: DataSource;
28
+ dataZoom?: DataZoomOption;
29
+ /** Formats time values (epoch millis) for axis labels */
30
+ formatTime?: (timestamp: number) => string;
31
+ /** Fixed visualMap range, by default computed from data */
32
+ max?: number;
33
+ min?: number;
34
+ showTooltip?: boolean;
35
+ /** Show the visualMap colour scale. Default true */
36
+ showVisualMap?: boolean;
37
+ /** Column providing the cell value. */
38
+ valueColumnName: string;
39
+ where?: RowMatch;
40
+ xAxis: HeatmapAxisDef;
41
+ yAxis: HeatmapAxisDef;
42
+ }
43
+ export declare const createHeatmapModel: ({ aggregation, colorScale, dataSource, dataZoom, formatTime, max, min, showTooltip, showVisualMap, valueColumnName, where, xAxis, yAxis, }: HeatmapChartOptions) => ChartModel;
@@ -0,0 +1,62 @@
1
+ import type { DataSource, DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import { Aggregator } from "../chart-data/projection-utils";
3
+ import { type ChartModel } from "../engine/ChartModel";
4
+ import type { Aggregation, LegendPosition, RowMatch } from "../vuu-chart-types";
5
+ export type HierarchyChartType = "treemap" | "sunburst" | "pie";
6
+ /**
7
+ * - 'palette': each top level group is assigned a palette colour
8
+ * - 'sign': node size is the absolute value, colour is up (positive) or
9
+ * down (negative), e.g. for pnl or long/short exposure
10
+ */
11
+ export type HierarchyColorMode = "palette" | "sign";
12
+ export interface HierarchyChartOptions {
13
+ /** Default 'sum' */
14
+ aggregation?: Aggregation;
15
+ /** Default 'palette' */
16
+ colorMode?: HierarchyColorMode;
17
+ dataSource: DataSource;
18
+ /**
19
+ * Columns defining the hierarchy, outermost first, e.g. ["sector", "ric"].
20
+ * Pie charts use only the first column.
21
+ */
22
+ groupByColumnNames: string[];
23
+ /** Pie chart only, renders a donut. Default false */
24
+ donut?: boolean;
25
+ /** Formats values in labels and tooltips */
26
+ formatValue?: (value: number) => string;
27
+ /** Pie only, default 'none' */
28
+ legend?: LegendPosition;
29
+ showTooltip?: boolean;
30
+ type: HierarchyChartType;
31
+ /** Column providing the value to be aggregated, e.g "notional" */
32
+ valueColumnName: string;
33
+ where?: RowMatch;
34
+ }
35
+ export interface HierarchyNode {
36
+ name: string;
37
+ /**
38
+ * size of the node, absolute value in colorMode 'sign'. For parent nodes,
39
+ * the sum of the children's sizes.
40
+ */
41
+ value: number;
42
+ /** aggregated value, which may be negative */
43
+ signedValue: number;
44
+ vuuGroupKey: string;
45
+ itemStyle?: {
46
+ color: string;
47
+ };
48
+ children?: HierarchyNode[];
49
+ }
50
+ interface GroupBuilder {
51
+ name: string;
52
+ key: string;
53
+ aggregator: Aggregator;
54
+ rows: DataSourceRow[];
55
+ children?: Map<string, GroupBuilder>;
56
+ }
57
+ /**
58
+ * Group rows by the given columns (outermost first), aggregating values.
59
+ */
60
+ export declare const buildHierarchy: (rows: DataSourceRow[], getGroupValue: (row: DataSourceRow, depth: number) => unknown, getValue: (row: DataSourceRow) => number | null, depth: number, aggregation: Aggregation) => GroupBuilder[];
61
+ export declare const createHierarchyModel: ({ aggregation, colorMode, dataSource, donut, formatValue, groupByColumnNames, legend, showTooltip, type, valueColumnName, where, }: HierarchyChartOptions) => ChartModel;
62
+ export {};
@@ -0,0 +1,2 @@
1
+ export { getInstanceByDom, init } from "echarts/core";
2
+ export type { ECElementEvent, ECharts, EChartsCoreOption, } from "echarts/core";
@@ -0,0 +1,55 @@
1
+ import type { DataSource, DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import type { ColumnMap } from "@vuu-ui/vuu-utils";
3
+ import type { EChartsCoreOption } from "echarts/core";
4
+ import type { ChartTheme } from "../theme/chartTheme";
5
+ export interface SeriesRows {
6
+ dataSource: DataSource;
7
+ /** rows, in the same order as the series data items */
8
+ rows: DataSourceRow[];
9
+ /**
10
+ * For aggregated items (e.g. hierarchy nodes), rows keyed by group key.
11
+ * Data items carry the key in a `vuuGroupKey` property.
12
+ */
13
+ groups?: Map<string, DataSourceRow[]>;
14
+ }
15
+ /** Separator used in group keys (ascii unit separator) */
16
+ export declare const GROUP_KEY_SEPARATOR = "\u001F";
17
+ export interface ChartRowData {
18
+ columnMap: ColumnMap;
19
+ /** rows in DataSource (index) order */
20
+ rows: DataSourceRow[];
21
+ }
22
+ /**
23
+ * Provides the current rows for each DataSource used by a chart.
24
+ */
25
+ export interface ChartDataLookup {
26
+ get: (dataSource: DataSource) => ChartRowData;
27
+ }
28
+ export interface ChartDataOption {
29
+ /**
30
+ * Partial option, containing only data dependent values (series data,
31
+ * category axis data, markLines, visualMap ranges). Merged (by component
32
+ * id) into the existing chart option on each data update.
33
+ */
34
+ option: EChartsCoreOption;
35
+ /** Keyed by series id, used to resolve rows for item events */
36
+ rowLookup?: Record<string, SeriesRows>;
37
+ }
38
+ /**
39
+ * Describes a chart to the chart engine. Each chart type creates a model
40
+ * from its props.
41
+ */
42
+ export interface ChartModel {
43
+ /** All DataSources that will be read by buildDataOption */
44
+ dataSources: DataSource[];
45
+ /**
46
+ * The structural option - series definitions (without data), axes, grids,
47
+ * tooltip, legend etc. Rebuilt only when props or theme change.
48
+ */
49
+ buildBaseOption: (theme: ChartTheme) => EChartsCoreOption;
50
+ /**
51
+ * Builds the data dependent part of the option from the current rows.
52
+ * Invoked at most once per animation frame while data is changing.
53
+ */
54
+ buildDataOption: (data: ChartDataLookup, theme: ChartTheme) => ChartDataOption;
55
+ }
@@ -0,0 +1,17 @@
1
+ import type { VuuChartBaseProps } from "../vuu-chart-types";
2
+ import { type ChartModel } from "./ChartModel";
3
+ export interface VuuChartContainerProps extends VuuChartBaseProps {
4
+ chartType: string;
5
+ model: ChartModel;
6
+ }
7
+ /**
8
+ * The chart engine, shared by all chart types.
9
+ *
10
+ * - creates (and disposes) the ECharts instance
11
+ * - subscribes to (and unsubscribes from) DataSources, via ChartDataStores
12
+ * - applies the full option, with notMerge, only when the chart model,
13
+ * theme or user overrides change
14
+ * - applies data updates as a partial option, merged by component id, at
15
+ * most once per animation frame, without re-rendering React
16
+ */
17
+ export declare const VuuChartContainer: ({ chartType, className, echartsOptions, height, legend: _legend, maxRows, model, onChartReady, onItemClick, onItemContextMenu, renderer, resizeStrategy, showTooltip: _showTooltip, style, theme: themeOverrides, width, ...htmlAttributes }: VuuChartContainerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Structural equality for plain objects and arrays. Class instances (e.g.
3
+ * DataSource) and functions are compared by identity.
4
+ */
5
+ export declare const isStructurallyEqual: (a: unknown, b: unknown) => boolean;
6
+ /**
7
+ * Returns the previous value if structurally equal to the new value. Allows
8
+ * consumers to pass inline object/array literals as props without causing
9
+ * the chart structure to be rebuilt on every render.
10
+ */
11
+ export declare const useStructuralMemo: <T>(value: T) => T;
@@ -0,0 +1,156 @@
1
+ import type { ChartTheme } from "../theme/chartTheme";
2
+ import type { DataZoomOption, LegendPosition, MarkLineDef } from "../vuu-chart-types";
3
+ /**
4
+ * Format an epoch millisecond timestamp for an axis label. Shows seconds
5
+ * only when present, date only at midnight.
6
+ */
7
+ export declare const formatTimeLabel: (ts: number) => string;
8
+ export declare const formatTimestamp: (ts: number) => string;
9
+ export declare const textStyle: (theme: ChartTheme) => {
10
+ color: string;
11
+ fontFamily: string;
12
+ };
13
+ export declare const GRID_OUTER_BOUNDS: {
14
+ left: number;
15
+ right: number;
16
+ top: number;
17
+ bottom: number;
18
+ };
19
+ export declare const axisStyle: (theme: ChartTheme, showSplitLine?: boolean) => {
20
+ axisLine: {
21
+ lineStyle: {
22
+ color: string;
23
+ };
24
+ };
25
+ axisTick: {
26
+ lineStyle: {
27
+ color: string;
28
+ };
29
+ };
30
+ axisLabel: {
31
+ color: string;
32
+ fontFamily: string;
33
+ hideOverlap: boolean;
34
+ };
35
+ nameTextStyle: {
36
+ color: string;
37
+ fontFamily: string;
38
+ };
39
+ splitLine: {
40
+ show: boolean;
41
+ lineStyle: {
42
+ color: string;
43
+ };
44
+ };
45
+ };
46
+ export declare const axisPointerLabel: (theme: ChartTheme) => {
47
+ backgroundColor: string;
48
+ color: string;
49
+ fontFamily: string;
50
+ };
51
+ export declare const tooltipOption: (theme: ChartTheme, { crosshair, show, trigger, }?: {
52
+ crosshair?: boolean;
53
+ show?: boolean;
54
+ trigger?: "axis" | "item";
55
+ }) => {
56
+ show: boolean;
57
+ trigger: "axis" | "item";
58
+ confine: boolean;
59
+ className: string;
60
+ backgroundColor: string;
61
+ borderColor: string;
62
+ textStyle: {
63
+ color: string;
64
+ fontFamily: string;
65
+ fontSize: number;
66
+ };
67
+ axisPointer: {
68
+ type: string;
69
+ lineStyle: {
70
+ color: string;
71
+ type: string;
72
+ };
73
+ crossStyle: {
74
+ color: string;
75
+ };
76
+ label: {
77
+ backgroundColor: string;
78
+ color: string;
79
+ fontFamily: string;
80
+ };
81
+ } | undefined;
82
+ };
83
+ export declare const legendOption: (theme: ChartTheme, position: LegendPosition) => {
84
+ show: boolean;
85
+ type?: undefined;
86
+ textStyle?: undefined;
87
+ pageTextStyle?: undefined;
88
+ } | {
89
+ [x: string]: string | number | boolean | {
90
+ color: string;
91
+ fontFamily: string;
92
+ } | {
93
+ fontFamily?: undefined;
94
+ color: string;
95
+ };
96
+ show: boolean;
97
+ type: string;
98
+ textStyle: {
99
+ color: string;
100
+ fontFamily: string;
101
+ };
102
+ pageTextStyle: {
103
+ color: string;
104
+ };
105
+ };
106
+ export declare const hasSlider: (dataZoom: DataZoomOption | undefined) => dataZoom is "both" | "slider";
107
+ export declare const dataZoomOption: (dataZoom: DataZoomOption | undefined, theme: ChartTheme, axisIndex?: number[], orientation?: "x" | "y") => Record<string, unknown>[];
108
+ /**
109
+ * Build a series markLine option from declarative mark line definitions.
110
+ * Values are computed from the current series values, so this is rebuilt
111
+ * on each data update.
112
+ */
113
+ export declare const markLineOption: (defs: MarkLineDef[] | undefined, theme: ChartTheme, values: Array<number | null>, { axis, defaultColor, weights, }?: {
114
+ axis?: "xAxis" | "yAxis";
115
+ defaultColor?: string;
116
+ weights?: Array<number | null>;
117
+ }) => {
118
+ silent: boolean;
119
+ symbol: string[];
120
+ animation: boolean;
121
+ data: {
122
+ [x: string]: string | number | {
123
+ color: string;
124
+ type: "dashed" | "dotted" | "solid";
125
+ width: number;
126
+ backgroundColor?: undefined;
127
+ padding?: undefined;
128
+ borderRadius?: undefined;
129
+ position?: undefined;
130
+ formatter?: undefined;
131
+ } | {
132
+ type?: undefined;
133
+ width?: undefined;
134
+ color: string;
135
+ backgroundColor: string;
136
+ padding: number[];
137
+ borderRadius: number;
138
+ position: import("..").MarkLineLabelPosition;
139
+ formatter: string;
140
+ };
141
+ name: string;
142
+ lineStyle: {
143
+ color: string;
144
+ type: "dashed" | "dotted" | "solid";
145
+ width: number;
146
+ };
147
+ label: {
148
+ color: string;
149
+ backgroundColor: string;
150
+ padding: number[];
151
+ borderRadius: number;
152
+ position: import("..").MarkLineLabelPosition;
153
+ formatter: string;
154
+ };
155
+ }[];
156
+ } | undefined;
@@ -0,0 +1,9 @@
1
+ import type { EChartsCoreOption } from "echarts/core";
2
+ /**
3
+ * Deep merge user supplied ECharts options over chart generated options.
4
+ * Plain objects are merged recursively. Arrays of components (e.g. series,
5
+ * xAxis, yAxis, grid, dataZoom) are merged item by item, matched by `id`
6
+ * where present, otherwise by position. Any other value (including data
7
+ * arrays, functions and primitives) in the override replaces the original.
8
+ */
9
+ export declare const mergeEChartsOptions: (base: EChartsCoreOption, ...overrides: Array<EChartsCoreOption | undefined>) => EChartsCoreOption;
@@ -0,0 +1,28 @@
1
+ import { ChartOptionsProps } from "./useChartOptions";
2
+ import { type MeasuredContainerProps } from "@vuu-ui/vuu-ui-controls";
3
+ type OptionSettings = {
4
+ notMerge: boolean;
5
+ };
6
+ type ChartSettings = {
7
+ /**
8
+ * Default value will be svg
9
+ */
10
+ renderer: "svg" | "canvas";
11
+ /**
12
+ * Enlarges 'click zone' around interactive elements.
13
+ * Default value true;
14
+ */
15
+ useCoarsePointer: boolean;
16
+ };
17
+ export interface ChartProps extends ChartOptionsProps, Omit<MeasuredContainerProps, "children" | "onResize"> {
18
+ chartSettings?: Partial<ChartSettings>;
19
+ optionSettings?: OptionSettings;
20
+ /**
21
+ * An array of color values that will be assigned, in the order given
22
+ * to rendered series.
23
+ */
24
+ palette?: string[];
25
+ showTooltip?: boolean;
26
+ }
27
+ export declare const Chart: ({ categoryColumnName, chartSettings, className, config, dataExclusions, dataSource, height, optionSettings, palette, resizeStrategy, showTooltip, style, seriesColumnNames, width, ...htmlAttributes }: ChartProps) => import("react").JSX.Element;
28
+ export {};
@@ -0,0 +1,32 @@
1
+ import { DataSource, DataSourceRow, DataSourceSubscribeCallback } from "@vuu-ui/vuu-data-types";
2
+ import { EventEmitter } from "@vuu-ui/vuu-utils";
3
+ import { Series } from "./chart-types";
4
+ import { ChartConfig, DataExclusionOptions } from "./useChartOptions";
5
+ export type DataSourceValue = {
6
+ key: string;
7
+ readonly row: DataSourceRow;
8
+ value: number | null;
9
+ };
10
+ export type ChartEvents = {
11
+ update: () => void;
12
+ };
13
+ export interface ChartSeriesConstructorProps {
14
+ dataExclusions?: DataExclusionOptions;
15
+ dataSource: DataSource;
16
+ config: ChartConfig;
17
+ palette: string[];
18
+ }
19
+ export declare class ChartSeries extends EventEmitter<ChartEvents> {
20
+ #private;
21
+ handleData: DataSourceSubscribeCallback;
22
+ buildCategoriesAndSeries(): void;
23
+ constructor({ config, dataExclusions, dataSource, palette, }: ChartSeriesConstructorProps);
24
+ get palette(): (string | undefined)[];
25
+ get categoryColumn(): string;
26
+ set categoryColumn(categoryColumn: string);
27
+ get seriesColumnNames(): string[];
28
+ set seriesColumnNames(seriesColumnNames: string[]);
29
+ get categories(): string[];
30
+ get series(): Series[];
31
+ private getCategoriesAndSeries;
32
+ }
@@ -0,0 +1,23 @@
1
+ import { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import { VuuRange } from "@vuu-ui/vuu-protocol-types";
3
+ import { WindowRange } from "@vuu-ui/vuu-utils";
4
+ export declare class MovingDataRowWindow {
5
+ #private;
6
+ data: DataSourceRow[];
7
+ rowCount: number;
8
+ constructor({ from, to }: VuuRange);
9
+ setRowCount: (rowCount: number) => void;
10
+ add(data: DataSourceRow): void;
11
+ getAtIndex(index: number): DataSourceRow | undefined;
12
+ getByKey(key: string): DataSourceRow | undefined;
13
+ isWithinRange(index: number): boolean;
14
+ setRange({ from, to }: VuuRange): void;
15
+ get hasData(): boolean;
16
+ /**
17
+ * This will throw if there is no data. Check `hasData` first
18
+ * to guard against this, if not certain.
19
+ */
20
+ get firstRow(): DataSourceRow;
21
+ get range(): WindowRange;
22
+ get hasAllRowsWithinRange(): boolean;
23
+ }
@@ -0,0 +1,42 @@
1
+ import { DataSourceValue } from "./ChartSeries";
2
+ export declare const defaultItemColorFunction: ItemColorFunction;
3
+ export type EChartsCallbackParams = {
4
+ color: string;
5
+ data: DataSourceValue;
6
+ dataIndex: number;
7
+ name: string;
8
+ /**
9
+ * This is the Vuu column name
10
+ */
11
+ seriesName: string;
12
+ };
13
+ export type SymbolSizeFunction = (value: number, params: EChartsCallbackParams) => number | [number, number];
14
+ export type SymbolSize = number | [number, number] | SymbolSizeFunction;
15
+ export type SymbolType = "emptyCircle" | "circle" | `path://${string}`;
16
+ export type ItemColorFunction = (params: EChartsCallbackParams) => string;
17
+ export interface SeriesBase {
18
+ data: DataSourceValue[];
19
+ id: string;
20
+ itemStyle?: {
21
+ borderColor?: string;
22
+ color: string | ItemColorFunction;
23
+ borderWidth?: number;
24
+ };
25
+ label: string;
26
+ name: string;
27
+ symbol?: SymbolType;
28
+ symbolSize: SymbolSize;
29
+ }
30
+ export interface LineSeries extends SeriesBase {
31
+ connectNulls?: boolean;
32
+ lineStyle: {
33
+ color?: string;
34
+ width: number;
35
+ };
36
+ type: "line";
37
+ }
38
+ export interface ScatterSeries extends SeriesBase {
39
+ type: "scatter";
40
+ }
41
+ export type Series = LineSeries | ScatterSeries;
42
+ export type ChartSelectionModel = "none" | "single" | "single-no-deselect" | "extended";
@@ -0,0 +1,12 @@
1
+ import { DataSourceValue } from "./ChartSeries";
2
+ export interface TooltipParams {
3
+ axisValueLabel: string;
4
+ color: string;
5
+ componentType: string;
6
+ componentSubType: string;
7
+ data: DataSourceValue;
8
+ seriesName: string;
9
+ seriesType: 'line' | 'scatter';
10
+ value: number;
11
+ }
12
+ export declare const chartTooltip: (params: TooltipParams[]) => string | undefined;
@@ -0,0 +1,5 @@
1
+ export { Chart, type ChartProps } from "./Chart";
2
+ export type { ItemColorFunction, LineSeries as Series } from './chart-types';
3
+ export { ChartSeries, type DataSourceValue } from "./ChartSeries";
4
+ export type { ChartContextMenuOptions, ChartMenuLocation } from "./useChartContextMenu";
5
+ export type { ChartConfig, DataExclusionOptions } from './useChartOptions';
@@ -0,0 +1,16 @@
1
+ import { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import { ECElementEvent } from "echarts";
3
+ import { ColumnMap } from "@vuu-ui/vuu-utils";
4
+ export type ChartMenuLocation = "canvas" | "series";
5
+ export type ChartContextMenuOptions = {
6
+ column: string;
7
+ columnMap: ColumnMap;
8
+ row: DataSourceRow;
9
+ };
10
+ interface ChartContextMenuHookProps {
11
+ allowContextMenu?: boolean;
12
+ categoryColumnName?: string;
13
+ columnMap: ColumnMap;
14
+ }
15
+ export declare const useChartContextMenu: ({ columnMap, }: ChartContextMenuHookProps) => ({ data, event, seriesName }: ECElementEvent) => void;
16
+ export {};
@@ -0,0 +1,28 @@
1
+ import { DataSource, DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import { ColumnMap } from "@vuu-ui/vuu-utils";
3
+ import { type EChartsCoreOption } from "echarts";
4
+ import type { ChartSelectionModel, ItemColorFunction, SymbolSize, SymbolSizeFunction, SymbolType } from "./chart-types";
5
+ export interface ChartConfig {
6
+ itemColorFunction?: ItemColorFunction;
7
+ selectionModel?: ChartSelectionModel;
8
+ symbolSize?: SymbolSize;
9
+ }
10
+ export interface DataExclusionOptions {
11
+ isExcludedData: (row: DataSourceRow, columnMap: ColumnMap, column: string) => boolean;
12
+ /**
13
+ * An embedded SVG path. If provided, will be used to render excluded values.
14
+ */
15
+ symbol?: SymbolType;
16
+ }
17
+ export interface ChartOptionsProps {
18
+ categoryColumnName: string;
19
+ config: ChartConfig;
20
+ dataExclusions?: DataExclusionOptions;
21
+ dataSource: DataSource;
22
+ itemColorFunction?: ItemColorFunction;
23
+ palette?: string[];
24
+ seriesColumnNames: string[];
25
+ showTooltip?: boolean;
26
+ symbolSizeFunction?: SymbolSizeFunction;
27
+ }
28
+ export declare const useChartOptions: ({ categoryColumnName, config, dataExclusions, dataSource, itemColorFunction, palette, seriesColumnNames, showTooltip, symbolSizeFunction: symbolSize, }: ChartOptionsProps) => EChartsCoreOption;
@@ -0,0 +1,14 @@
1
+ import { ECElementEvent } from "echarts";
2
+ import { ChartSelectionModel, ItemColorFunction, SymbolSizeFunction } from "./chart-types";
3
+ interface ChartSelectionHookProps {
4
+ selectionModel?: ChartSelectionModel;
5
+ categoryColumnName: string;
6
+ }
7
+ export declare const useChartSelection: (_props: ChartSelectionHookProps) => {
8
+ onClick: ({ data, event, seriesName: column }: ECElementEvent) => void;
9
+ onMouseOver: ({ data, seriesName }: ECElementEvent) => void;
10
+ onMouseOut: () => void;
11
+ itemColorFunction: ItemColorFunction;
12
+ symbolSizeFunction: SymbolSizeFunction;
13
+ };
14
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Chart colours are resolved from CSS custom properties at runtime, so that
3
+ * charts follow the Salt/Vuu theme (including light/dark mode) and work with
4
+ * the canvas renderer (which cannot resolve css var() references itself).
5
+ *
6
+ * All tokens are declared, with Salt-based defaults, in Chart.css on the
7
+ * .vuuChart class and can be overridden in application css.
8
+ */
9
+ export interface ChartTheme {
10
+ axisLineColor: string;
11
+ backgroundColor: string;
12
+ crosshairColor: string;
13
+ /** colour of declining candles/bars, negative values, SELL side */
14
+ downColor: string;
15
+ fontFamily: string;
16
+ foregroundColor: string;
17
+ /** low/high colours used for heatmaps */
18
+ heatmapColors: [string, string];
19
+ /** categorical palette, assigned to series in order */
20
+ palette: string[];
21
+ secondaryForegroundColor: string;
22
+ splitLineColor: string;
23
+ tooltipBackgroundColor: string;
24
+ tooltipBorderColor: string;
25
+ /** colour of rising candles/bars, positive values, BUY side */
26
+ upColor: string;
27
+ }
28
+ export declare const defaultPalette: string[];
29
+ export declare const defaultChartTheme: ChartTheme;
30
+ /**
31
+ * Read chart theme tokens from the computed style of the chart element.
32
+ */
33
+ export declare const resolveChartTheme: (element: HTMLElement | null, overrides?: Partial<ChartTheme>) => ChartTheme;
34
+ /**
35
+ * Colour values in declarative chart props may reference theme colours by
36
+ * name: 'up', 'down' or 'palette-n' (1 based).
37
+ */
38
+ export declare const resolveColor: (color: string | undefined, theme: ChartTheme) => string | undefined;
@@ -0,0 +1,117 @@
1
+ import type { DataSource, DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
+ import type { MeasuredContainerProps } from "@vuu-ui/vuu-ui-controls";
4
+ import type { ColumnMap } from "@vuu-ui/vuu-utils";
5
+ import type { ECharts, EChartsCoreOption } from "echarts/core";
6
+ import type { ChartTheme } from "./theme/chartTheme";
7
+ export type ChartRenderer = "canvas" | "svg";
8
+ /**
9
+ * true is equivalent to 'inside'.
10
+ */
11
+ export type DataZoomOption = boolean | "inside" | "slider" | "both";
12
+ export type LegendPosition = "top" | "bottom" | "none";
13
+ export type XAxisType = "time" | "category" | "value";
14
+ export type RowPredicate = (row: DataSourceRow, columnMap: ColumnMap) => boolean;
15
+ /**
16
+ * Restrict the rows used by a series. Either a map of column name to required
17
+ * value (all must match) or a predicate.
18
+ * e.g { side: "BUY" }
19
+ */
20
+ export type RowMatch = Record<string, VuuRowDataItemType> | RowPredicate;
21
+ /**
22
+ * Colour each data point according to the value in a column.
23
+ * Colours may be any css colour or one of the theme colour names
24
+ * 'up', 'down', 'palette-1' ... 'palette-8'.
25
+ * e.g { columnName: "side", colors: { BUY: "up", SELL: "down" } }
26
+ */
27
+ export interface ColorBy {
28
+ columnName: string;
29
+ colors: Record<string, string>;
30
+ defaultColor?: string;
31
+ }
32
+ export type Aggregation = "sum" | "avg" | "min" | "max" | "count" | "last";
33
+ /**
34
+ * - number: a fixed value
35
+ * - 'last': the value of the last (most recent) data point
36
+ * - 'min' | 'max' | 'average': computed over the series values
37
+ * - { weightedAverage: column }: average of series values weighted by the
38
+ * named column (e.g. average fill price weighted by quantity)
39
+ */
40
+ export type MarkLineValue = number | "last" | "min" | "max" | "average" | {
41
+ weightedAverage: string;
42
+ };
43
+ export interface MarkLineDef {
44
+ value: MarkLineValue;
45
+ label?: string;
46
+ /** css colour or theme colour name ('up', 'down', 'palette-n') */
47
+ color?: string;
48
+ lineType?: "solid" | "dashed" | "dotted";
49
+ /**
50
+ * Position of the label, relative to the line. Default 'insideEndTop'
51
+ * (inside the plot area, at the end of the line, so never clipped). Use
52
+ * 'end' to place the label beyond the end of the line, e.g over a right
53
+ * hand price axis.
54
+ */
55
+ labelPosition?: MarkLineLabelPosition;
56
+ }
57
+ export type MarkLineLabelPosition = "start" | "middle" | "end" | "insideStartTop" | "insideStartBottom" | "insideMiddleTop" | "insideMiddleBottom" | "insideEndTop" | "insideEndBottom";
58
+ export type EChartsOptionsOverride = EChartsCoreOption | ((generated: EChartsCoreOption) => EChartsCoreOption);
59
+ export interface ChartItemEvent {
60
+ columnMap: ColumnMap;
61
+ dataSource: DataSource;
62
+ /** The DataSourceRow behind the clicked item, where one can be identified */
63
+ row: DataSourceRow | undefined;
64
+ /**
65
+ * For aggregated items (hierarchy nodes, aggregated categories), all rows
66
+ * contributing to the item.
67
+ */
68
+ rows?: DataSourceRow[];
69
+ /** For hierarchy nodes, the group values from root to node */
70
+ groupPath?: string[];
71
+ seriesId: string;
72
+ seriesName: string;
73
+ dataIndex: number;
74
+ value: unknown;
75
+ nativeEvent?: Event;
76
+ }
77
+ export type ChartItemEventHandler = (event: ChartItemEvent) => void;
78
+ export interface VuuChartBaseProps extends Omit<MeasuredContainerProps, "children" | "onResize" | "onClick"> {
79
+ /**
80
+ * Additional raw ECharts options, deep merged over the generated options.
81
+ * Arrays of components (series, xAxis, yAxis, grid, dataZoom etc) are
82
+ * merged item by item, matched by id where present, otherwise by index.
83
+ * Generated ids are documented in the README.
84
+ * If a function is provided, it receives the generated option and returns
85
+ * the option to be used. Note: overrides are applied when the chart
86
+ * structure is (re)built, not on each data update.
87
+ */
88
+ echartsOptions?: EChartsOptionsOverride;
89
+ /**
90
+ * Maximum number of rows to be read from each DataSource. Default 1000.
91
+ */
92
+ maxRows?: number;
93
+ /**
94
+ * Invoked once the ECharts instance has been created.
95
+ */
96
+ onChartReady?: (chart: ECharts) => void;
97
+ onItemClick?: ChartItemEventHandler;
98
+ onItemContextMenu?: ChartItemEventHandler;
99
+ /**
100
+ * Default is 'canvas', which performs better with streaming data.
101
+ */
102
+ renderer?: ChartRenderer;
103
+ /**
104
+ * Show a legend. Default depends on chart type, generally shown when there
105
+ * are multiple series.
106
+ */
107
+ legend?: LegendPosition;
108
+ /**
109
+ * Default true
110
+ */
111
+ showTooltip?: boolean;
112
+ /**
113
+ * Override any of the theme colours (by default resolved from css tokens).
114
+ */
115
+ theme?: Partial<ChartTheme>;
116
+ }
117
+ export type { ChartTheme };