@univerjs-pro/engine-chart 0.6.4-nightly.202503101606

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 (71) hide show
  1. package/README.md +26 -0
  2. package/lib/cjs/index.js +1 -0
  3. package/lib/es/index.js +1 -0
  4. package/lib/types/enum.d.ts +301 -0
  5. package/lib/types/extra/func.d.ts +1 -0
  6. package/lib/types/extra/reverse.d.ts +64 -0
  7. package/lib/types/index.d.ts +16 -0
  8. package/lib/types/model/chart-data-operators/build-chart-data.d.ts +3 -0
  9. package/lib/types/model/chart-data-operators/index.d.ts +2 -0
  10. package/lib/types/model/chart-data-operators/operators.d.ts +25 -0
  11. package/lib/types/model/chart-theme.service.d.ts +25 -0
  12. package/lib/types/model/constants/build-in-theme/default.d.ts +2 -0
  13. package/lib/types/model/constants/build-in-theme/index.d.ts +15 -0
  14. package/lib/types/model/constants/build-in-theme/types.d.ts +77 -0
  15. package/lib/types/model/constants/build-in-theme/univer-gradient1.d.ts +2 -0
  16. package/lib/types/model/constants/build-in-theme/univer-gradient2.d.ts +2 -0
  17. package/lib/types/model/constants/build-in-theme/univer-gradient3.d.ts +2 -0
  18. package/lib/types/model/constants/build-in-theme/univer-gradient4.d.ts +2 -0
  19. package/lib/types/model/constants/build-in-theme/univer-gradient5.d.ts +2 -0
  20. package/lib/types/model/constants/build-in-theme/univer-gradient6.d.ts +2 -0
  21. package/lib/types/model/constants/build-in-theme/univer1.d.ts +2 -0
  22. package/lib/types/model/constants/build-in-theme/univer2.d.ts +2 -0
  23. package/lib/types/model/constants/build-in-theme/univer3.d.ts +2 -0
  24. package/lib/types/model/constants/build-in-theme/univer4.d.ts +2 -0
  25. package/lib/types/model/constants/build-in-theme/univer5.d.ts +2 -0
  26. package/lib/types/model/constants/build-in-theme/univer6.d.ts +2 -0
  27. package/lib/types/model/constants/default-chart-style.d.ts +69 -0
  28. package/lib/types/model/constants/default.d.ts +9 -0
  29. package/lib/types/model/data-context-transformers/bar-data-context-transformer.d.ts +3 -0
  30. package/lib/types/model/data-context-transformers/line-like-context-transformer.d.ts +3 -0
  31. package/lib/types/model/data-context-transformers/percent-data-context-transformer.d.ts +3 -0
  32. package/lib/types/model/data-context-transformers/pie-data-context-transformer.d.ts +3 -0
  33. package/lib/types/model/echart-render-model.d.ts +33 -0
  34. package/lib/types/model/mode-converter/converters/combination-chart-converter.d.ts +2 -0
  35. package/lib/types/model/mode-converter/converters/constants.d.ts +7 -0
  36. package/lib/types/model/mode-converter/converters/pie-chart-converter.d.ts +2 -0
  37. package/lib/types/model/mode-converter/converters/radar-chart-converter.d.ts +2 -0
  38. package/lib/types/model/mode-converter/converters/tools.d.ts +5 -0
  39. package/lib/types/model/mode-converter/mode-converter.d.ts +86 -0
  40. package/lib/types/model/mode-converter/render-spec-operators/axis-title.operator.d.ts +2 -0
  41. package/lib/types/model/mode-converter/render-spec-operators/chart-axes.operator.d.ts +2 -0
  42. package/lib/types/model/mode-converter/render-spec-operators/chart-box-style.operator.d.ts +2 -0
  43. package/lib/types/model/mode-converter/render-spec-operators/empty-style-operator.d.ts +2 -0
  44. package/lib/types/model/mode-converter/render-spec-operators/font-size.operator.d.ts +2 -0
  45. package/lib/types/model/mode-converter/render-spec-operators/grid-operator.d.ts +2 -0
  46. package/lib/types/model/mode-converter/render-spec-operators/hover-mark-style.operator.d.ts +2 -0
  47. package/lib/types/model/mode-converter/render-spec-operators/index.d.ts +13 -0
  48. package/lib/types/model/mode-converter/render-spec-operators/invalid-value-style.operator.d.ts +2 -0
  49. package/lib/types/model/mode-converter/render-spec-operators/legend-style.operator.d.ts +2 -0
  50. package/lib/types/model/mode-converter/render-spec-operators/line-like-style.operator.d.ts +2 -0
  51. package/lib/types/model/mode-converter/render-spec-operators/operator-types.d.ts +7 -0
  52. package/lib/types/model/mode-converter/render-spec-operators/pie-style.operator.d.ts +2 -0
  53. package/lib/types/model/mode-converter/render-spec-operators/radar-style.operator.d.ts +2 -0
  54. package/lib/types/model/mode-converter/render-spec-operators/scatter-style.operator.d.ts +2 -0
  55. package/lib/types/model/mode-converter/render-spec-operators/series-style-operator/series-chart-style.handler.d.ts +2 -0
  56. package/lib/types/model/mode-converter/render-spec-operators/series-style-operator/series-data-label.handler.d.ts +2 -0
  57. package/lib/types/model/mode-converter/render-spec-operators/series-style-operator/series-style-operator.d.ts +11 -0
  58. package/lib/types/model/mode-converter/render-spec-operators/stack.operator.d.ts +2 -0
  59. package/lib/types/model/mode-converter/render-spec-operators/theme.operator.d.ts +2 -0
  60. package/lib/types/model/mode-converter/render-spec-operators/title-style.operator.d.ts +2 -0
  61. package/lib/types/model/mode-converter/render-spec-operators/tool-tip-operator.d.ts +2 -0
  62. package/lib/types/model/mode-converter/render-spec-operators/tools.d.ts +13 -0
  63. package/lib/types/model/mode-converter/render-spec-operators/watermark.operator.d.ts +2 -0
  64. package/lib/types/model/spec-converter/spec-converter.d.ts +1 -0
  65. package/lib/types/source/chart-source.d.ts +32 -0
  66. package/lib/types/source/source-util.d.ts +2 -0
  67. package/lib/types/source/static-chart-source.d.ts +7 -0
  68. package/lib/types/types.d.ts +271 -0
  69. package/lib/types/util.d.ts +22 -0
  70. package/lib/umd/index.js +1 -0
  71. package/package.json +67 -0
