@vuu-ui/vuu-chart 4.0.1 → 5.0.0-alpha.1

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.
Files changed (49) hide show
  1. package/README.md +324 -0
  2. package/package.json +10 -11
  3. package/src/Chart.css.js +22 -0
  4. package/src/Chart.js +2 -2
  5. package/src/ChartSeries.js +20 -3
  6. package/src/chart-data/ChartDataStore.js +131 -0
  7. package/src/chart-data/projection-utils.js +119 -0
  8. package/src/charts/CandlestickChart.js +31 -0
  9. package/src/charts/CartesianChart.js +28 -0
  10. package/src/charts/DepthChart.js +28 -0
  11. package/src/charts/HeatmapChart.js +31 -0
  12. package/src/charts/HierarchyChart.js +41 -0
  13. package/src/charts/candlestick-model.js +373 -0
  14. package/src/charts/cartesian-model.js +234 -0
  15. package/src/charts/depth-model.js +159 -0
  16. package/src/charts/heatmap-model.js +243 -0
  17. package/src/charts/hierarchy-model.js +224 -0
  18. package/src/echarts.js +26 -0
  19. package/src/engine/ChartModel.js +2 -0
  20. package/src/engine/VuuChartContainer.js +196 -0
  21. package/src/engine/useStructuralMemo.js +18 -0
  22. package/src/index.js +8 -0
  23. package/src/options/common.js +181 -0
  24. package/src/options/mergeOptions.js +37 -0
  25. package/src/theme/chartTheme.js +74 -0
  26. package/src/useChartOptions.js +25 -2
  27. package/src/vuu-chart-types.js +0 -0
  28. package/types/Chart.d.ts +1 -1
  29. package/types/ChartSeries.d.ts +15 -0
  30. package/types/charts/CandlestickChart.d.ts +1 -1
  31. package/types/charts/CartesianChart.d.ts +1 -1
  32. package/types/charts/DepthChart.d.ts +1 -1
  33. package/types/charts/HeatmapChart.d.ts +1 -1
  34. package/types/charts/HierarchyChart.d.ts +4 -4
  35. package/types/engine/VuuChartContainer.d.ts +1 -1
  36. package/types/index.d.ts +18 -4
  37. package/types/options/common.d.ts +1 -1
  38. package/types/useChartContextMenu.d.ts +1 -1
  39. package/types/useChartOptions.d.ts +1 -1
  40. package/types/useChartSelection.d.ts +1 -1
  41. package/types/src/Chart.d.ts +0 -28
  42. package/types/src/ChartSeries.d.ts +0 -32
  43. package/types/src/DataRowMovingWindow.d.ts +0 -23
  44. package/types/src/chart-types.d.ts +0 -42
  45. package/types/src/chartTooltip.d.ts +0 -12
  46. package/types/src/index.d.ts +0 -5
  47. package/types/src/useChartContextMenu.d.ts +0 -16
  48. package/types/src/useChartOptions.d.ts +0 -28
  49. package/types/src/useChartSelection.d.ts +0 -14