@@ -0,0 +1,3 @@
1
+ import { ChartModel } from '../chart-model';
2
+ import { ChartTypeBits } from '../../enum';
3
+ export declare const lineLikeContextTransformer: (fromType: ChartTypeBits, toType: ChartTypeBits, model: ChartModel) => void;
@@ -0,0 +1,3 @@
1
+ import { ChartModel } from '../chart-model';
2
+ import { ChartTypeBits } from '../../enum';
3
+ export declare const percentDataContextTransformer: (fromType: ChartTypeBits, toType: ChartTypeBits, model: ChartModel) => void;
@@ -0,0 +1,3 @@
1
+ import { ChartModel } from '../chart-model';
2
+ import { ChartTypeBits } from '../../enum';
3
+ export declare const pieDataContextTransformer: (fromType: ChartTypeBits, toType: ChartTypeBits, model: ChartModel) => void;
@@ -0,0 +1,33 @@
1
+ import { ChartStyle, EChartInstance, EChartSpec, IChartConfig, IChartHostRect, IChartInstance, IChartRenderModel, IChartRenderModelStylizeInit } from '../types';
2
+ import { Disposable } from '@univerjs/core';
3
+ import * as echarts from 'echarts';
4
+ export declare class EChartRenderModel extends Disposable implements IChartRenderModel {
5
+ private _specConverters;
6
+ private _specOperators;
7
+ readonly _addWatermark: boolean;
8
+ constructor(_addWatermark: boolean);
9
+ private _addSpecConverters;
10
+ private _addSpecOperators;
11
+ createChartInstance(): IChartInstance<EChartSpec>;
12
+ toSpec(config: IChartConfig, style: ChartStyle): echarts.EChartsOption;
13
+ stylizeSpec(spec: EChartSpec, stylizeInit: IChartRenderModelStylizeInit<EChartSpec>, rect: IChartHostRect): echarts.EChartsOption | {
14
+ backgroundColor: string;
15
+ };
16
+ }
17
+ export declare class EChartRenderEngine extends Disposable implements EChartInstance {
18
+ [Symbol.dispose](): void;
19
+ static name: string;
20
+ private _instance;
21
+ container: HTMLElement | string;
22
+ private _devicePixelRatio;
23
+ constructor();
24
+ getDevicePixelRatio(): 1 | 2 | undefined;
25
+ mount(id: string | HTMLElement): void;
26
+ resize(): void;
27
+ private _ensureChartInstance;
28
+ get containerElement(): HTMLElement | null;
29
+ render(spec: EChartSpec): void;
30
+ exportImg(): Promise<string>;
31
+ onDispose(): void;
32
+ dispose(): void;
33
+ }
@@ -0,0 +1,2 @@
1
+ import { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
+ export declare const combinationChartConverter: IChartRenderSpecConverter<EChartSpec>;
@@ -0,0 +1,7 @@
1
+ export declare enum SpecField {
2
+ ValueField = "__valueField__",
3
+ SeriesField = "__seriesField__",
4
+ SeriesFieldLabel = "__seriesFieldLabel__",
5
+ CategoryField = "__categoryField__",
6
+ CategoryFieldLabel = "__categoryFieldLabel__"
7
+ }
@@ -0,0 +1,2 @@
1
+ import { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
+ export declare const pieChartConverter: IChartRenderSpecConverter<EChartSpec>;
@@ -0,0 +1,2 @@
1
+ import { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
+ export declare const radarChartConverter: IChartRenderSpecConverter<EChartSpec>;
@@ -0,0 +1,5 @@
1
+ import { IChartConfig } from '../../../types';
2
+ export declare function createLabelMap(config: IChartConfig): {
3
+ categoryNameMap: Record<string, string>;
4
+ seriesNameMap: Record<string, string>;
5
+ };
@@ -0,0 +1,86 @@
1
+ import { Injector } from '@univerjs/core';
2
+ import { ChartTypeBits } from '../../enum';
3
+ import { ChartStyle, IChartContext, IChartHostRect, IUniverDataSet } from '../../types';
4
+ import { ChartModel } from '../chart-model';
5
+ /**
6
+ * The parameters for initializing a chart model.
7
+ */
8
+ export interface IChartModelInitParams {
9
+ /**
10
+ * The type of the chart.
11
+ */
12
+ chartType: ChartTypeBits;
13
+ /**
14
+ * The data source of the chart. The data should be like has dimensions and source.
15
+ * @example
16
+ * ```json
17
+ * {
18
+ * "dimensions": ['a', 'b', 'c'],
19
+ * "source": [
20
+ * [1, 2, 3],
21
+ * [4, 5, 6],
22
+ * [7, 8, 9],
23
+ * ]
24
+ * }
25
+ * ```
26
+ */
27
+ source: IUniverDataSet;
28
+ /**
29
+ * The chart title.
30
+ */
31
+ title: string;
32
+ /**
33
+ * The id of the chart model. This property will be provided by chart model json.
34
+ */
35
+ id?: string;
36
+ /**
37
+ * The context of the chart model. This property will be provided by chart model json.
38
+ */
39
+ context?: Partial<IChartContext>;
40
+ /**
41
+ * The style of the chart model. This property will be provided by chart model json.
42
+ */
43
+ style?: ChartStyle;
44
+ /**
45
+ * The theme name of the chart model. This property will be provided by chart model json.
46
+ */
47
+ themeName?: string;
48
+ }
49
+ /**
50
+ * Convert the initial data to a chart model.
51
+ * @param initJson The initial data of the chart model.
52
+ * @param injector The injector of the chart model.
53
+ * @returns {Promise<ChartModel>} The chart model.
54
+ * @example
55
+ * ```typescript
56
+ * const workbook = univerAPI.getActiveWorkbook()
57
+ * const sheet = workbook.getActiveSheet()
58
+ * const inject = sheet.getInject(); *
59
+ * const data = {
60
+ * dimensions: ['a', 'b', 'c'],
61
+ * source: [['test', 1, 3], ['test1', 2, 2], ['tes2', 3, 1], ['test3', 4, 4], ]
62
+ * } *
63
+ * const initData = {
64
+ * chartType: 4,
65
+ * source: data,
66
+ * title: 'test title',
67
+ * }
68
+ * const model = await window.convertModelFromInitData(initData, inject)
69
+ * const rect = {
70
+ * width: 500,
71
+ * height: 400
72
+ * };
73
+ * console.log(window.convertModelToSpec(model, rect))
74
+ * setTimeout(()=>{
75
+ * console.log('1111',window.convertModelToSpec(model, rect))
76
+ * },1000)
77
+ * ```
78
+ */
79
+ export declare function convertModelFromInitData(initJson: IChartModelInitParams, injector: Injector): Promise<ChartModel>;
80
+ /**
81
+ * Convert the chart model to a chart spec.The spec is a echart option object.
82
+ * @param model The chart model.
83
+ * @param rect The current size of the chart.
84
+ * @returns {EChartSpec} The chart spec.
85
+ */
86
+ export declare function convertModelToSpec(model: ChartModel, rect: IChartHostRect): import('echarts').EChartsOption;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const axisTitleStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const chartAxesOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const chartBoxStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const emptyStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const fontSizeOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const gridStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const hoverMarkStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,13 @@
1
+ export { axisTitleStyleOperator } from './axis-title.operator';
2
+ export { chartAxesOperator } from './chart-axes.operator';
3
+ export { chartBoxStyleOperator } from './chart-box-style.operator';
4
+ export { fontSizeOperator } from './font-size.operator';
5
+ export { hoverMarkStyleOperator } from './hover-mark-style.operator';
6
+ export { invalidValueStyleOperator } from './invalid-value-style.operator';
7
+ export { legendStyleOperator } from './legend-style.operator';
8
+ export { lineLikeStyleOperator } from './line-like-style.operator';
9
+ export { pieStyleOperator } from './pie-style.operator';
10
+ export { seriesStyleOperator } from './series-style-operator/series-style-operator';
11
+ export { stackOperator } from './stack.operator';
12
+ export { chartThemeOperator } from './theme.operator';
13
+ export { chartTitleStyleOperator } from './title-style.operator';
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const invalidValueStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const legendStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const lineLikeStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,7 @@
1
+ export interface ISpecGrid {
2
+ left: number;
3
+ right: number;
4
+ top: number;
5
+ bottom: number;
6
+ containLabel: boolean;
7
+ }
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const pieStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const radarStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const scatterStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { SeriesItemHandler } from './series-style-operator';
2
+ export declare const seriesChartStyleHandler: SeriesItemHandler;
@@ -0,0 +1,2 @@
1
+ import { SeriesItemHandler } from './series-style-operator';
2
+ export declare const seriesDataLabelHandler: SeriesItemHandler;
@@ -0,0 +1,11 @@
1
+ import { ChartStyle, DeepPartial, EChartRenderSpecOperator, EChartSeriesItem, ISeriesStyle } from '../../../../types';
2
+ import { ChartTypeBits } from '../../../../enum';
3
+ export interface ISeriesStyleHandlerContext {
4
+ seriesItem: EChartSeriesItem;
5
+ seriesIndex: number;
6
+ seriesStyle: DeepPartial<ISeriesStyle> | undefined;
7
+ chartStyle: ChartStyle;
8
+ chartType: ChartTypeBits;
9
+ }
10
+ export type SeriesItemHandler = (context: ISeriesStyleHandlerContext, isVerticalSeriesValue: boolean) => void;
11
+ export declare const seriesStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const stackOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const chartThemeOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const chartTitleStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const toolTipStyleOperator: EChartRenderSpecOperator;
@@ -0,0 +1,13 @@
1
+ import { ChartStyle, EChartSeriesItem, EChartSpec, IChartConfig, ILabelStyle } from '../../../types';
2
+ import { ISpecGrid } from './operator-types';
3
+ type PartialLabelStyle = Partial<Pick<ILabelStyle, 'visible' | 'color' | 'fontSize' | 'italic' | 'bold' | 'underline' | 'strikethrough' | 'showMaxLabel' | 'showMinLabel'>>;
4
+ export declare function applyLabelStyle(spec: Record<string, any>, path: string, labelStyle: PartialLabelStyle): void;
5
+ export declare function applyLineStyle(spec: Record<string, any>, path: string, labelStyle: PartialLabelStyle): void;
6
+ export declare function toArray<T = unknown>(value: T | T[]): T[];
7
+ export declare function seriesForEach(series: EChartSpec['series'], func: (item: EChartSeriesItem, index: number) => void): void;
8
+ export declare function toPercentage(value: number, fixed?: number): string;
9
+ export declare const getLegendOrSeriesMaxWidth: (gridInfo: ISpecGrid, config: IChartConfig, style: ChartStyle) => number;
10
+ export declare const getCategoryLabelVertical: (gridInfo: ISpecGrid, style: ChartStyle) => number;
11
+ export declare const getCategoryLabelHorizontal: (gridInfo: ISpecGrid, style: ChartStyle, seriesCount: number, axisLabelMaxWidth?: number) => number;
12
+ export declare const getIntegerValue: (value: number, digit?: number) => number;
13
+ export {};
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const chartWaterMarkerOperator: EChartRenderSpecOperator;
@@ -0,0 +1 @@
1
+ export declare function convertToSpecFromModel(model: any): any;
@@ -0,0 +1,32 @@
1
+ import { Observable, BehaviorSubject } from 'rxjs';
2
+ import { IChartDataSource, IUniverDataSet } from '../types';
3
+ export declare abstract class ChartDataSource implements IChartDataSource {
4
+ protected _data$: BehaviorSubject<IUniverDataSet>;
5
+ /**
6
+ * The data source of the chart
7
+ */
8
+ data$: Observable<IUniverDataSet>;
9
+ protected _canSwitchOrient$: BehaviorSubject<boolean>;
10
+ /**
11
+ * The data source can switch the orient or not
12
+ */
13
+ canSwitchOrient$: Observable<boolean>;
14
+ protected _isRowDirection: BehaviorSubject<boolean>;
15
+ /**
16
+ * The data source is row direction or not
17
+ */
18
+ isRowDirection$: Observable<boolean>;
19
+ /**
20
+ * How to convert the data source to the dataset
21
+ */
22
+ abstract convertDataSet(): IUniverDataSet;
23
+ constructor();
24
+ protected _init(): void;
25
+ setData(data: IUniverDataSet): void;
26
+ updateCanSwitchOrient(flag: boolean): void;
27
+ updateIsRowDirection(flag: boolean): void;
28
+ getDataSet(): IUniverDataSet;
29
+ getDimensionCount(): number;
30
+ refresh(): void;
31
+ dispose(): void;
32
+ }
@@ -0,0 +1,2 @@
1
+ import { OptionDataValue } from '../types';
2
+ export declare function getCategoryData(source: OptionDataValue[][], categoryIndex: number, isRowDirection: boolean): OptionDataValue[];
@@ -0,0 +1,7 @@
1
+ import { IUniverDataSet } from '../types';
2
+ import { ChartDataSource } from './chart-source';
3
+ export declare class StaticChartSource extends ChartDataSource {
4
+ constructor();
5
+ initData(data: IUniverDataSet): void;
6
+ convertDataSet(): IUniverDataSet;
7
+ }
@@ -0,0 +1,271 @@
1
+ import { CellValue, IDisposable, LocaleService, Nullable } from '@univerjs/core';
2
+ import { Observable } from 'rxjs';
3
+ import { AreaLineStyle, AxisAlignEnum, AxisValueType, CategoryType, ChartBorderDashType, ChartTypeBits, DataOrientation, InvalidValueType, IRuntimeAxisPosition, IRuntimeAxisPriority, LabelAlignEnum, LegendPositionEnum, LinePointShape, PieLabelPosition, RadarShape, SelectModeEnum, SeriesLabelPosition, TitlePositionEnum } from './enum';
4
+ import { IEchartTheme } from './model/constants/build-in-theme';
5
+ export type DeepPartial<T> = T extends Record<string, any> ? T extends any[] ? T : {
6
+ [key in keyof T]+?: DeepPartial<T[key]>;
7
+ } : T;
8
+ export interface IChartDataSource {
9
+ data$: Observable<IUniverDataSet>;
10
+ canSwitchOrient$: Observable<boolean>;
11
+ isRowDirection$: Observable<boolean>;
12
+ convertDataSet(): IUniverDataSet;
13
+ dispose(): void;
14
+ getDataSet(): IUniverDataSet;
15
+ getDimensionCount(): number;
16
+ refresh(): void;
17
+ }
18
+ export type ChartDataSourceValue = Nullable<CellValue>;
19
+ export type ChartDataSourceValues = Array<Array<ChartDataSourceValue>>;
20
+ export interface IDimensionDefinition {
21
+ type?: 'number' | 'ordinal' | 'time' | 'float' | 'int';
22
+ name?: string;
23
+ displayName?: string;
24
+ }
25
+ export type DimensionDefinitionLoose = IDimensionDefinition['name'] | IDimensionDefinition;
26
+ export type OptionDataValue = string | number | Date | null | undefined;
27
+ export interface IUniverDataSet {
28
+ source: OptionDataValue[][];
29
+ dimensions: Array<DimensionDefinitionLoose>;
30
+ }
31
+ export interface IChartContext {
32
+ headers?: string[];
33
+ categoryType?: CategoryType;
34
+ categoryIndex?: number;
35
+ categoryResourceIndexes?: number[];
36
+ seriesIndexes?: number[];
37
+ seriesResourceIndexes?: number[];
38
+ transform?: {
39
+ categoryIndex?: number;
40
+ seriesIndexes?: number[];
41
+ };
42
+ }
43
+ export interface IChartData {
44
+ category?: IChartDataCategory;
45
+ headers?: string[];
46
+ series: IChartDataSeries[];
47
+ maxValue: number;
48
+ minValue: number;
49
+ /**
50
+ * the dataset of the chart, it should match echart dataset option
51
+ */
52
+ dataset?: IUniverDataSet;
53
+ }
54
+ export interface IChartDataCategory {
55
+ index: number;
56
+ name: string;
57
+ type: CategoryType;
58
+ items: IChartDataItem[];
59
+ keys: string[];
60
+ }
61
+ export interface IChartDataSeries {
62
+ index: number;
63
+ name: string;
64
+ items: IChartDataItem[];
65
+ }
66
+ interface IChartDataItem {
67
+ value: OptionDataValue;
68
+ label: string;
69
+ }
70
+ export interface IRuntimeAxis {
71
+ priority: IRuntimeAxisPriority;
72
+ position: IRuntimeAxisPosition;
73
+ type: AxisValueType;
74
+ }
75
+ export interface IChartRuntimeContext {
76
+ themeColors?: string[];
77
+ axes: IRuntimeAxis[];
78
+ themeInfo: IEchartTheme;
79
+ hasSecondaryAxis: boolean;
80
+ localeService: LocaleService;
81
+ emptyTips: string;
82
+ }
83
+ export interface ILabelStyle {
84
+ visible: boolean;
85
+ content: string;
86
+ fontSize: number;
87
+ color: string;
88
+ align: LabelAlignEnum;
89
+ bold: boolean;
90
+ family: string;
91
+ strikethrough: boolean;
92
+ italic: boolean;
93
+ underline: boolean;
94
+ padAngle: boolean;
95
+ axisTitleAlign?: AxisAlignEnum | undefined;
96
+ showMaxLabel?: boolean;
97
+ showMinLabel?: boolean;
98
+ }
99
+ export interface ILegendStyle {
100
+ position?: LegendPositionEnum;
101
+ label?: Omit<ILabelStyle, 'visible' | 'align' | 'content'>;
102
+ selectMode?: SelectModeEnum;
103
+ }
104
+ export interface IGridLineStyle {
105
+ visible: boolean;
106
+ color: string;
107
+ width: number;
108
+ }
109
+ export interface IAxisOptions {
110
+ lineVisible: boolean;
111
+ label: Omit<ILabelStyle, 'align' | 'content'>;
112
+ lineStyle: IGridLineStyle;
113
+ gridLine: IGridLineStyle;
114
+ tick: {
115
+ visible: boolean;
116
+ lineWidth: number;
117
+ lineColor: string;
118
+ length: number;
119
+ position: PieLabelPosition;
120
+ };
121
+ reverse?: boolean;
122
+ min?: number | null;
123
+ max?: number | null;
124
+ }
125
+ export interface ISeriesLabelStyle extends ILabelStyle {
126
+ contentType: number;
127
+ position: SeriesLabelPosition;
128
+ }
129
+ export interface IPieLabelStyle extends Omit<ILabelStyle, 'align' | 'content'> {
130
+ contentType: number;
131
+ position: PieLabelPosition;
132
+ }
133
+ export interface IPointStyle {
134
+ shape: LinePointShape;
135
+ size: number;
136
+ color: Nullable<string>;
137
+ }
138
+ export interface IDataPointStyle extends IPointStyle {
139
+ }
140
+ export interface ISeriesStyle {
141
+ chartType?: ChartTypeBits.Line | ChartTypeBits.Column | ChartTypeBits.Area;
142
+ rightYAxis?: boolean;
143
+ color: Nullable<string>;
144
+ fillOpacity: number;
145
+ border: {
146
+ opacity: number;
147
+ color: Nullable<string>;
148
+ width: number;
149
+ dashType: ChartBorderDashType;
150
+ };
151
+ label: ISeriesLabelStyle;
152
+ point: IPointStyle;
153
+ dataPoints: {
154
+ [index: number]: IDataPointStyle;
155
+ };
156
+ }
157
+ export type RightYAxisOptions = Omit<IAxisOptions, 'reverse'>;
158
+ export interface IAllSeriesStyle extends Pick<ISeriesStyle, 'border' | 'label' | 'rightYAxis' | 'point' | 'color'> {
159
+ }
160
+ export interface IChartStyle {
161
+ runtime: IChartRuntimeContext;
162
+ width: number;
163
+ height: number;
164
+ theme: string;
165
+ invalidValueType: InvalidValueType;
166
+ gradientFill: boolean;
167
+ backgroundColor: Nullable<string>;
168
+ titleFontSize: number;
169
+ fontSize: number;
170
+ fontColor: string;
171
+ borderColor: Nullable<string>;
172
+ titles: {
173
+ title: Omit<ILabelStyle, 'visible'>;
174
+ subtitle: Omit<ILabelStyle, 'visible'>;
175
+ xAxisTitle: Omit<ILabelStyle, 'visible'>;
176
+ yAxisTitle: Omit<ILabelStyle, 'visible'>;
177
+ rightYAxisTitle: Omit<ILabelStyle, 'visible'>;
178
+ titlePosition: TitlePositionEnum;
179
+ };
180
+ legend: ILegendStyle;
181
+ xAxis: IAxisOptions;
182
+ yAxis: IAxisOptions;
183
+ rightYAxis: RightYAxisOptions;
184
+ allSeriesStyle: IAllSeriesStyle;
185
+ seriesStyleMap: {
186
+ [id: string]: ISeriesStyle;
187
+ };
188
+ pie: {
189
+ doughnutHole: Nullable<number>;
190
+ labelStyle: IPieLabelStyle;
191
+ borderColor: string;
192
+ hasPaddingAngle: boolean;
193
+ isHalfPie: boolean;
194
+ rosePie: boolean;
195
+ showLabelLine: boolean;
196
+ };
197
+ area: {
198
+ lineStyle: AreaLineStyle;
199
+ };
200
+ radar: {
201
+ shape: RadarShape;
202
+ fill: boolean;
203
+ };
204
+ tooltip: {
205
+ indicatorLabelColor: string;
206
+ indicatorLineType: ChartBorderDashType;
207
+ indicatorLineColor: string;
208
+ indicatorLabelTextColor: string;
209
+ };
210
+ }
211
+ export type ChartStyle = DeepPartial<IChartStyle>;
212
+ export interface IChartDataAggregation {
213
+ aggregate?: boolean;
214
+ topN?: number;
215
+ }
216
+ export interface IChartConfig extends IChartData {
217
+ type: ChartTypeBits;
218
+ }
219
+ export interface IChartSnapshot {
220
+ id: string;
221
+ chartType: ChartTypeBits;
222
+ orient?: DataOrientation;
223
+ context?: Pick<IChartContext, 'categoryIndex' | 'seriesIndexes' | 'transform'>;
224
+ style?: ChartStyle;
225
+ dataAggregation?: IChartDataAggregation;
226
+ }
227
+ export interface IChartRenderSpecConverter<ChartRenderSpec = Record<string, any>> {
228
+ canConvert: (config: IChartConfig) => boolean;
229
+ convert: (config: IChartConfig, style: ChartStyle) => ChartRenderSpec;
230
+ }
231
+ export type ChartConfigInterceptor = (config: IChartConfig) => IChartConfig;
232
+ export type RenderSpecOperator<ChartRenderSpec> = (spec: ChartRenderSpec, style: ChartStyle, config: IChartConfig, instance: IChartInstance) => void;
233
+ export interface IChartRenderModelStylizeInit<Spec> {
234
+ chartStyle: ChartStyle;
235
+ chartConfig: IChartConfig;
236
+ chartInstance?: IChartInstance<Spec>;
237
+ }
238
+ export interface IChartRenderModel<Spec extends Record<string, any> = Record<string, any>> extends IDisposable {
239
+ toSpec(chartConfig: IChartConfig, style: ChartStyle): Spec;
240
+ stylizeSpec(spec: Spec, stylizeInit: IChartRenderModelStylizeInit<Spec>, rect: IChartHostRect): Spec;
241
+ createChartInstance(): IChartInstance<Spec>;
242
+ dispose(): void;
243
+ }
244
+ export interface IChartThemeOptions {
245
+ colors: string[];
246
+ }
247
+ export interface IChartInstance<Spec = Record<string, any>> extends IDisposable {
248
+ container: HTMLElement | string;
249
+ mount(id: string | HTMLElement): void;
250
+ render(spec: Spec): void;
251
+ exportImg(): Promise<string>;
252
+ onDispose?(dispose: () => void): void;
253
+ resize(): void;
254
+ }
255
+ export interface IChartInstanceConstructor<Spec> {
256
+ new (container: HTMLElement | string): IChartInstance<Spec>;
257
+ }
258
+ export type OptionalDataValue = number | string | null | undefined;
259
+ export type ExtractArrayItem<T> = T extends Array<infer U> ? U : never;
260
+ export type EChartSpec = echarts.EChartsOption;
261
+ export type EChartSeriesItem = ExtractArrayItem<EChartSpec['series']> & {
262
+ rawData?: number[];
263
+ seriesId: string;
264
+ };
265
+ export type EChartInstance = IChartInstance<EChartSpec>;
266
+ export type EChartRenderSpecOperator = RenderSpecOperator<EChartSpec>;
267
+ export interface IChartHostRect {
268
+ width: number;
269
+ height: number;
270
+ }
271
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ChartTypeBits } from './enum';
2
+ export declare const chartBitsUtils: {
3
+ has(bit: number, attribute: number): boolean;
4
+ baseOn(bit: number, base: number): boolean;
5
+ remove(bit: number, attribute: number): number;
6
+ chartBitToString(bit: ChartTypeBits): "" | "line" | "pie" | "bar" | "scatter" | "radar" | "combination";
7
+ };
8
+ export declare const setProperty: (data: Record<string, any>, propertyPath: string, value: any) => void;
9
+ /**
10
+ * Set graphic element to data.
11
+ * because we use graphic element to draw watermark title, so we need to set it to data.
12
+ */
13
+ export declare const setGraphicToSpec: (spec: Record<string, any>, graphicElements: unknown[]) => void;
14
+ export declare const translateAngleToRadian: (angle: number) => number;
15
+ interface ISize {
16
+ width: number;
17
+ height: number;
18
+ }
19
+ export declare const ChartTextMeasureCache: Map<string, ISize>;
20
+ export declare const calcPosition: (text: string, font: string) => ISize;
21
+ export declare const clearChartTextMeasureCache: () => void;
22
+ export {};