@@ -0,0 +1,37 @@
1
+ const isPlainObject = (value)=>null !== value && "object" == typeof value && (Object.getPrototypeOf(value) === Object.prototype || null === Object.getPrototypeOf(value));
2
+ const hasId = (value)=>isPlainObject(value) && void 0 !== value.id;
3
+ const mergeArrays = (base, override)=>{
4
+ const result = base.slice();
5
+ override.forEach((item, i)=>{
6
+ if (hasId(item)) {
7
+ const index = result.findIndex((b)=>hasId(b) && b.id === item.id);
8
+ if (-1 !== index) result[index] = mergeValues(result[index], item);
9
+ else result.push(item);
10
+ } else if (i < result.length) result[i] = mergeValues(result[i], item);
11
+ else result.push(item);
12
+ });
13
+ return result;
14
+ };
15
+ const mergeValues = (base, override)=>{
16
+ if (void 0 === override) return base;
17
+ if (isPlainObject(base) && isPlainObject(override)) {
18
+ const result = {
19
+ ...base
20
+ };
21
+ for (const [key, value] of Object.entries(override))result[key] = mergeValues(base[key], value);
22
+ return result;
23
+ }
24
+ if (Array.isArray(override) && (Array.isArray(base) || isPlainObject(base))) {
25
+ const baseArray = Array.isArray(base) ? base : [
26
+ base
27
+ ];
28
+ if (override.every((o)=>isPlainObject(o))) return mergeArrays(baseArray, override);
29
+ return override;
30
+ }
31
+ if (Array.isArray(base) && isPlainObject(override)) return mergeArrays(base, [
32
+ override
33
+ ]);
34
+ return override;
35
+ };
36
+ const mergeEChartsOptions = (base, ...overrides)=>overrides.reduce((result, override)=>override ? mergeValues(result, override) : result, base);
37
+ export { mergeEChartsOptions };
@@ -0,0 +1,74 @@
1
+ const defaultPalette = [
2
+ "#4676bf",
3
+ "#ab6528",
4
+ "#9f55c2",
5
+ "#2a8285",
6
+ "#697694",
7
+ "#b0549d",
8
+ "#c69d26",
9
+ "#5c8a3a"
10
+ ];
11
+ const defaultChartTheme = {
12
+ axisLineColor: "#9fa3a8",
13
+ backgroundColor: "transparent",
14
+ crosshairColor: "#697694",
15
+ downColor: "#e52135",
16
+ fontFamily: "sans-serif",
17
+ foregroundColor: "#15171b",
18
+ heatmapColors: [
19
+ "#e2ebf8",
20
+ "#1b4f9c"
21
+ ],
22
+ palette: defaultPalette,
23
+ secondaryForegroundColor: "#5f646d",
24
+ splitLineColor: "#e6e8ea",
25
+ tooltipBackgroundColor: "#ffffff",
26
+ tooltipBorderColor: "#2670a9",
27
+ upColor: "#00875d"
28
+ };
29
+ const PALETTE_SIZE = 8;
30
+ const read = (style, name, fallback)=>{
31
+ const value = style.getPropertyValue(name).trim();
32
+ return "" === value ? fallback : value;
33
+ };
34
+ const resolveChartTheme = (element, overrides)=>{
35
+ let theme = defaultChartTheme;
36
+ if (element && "function" == typeof getComputedStyle) {
37
+ const style = getComputedStyle(element);
38
+ const d = defaultChartTheme;
39
+ const palette = [];
40
+ for(let i = 0; i < PALETTE_SIZE; i++)palette.push(read(style, `--vuuChart-color-${i + 1}`, d.palette[i]));
41
+ theme = {
42
+ axisLineColor: read(style, "--vuuChart-axisLineColor", d.axisLineColor),
43
+ backgroundColor: read(style, "--vuuChart-background", d.backgroundColor),
44
+ crosshairColor: read(style, "--vuuChart-crosshairColor", d.crosshairColor),
45
+ downColor: read(style, "--vuuChart-downColor", d.downColor),
46
+ fontFamily: read(style, "--vuuChart-fontFamily", d.fontFamily),
47
+ foregroundColor: read(style, "--vuuChart-foreground", d.foregroundColor),
48
+ heatmapColors: [
49
+ read(style, "--vuuChart-heatmap-lowColor", d.heatmapColors[0]),
50
+ read(style, "--vuuChart-heatmap-highColor", d.heatmapColors[1])
51
+ ],
52
+ palette,
53
+ secondaryForegroundColor: read(style, "--vuuChart-secondaryForeground", d.secondaryForegroundColor),
54
+ splitLineColor: read(style, "--vuuChart-splitLineColor", d.splitLineColor),
55
+ tooltipBackgroundColor: read(style, "--vuuChart-tooltip-background", d.tooltipBackgroundColor),
56
+ tooltipBorderColor: read(style, "--vuuChart-tooltip-borderColor", d.tooltipBorderColor),
57
+ upColor: read(style, "--vuuChart-upColor", d.upColor)
58
+ };
59
+ }
60
+ return overrides ? {
61
+ ...theme,
62
+ ...overrides
63
+ } : theme;
64
+ };
65
+ const resolveColor = (color, theme)=>{
66
+ if ("up" === color) return theme.upColor;
67
+ if ("down" === color) return theme.downColor;
68
+ if (color?.startsWith("palette-")) {
69
+ const index = parseInt(color.slice(8), 10) - 1;
70
+ return theme.palette[index % theme.palette.length];
71
+ }
72
+ return color;
73
+ };
74
+ export { defaultChartTheme, defaultPalette, resolveChartTheme, resolveColor };
@@ -1,5 +1,5 @@
1
1
  import { itemsChanged } from "@vuu-ui/vuu-utils";
2
- import { useMemo, useState } from "react";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { ChartSeries } from "./ChartSeries.js";
4
4
  import { chartTooltip } from "./chartTooltip.js";
5
5
  const defaultPalette = [
@@ -16,6 +16,7 @@ const combineConfig = (config, overrides)=>({
16
16
  });
17
17
  const useChartOptions = ({ categoryColumnName, config, dataExclusions, dataSource, itemColorFunction, palette = defaultPalette, seriesColumnNames, showTooltip = true, symbolSizeFunction: symbolSize })=>{
18
18
  const [, forceRender] = useState({});
19
+ const frameRef = useRef(void 0);
19
20
  const chartSeries = useMemo(()=>{
20
21
  const cs = new ChartSeries({
21
22
  config: combineConfig(config, {
@@ -26,12 +27,34 @@ const useChartOptions = ({ categoryColumnName, config, dataExclusions, dataSourc
26
27
  dataSource,
27
28
  palette
28
29
  });
29
- cs.on("update", ()=>forceRender({}));
30
+ cs.on("update", ()=>{
31
+ if (void 0 === frameRef.current) frameRef.current = requestAnimationFrame(()=>{
32
+ frameRef.current = void 0;
33
+ forceRender({});
34
+ });
35
+ });
30
36
  return cs;
31
37
  }, [
32
38
  dataSource,
33
39
  config
34
40
  ]);
41
+ const chartSeriesRef = useRef(chartSeries);
42
+ chartSeriesRef.current = chartSeries;
43
+ useEffect(()=>{
44
+ chartSeries.subscribe();
45
+ return ()=>{
46
+ if (void 0 !== frameRef.current) {
47
+ cancelAnimationFrame(frameRef.current);
48
+ frameRef.current = void 0;
49
+ }
50
+ chartSeries.detach();
51
+ };
52
+ }, [
53
+ chartSeries
54
+ ]);
55
+ useEffect(()=>()=>{
56
+ chartSeriesRef.current.dispose();
57
+ }, []);
35
58
  useMemo(()=>{
36
59
  if (categoryColumnName !== chartSeries.categoryColumn) chartSeries.categoryColumn = categoryColumnName;
37
60
  if (itemsChanged(seriesColumnNames, chartSeries.seriesColumnNames)) chartSeries.seriesColumnNames = seriesColumnNames;
File without changes
package/types/Chart.d.ts CHANGED
@@ -24,5 +24,5 @@ export interface ChartProps extends ChartOptionsProps, Omit<MeasuredContainerPro
24
24
  palette?: string[];
25
25
  showTooltip?: boolean;
26
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-runtime").JSX.Element;
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
28
  export {};
@@ -21,6 +21,21 @@ export declare class ChartSeries extends EventEmitter<ChartEvents> {
21
21
  handleData: DataSourceSubscribeCallback;
22
22
  buildCategoriesAndSeries(): void;
23
23
  constructor({ config, dataExclusions, dataSource, palette, }: ChartSeriesConstructorProps);
24
+ /**
25
+ * Subscribes to the DataSource. Invoked by the constructor, only needs to
26
+ * be invoked again after dispose.
27
+ */
28
+ subscribe(): void;
29
+ /**
30
+ * Stops processing data from the DataSource, without unsubscribing it.
31
+ * Used when the DataSource is replaced, the caller may still be using
32
+ * the previous DataSource (e.g. as the source of an edit session).
33
+ */
34
+ detach(): void;
35
+ /**
36
+ * Stops processing data and unsubscribes from the DataSource.
37
+ */
38
+ dispose(): void;
24
39
  get palette(): (string | undefined)[];
25
40
  get categoryColumn(): string;
26
41
  set categoryColumn(categoryColumn: string);
@@ -6,4 +6,4 @@ export interface CandlestickChartProps extends Omit<VuuChartBaseProps, "legend">
6
6
  * OHLC candlestick chart with optional volume pane and overlay series
7
7
  * (e.g. a vwap line, or fills as scatter markers from a second DataSource).
8
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;
9
+ export declare const CandlestickChart: ({ crosshair, dataSource, dataZoom, formatTime, legend, markLines, ohlcColumnNames, overlays, showTooltip, timeColumnName, volumeColumnName, volumePaneHeight, xAxisType, ...props }: CandlestickChartProps) => import("react").JSX.Element;
@@ -7,4 +7,4 @@ export interface CartesianChartProps extends Omit<VuuChartBaseProps, "legend">,
7
7
  * scatter series, on a category, time or value x axis. Series may be read
8
8
  * from multiple DataSources.
9
9
  */
10
- export declare const CartesianChart: ({ aggregation, crosshair, dataSource, dataZoom, legend, orientation, series, showTooltip, xAxis, yAxes, ...props }: CartesianChartProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const CartesianChart: ({ aggregation, crosshair, dataSource, dataZoom, legend, orientation, series, showTooltip, xAxis, yAxes, ...props }: CartesianChartProps) => import("react").JSX.Element;
@@ -5,4 +5,4 @@ export interface DepthChartProps extends Omit<VuuChartBaseProps, "legend">, Dept
5
5
  /**
6
6
  * Market depth chart: stepped cumulative bid and ask areas, by price.
7
7
  */
8
- export declare const DepthChart: ({ askValue, bidValue, cumulativeSizeColumnName, dataSource, legend, priceColumnName, showMidPrice, showTooltip, sideColumnName, sizeColumnName, ...props }: DepthChartProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const DepthChart: ({ askValue, bidValue, cumulativeSizeColumnName, dataSource, legend, priceColumnName, showMidPrice, showTooltip, sideColumnName, sizeColumnName, ...props }: DepthChartProps) => import("react").JSX.Element;
@@ -6,4 +6,4 @@ export interface HeatmapChartProps extends Omit<VuuChartBaseProps, "legend">, He
6
6
  * Heatmap of a value column by two dimensions, e.g. traded quantity by
7
7
  * price level and time bucket.
8
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;
9
+ export declare const HeatmapChart: ({ aggregation, colorScale, dataSource, dataZoom, formatTime, max, min, showTooltip, showVisualMap, valueColumnName, where, xAxis, yAxis, ...props }: HeatmapChartProps) => import("react").JSX.Element;
@@ -6,10 +6,10 @@ export interface HierarchyChartProps extends Omit<VuuChartBaseProps, "legend">,
6
6
  * Treemap, sunburst or pie breakdown of a value column, grouped by one or
7
7
  * more columns e.g. exposure by sector -> ric.
8
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;
9
+ export declare const HierarchyChart: ({ aggregation, colorMode, dataSource, donut, formatValue, groupByColumnNames, legend, showTooltip, type, valueColumnName, where, ...props }: HierarchyChartProps) => import("react").JSX.Element;
10
10
  export type TreemapChartProps = Omit<HierarchyChartProps, "type" | "donut">;
11
- export declare const TreemapChart: (props: TreemapChartProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const TreemapChart: (props: TreemapChartProps) => import("react").JSX.Element;
12
12
  export type SunburstChartProps = Omit<HierarchyChartProps, "type" | "donut">;
13
- export declare const SunburstChart: (props: SunburstChartProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const SunburstChart: (props: SunburstChartProps) => import("react").JSX.Element;
14
14
  export type PieChartProps = Omit<HierarchyChartProps, "type">;
15
- export declare const PieChart: (props: PieChartProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const PieChart: (props: PieChartProps) => import("react").JSX.Element;
@@ -14,4 +14,4 @@ export interface VuuChartContainerProps extends VuuChartBaseProps {
14
14
  * - applies data updates as a partial option, merged by component id, at
15
15
  * most once per animation frame, without re-rendering React
16
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;
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.Element;
package/types/index.d.ts CHANGED
@@ -1,5 +1,19 @@
1
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';
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";
6
+ export { CandlestickChart, type CandlestickChartProps, } from "./charts/CandlestickChart";
7
+ export type { CandlestickChartOptions, CandlestickOverlayDef, OhlcColumnNames, } from "./charts/candlestick-model";
8
+ export { CartesianChart, type CartesianChartProps, } from "./charts/CartesianChart";
9
+ export type { CartesianChartOptions, CartesianSeriesDef, CartesianSeriesType, CartesianXAxisDef, CartesianYAxisDef, } from "./charts/cartesian-model";
10
+ export { DepthChart, type DepthChartProps } from "./charts/DepthChart";
11
+ export type { DepthChartOptions } from "./charts/depth-model";
12
+ export { HeatmapChart, type HeatmapChartProps } from "./charts/HeatmapChart";
13
+ export type { HeatmapAxisDef, HeatmapChartOptions, } from "./charts/heatmap-model";
14
+ export { HierarchyChart, type HierarchyChartProps, PieChart, type PieChartProps, SunburstChart, type SunburstChartProps, TreemapChart, type TreemapChartProps, } from "./charts/HierarchyChart";
15
+ export type { HierarchyChartOptions, HierarchyChartType, HierarchyColorMode, } from "./charts/hierarchy-model";
16
+ export { ChartDataStore } from "./chart-data/ChartDataStore";
17
+ export { mergeEChartsOptions } from "./options/mergeOptions";
18
+ export { defaultChartTheme, resolveChartTheme, } from "./theme/chartTheme";
19
+ export type * from "./vuu-chart-types";
@@ -120,13 +120,13 @@ export declare const markLineOption: (defs: MarkLineDef[] | undefined, theme: Ch
120
120
  animation: boolean;
121
121
  data: {
122
122
  [x: string]: string | number | {
123
+ position?: undefined;
123
124
  color: string;
124
125
  type: "dashed" | "dotted" | "solid";
125
126
  width: number;
126
127
  backgroundColor?: undefined;
127
128
  padding?: undefined;
128
129
  borderRadius?: undefined;
129
- position?: undefined;
130
130
  formatter?: undefined;
131
131
  } | {
132
132
  type?: undefined;
@@ -1,5 +1,5 @@
1
1
  import { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
- import { ECElementEvent } from "echarts";
2
+ import type { ECElementEvent } from "echarts/core";
3
3
  import { ColumnMap } from "@vuu-ui/vuu-utils";
4
4
  export type ChartMenuLocation = "canvas" | "series";
5
5
  export type ChartContextMenuOptions = {
@@ -1,6 +1,6 @@
1
1
  import { DataSource, DataSourceRow } from "@vuu-ui/vuu-data-types";
2
2
  import { ColumnMap } from "@vuu-ui/vuu-utils";
3
- import { type EChartsCoreOption } from "echarts";
3
+ import { type EChartsCoreOption } from "echarts/core";
4
4
  import type { ChartSelectionModel, ItemColorFunction, SymbolSize, SymbolSizeFunction, SymbolType } from "./chart-types";
5
5
  export interface ChartConfig {
6
6
  itemColorFunction?: ItemColorFunction;
@@ -1,4 +1,4 @@
1
- import { ECElementEvent } from "echarts";
1
+ import type { ECElementEvent } from "echarts/core";
2
2
  import { ChartSelectionModel, ItemColorFunction, SymbolSizeFunction } from "./chart-types";
3
3
  interface ChartSelectionHookProps {
4
4
  selectionModel?: ChartSelectionModel;
@@ -1,28 +0,0 @@
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 {};
@@ -1,32 +0,0 @@
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
- }
@@ -1,23 +0,0 @@
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
- }
@@ -1,42 +0,0 @@
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";
@@ -1,12 +0,0 @@
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;
@@ -1,5 +0,0 @@
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';
@@ -1,16 +0,0 @@
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 {};
@@ -1,28 +0,0 @@
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;
@@ -1,14 +0,0 @@
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 {};