@univerjs-pro/engine-chart 1.0.0-alpha.1 → 1.0.0-alpha.3
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/README.md +9 -3
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/chart-model-api/chart-model-api.d.ts +2 -0
- package/lib/types/chart-model-api/chart-type-manifest.d.ts +128 -0
- package/lib/types/chart-model-api/chart-type-registry.d.ts +56 -0
- package/lib/types/chart-model-api/chart-type.d.ts +7 -0
- package/lib/types/chart-model-api/constants.d.ts +99 -0
- package/lib/types/chart-model-api/describe.d.ts +3 -0
- package/lib/types/chart-model-api/index.d.ts +8 -0
- package/lib/types/chart-model-api/patch-builder.d.ts +9 -0
- package/lib/types/chart-model-api/series-selector.d.ts +3 -0
- package/lib/types/chart-model-api/types.d.ts +452 -0
- package/lib/types/chart-model-api/utils.d.ts +10 -0
- package/lib/types/chart-model-api/validate.d.ts +5 -0
- package/lib/types/enum.d.ts +8 -0
- package/lib/types/f-base-chart.d.ts +25 -0
- package/lib/types/index.d.ts +119 -13
- package/lib/types/models/chart-data-operators/build-chart-data.d.ts +6 -1
- package/lib/types/models/chart-data-operators/cartesian-point-data.d.ts +43 -0
- package/lib/types/models/chart-data-operators/operators.d.ts +4 -5
- package/lib/types/models/chart-element-axis-id.d.ts +9 -0
- package/lib/types/models/chart-element-edit-overlay/chart-element-edit-overlay.d.ts +38 -0
- package/lib/types/models/chart-element-edit-overlay/index.d.ts +4 -0
- package/lib/types/models/chart-element-edit-overlay/palette.d.ts +2 -0
- package/lib/types/models/chart-element-edit-overlay/resolve-chart-element-hit-layout.d.ts +16 -0
- package/lib/types/models/chart-element-edit-overlay/types.d.ts +20 -0
- package/lib/types/models/chart-host-style.d.ts +35 -0
- package/lib/types/models/chart-model.d.ts +40 -31
- package/lib/types/models/chart-render-input-resolver.d.ts +13 -0
- package/lib/types/models/chart-render-model-manager.service.d.ts +26 -0
- package/lib/types/models/chart-runtime-style.d.ts +1 -0
- package/lib/types/models/constants/build-in-theme/index.d.ts +12 -12
- package/lib/types/models/constants/build-in-theme/univer-gradient1.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer-gradient2.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer-gradient3.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer-gradient4.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer-gradient5.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer-gradient6.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer1.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer2.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer3.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer4.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer5.d.ts +1 -1
- package/lib/types/models/constants/build-in-theme/univer6.d.ts +1 -1
- package/lib/types/models/constants/default.d.ts +3 -1
- package/lib/types/models/echart-render-model.d.ts +43 -4
- package/lib/types/models/image-chart-host.d.ts +18 -0
- package/lib/types/models/mode-converter/mode-converter.d.ts +0 -2
- package/lib/types/models/mode-converter/render-spec-operators/legend-size.d.ts +2 -1
- package/lib/types/models/offscreen-chart-host.d.ts +7 -0
- package/lib/types/models/series-style/series-style-resolver.d.ts +9 -0
- package/lib/types/source/source-util.d.ts +1 -1
- package/lib/types/source/static-chart-source.d.ts +11 -3
- package/lib/types/types.d.ts +188 -35
- package/lib/types/util.d.ts +1 -1
- package/lib/types/wordcloud-chart/adapters/echarts/chart-view.d.ts +2 -2
- package/lib/types/wordcloud-chart/adapters/echarts/install.d.ts +3 -2
- package/lib/types/wordcloud-chart/adapters/echarts/layout-register.d.ts +2 -2
- package/lib/types/wordcloud-chart/adapters/echarts/runtime-cache.d.ts +29 -0
- package/lib/types/wordcloud-chart/adapters/echarts/series-model.d.ts +2 -2
- package/lib/types/wordcloud-chart/core/collision/box-shape-engine.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/collision/engine.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/collision/footprint.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/collision/glyph-shape-engine.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/collision/grid.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/candidates.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/layout-config.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/layout.d.ts +1 -2
- package/lib/types/wordcloud-chart/core/layout/phases.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/place-word.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/placement-stats.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/placement-types.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/placement-word-manager.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/runtime-mask.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/layout/word-prepare.d.ts +1 -1
- package/lib/types/wordcloud-chart/core/shape/shape-mask.d.ts +1 -1
- package/lib/types/wordcloud-chart/index.d.ts +3 -2
- package/lib/types/wordcloud-chart/types.d.ts +2 -0
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
- package/lib/types/wordcloud-chart/core/collision/types.d.ts +0 -1
- package/lib/types/wordcloud-chart/core/layout/types.d.ts +0 -1
- package/lib/types/wordcloud-chart/core/shape/types.d.ts +0 -1
- package/lib/types/wordcloud-chart/core/text/types.d.ts +0 -1
- package/lib/types/wordcloud-chart/core/types/option.d.ts +0 -1
- package/lib/types/wordcloud-chart/core/types/shape.d.ts +0 -1
- package/lib/types/wordcloud-chart/core/types/word.d.ts +0 -1
- package/lib/types/wordcloud-chart/echarts.d.ts +0 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IDisposable, Injector } from '@univerjs/core';
|
|
2
|
+
import type { ChartHostRenderMode, IChartInstance, IChartRenderInstance, IChartRenderInstanceCreateContext, IChartRenderModel, IChartRenderModelImageExportInput, IChartRenderModelImageExportOptions, IChartRenderModelImageExportResult } from '../types';
|
|
3
|
+
import { Disposable } from '@univerjs/core';
|
|
4
|
+
export interface IChartRenderModelManagerService extends IDisposable {
|
|
5
|
+
registerRenderModel(name: string, renderModel: IChartRenderModel): void;
|
|
6
|
+
setRenderModel(name: string): void;
|
|
7
|
+
getRenderModel(name?: string): IChartRenderModel | undefined;
|
|
8
|
+
getCurrentRenderModel(): IChartRenderModel;
|
|
9
|
+
createChartInstance(): IChartInstance;
|
|
10
|
+
createChartInstance(mode: ChartHostRenderMode, context?: IChartRenderInstanceCreateContext): IChartRenderInstance;
|
|
11
|
+
exportImage(input: IChartRenderModelImageExportInput, options?: IChartRenderModelImageExportOptions): Promise<IChartRenderModelImageExportResult>;
|
|
12
|
+
}
|
|
13
|
+
export declare const IChartRenderModelManagerService: import("@wendellhu/redi").IdentifierDecorator<IChartRenderModelManagerService>;
|
|
14
|
+
export declare class ChartRenderModelManagerService extends Disposable implements IChartRenderModelManagerService {
|
|
15
|
+
private readonly _renderModelMap;
|
|
16
|
+
private _currentRenderModel;
|
|
17
|
+
registerRenderModel(name: string, renderModel: IChartRenderModel): void;
|
|
18
|
+
setRenderModel(name: string): void;
|
|
19
|
+
getRenderModel(name?: string): IChartRenderModel | undefined;
|
|
20
|
+
getCurrentRenderModel(): IChartRenderModel;
|
|
21
|
+
createChartInstance(): IChartInstance;
|
|
22
|
+
createChartInstance(mode: ChartHostRenderMode, context?: IChartRenderInstanceCreateContext): IChartRenderInstance;
|
|
23
|
+
exportImage(input: IChartRenderModelImageExportInput, options?: IChartRenderModelImageExportOptions): Promise<IChartRenderModelImageExportResult>;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
}
|
|
26
|
+
export declare function registerChartRenderModelManagerService(injector: Injector, defaultRenderModel?: IChartRenderModel): IChartRenderModelManagerService;
|
|
@@ -10,3 +10,4 @@ import { ChartTypeBits } from '../enum';
|
|
|
10
10
|
* the runtime render style consumed by physical-position operators.
|
|
11
11
|
*/
|
|
12
12
|
export declare function resolveChartRuntimeStyle(style: ChartStyle, chartType?: ChartTypeBits): ChartStyle;
|
|
13
|
+
export declare function resolveChartStyleBackgroundColor(style?: Pick<ChartStyle, 'backgroundColor'> | null): string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export { themeDefault } from './default';
|
|
2
2
|
export { getThemeAxesByType, getThemeProps } from './theme-util';
|
|
3
3
|
export type { IEchartTheme } from './types';
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
4
|
+
export { UniverTheme1 } from './univer1';
|
|
5
|
+
export { UniverTheme2 } from './univer2';
|
|
6
|
+
export { UniverTheme3 } from './univer3';
|
|
7
|
+
export { UniverTheme4 } from './univer4';
|
|
8
|
+
export { UniverTheme5 } from './univer5';
|
|
9
|
+
export { UniverTheme6 } from './univer6';
|
|
10
|
+
export { UniverThemeGradient1 } from './univer-gradient1';
|
|
11
|
+
export { UniverThemeGradient2 } from './univer-gradient2';
|
|
12
|
+
export { UniverThemeGradient3 } from './univer-gradient3';
|
|
13
|
+
export { UniverThemeGradient4 } from './univer-gradient4';
|
|
14
|
+
export { UniverThemeGradient5 } from './univer-gradient5';
|
|
15
|
+
export { UniverThemeGradient6 } from './univer-gradient6';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverThemeGradient1: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverThemeGradient2: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverThemeGradient3: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverThemeGradient4: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverThemeGradient5: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverThemeGradient6: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverTheme1: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverTheme2: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverTheme3: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverTheme4: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverTheme5: IEchartTheme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IEchartTheme } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const UniverTheme6: IEchartTheme;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { ChartStyle } from '../../types';
|
|
1
2
|
export declare const EChartRenderEngineName = "EChartRenderEngine";
|
|
2
3
|
export declare const defaultChartWidth = 468;
|
|
3
4
|
export declare const defaultChartHeight = 369;
|
|
4
5
|
export declare const LegendPadding = 15;
|
|
5
6
|
export declare const TitleOrLegendPadding = 12;
|
|
6
7
|
export declare const TitleDefaultStartPosition = 8;
|
|
7
|
-
export declare const
|
|
8
|
+
export declare const DEFAULT_CHART_LAYOUT_PADDING = 14;
|
|
9
|
+
export declare function getChartLayoutPadding(style?: ChartStyle): number;
|
|
8
10
|
export declare const TitleLineHeightBase = 1.2;
|
|
9
11
|
export declare const AxisLabelMaxPercent = 0.15;
|
|
10
12
|
export declare const defaultBubbleSize = 0.12;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ChartStyle, EChartInstance, EChartSpec, IChartConfig, IChartHostRect, IChartInstance, IChartRenderModel, IChartRenderModelStylizeInit } from '../types';
|
|
1
|
+
import type { ChartElementEventHandler, ChartElementEventType, ChartImageSource, ChartStyle, EChartInstance, EChartSpec, IChartConfig, IChartHostRect, IChartInstance, IChartRenderAsImageOptions, IChartRenderInstance, IChartRenderInstanceCreateContext, IChartRenderModel, IChartRenderModelImageExportInput, IChartRenderModelImageExportOptions, IChartRenderModelImageExportResult, IChartRenderModelStylizeInit, IChartRenderRuntimeOptions } from '../types';
|
|
2
2
|
import type { IWordCloudRenderConfig } from '../wordcloud-chart/word-cloud-render-config';
|
|
3
3
|
import { Disposable } from '@univerjs/core';
|
|
4
|
+
import { ChartHostRenderMode } from '../types';
|
|
4
5
|
export interface IEChartRenderModelOptions {
|
|
5
6
|
wordCloudRenderConfig?: IWordCloudRenderConfig;
|
|
6
7
|
}
|
|
@@ -14,24 +15,62 @@ export declare class EChartRenderModel extends Disposable implements IChartRende
|
|
|
14
15
|
private _addSpecConverters;
|
|
15
16
|
private _addSpecOperators;
|
|
16
17
|
createChartInstance(): IChartInstance<EChartSpec>;
|
|
18
|
+
createChartInstance(mode: ChartHostRenderMode, context?: IChartRenderInstanceCreateContext<EChartSpec>): IChartRenderInstance;
|
|
19
|
+
clearRuntimeCache(chartId: string): void;
|
|
20
|
+
clearAllRuntimeCache(): void;
|
|
21
|
+
dispose(): void;
|
|
17
22
|
toSpec(config: IChartConfig, style: ChartStyle): import("echarts").EChartsOption;
|
|
18
23
|
stylizeSpec(spec: EChartSpec, stylizeInit: IChartRenderModelStylizeInit<EChartSpec>, rect: IChartHostRect): import("echarts").EChartsOption | {
|
|
19
24
|
backgroundColor: string;
|
|
20
25
|
};
|
|
26
|
+
exportImage(input: IChartRenderModelImageExportInput, options?: IChartRenderModelImageExportOptions): Promise<IChartRenderModelImageExportResult>;
|
|
21
27
|
}
|
|
22
28
|
export declare class EChartRenderEngine extends Disposable implements EChartInstance {
|
|
23
29
|
static engineName: string;
|
|
24
30
|
private _instance;
|
|
25
31
|
container: HTMLElement | string;
|
|
26
32
|
private _devicePixelRatio;
|
|
33
|
+
private _lastSpec;
|
|
34
|
+
private readonly _eventHandlers;
|
|
35
|
+
private readonly _nativeEventHandlers;
|
|
36
|
+
private readonly _nativeZrBlankEventHandlers;
|
|
37
|
+
private readonly _elementEditModeHandlers;
|
|
38
|
+
private _elementEditModeZrMouseMoveHandler;
|
|
39
|
+
private _elementEditModeZrClickHandler;
|
|
40
|
+
private _elementEditModeEnabled;
|
|
41
|
+
private _editOverlay;
|
|
42
|
+
private readonly _emittedElementEventKeys;
|
|
43
|
+
private _emittedElementEventKeysClearQueued;
|
|
27
44
|
constructor();
|
|
28
45
|
getDevicePixelRatio(): 1 | 2 | undefined;
|
|
29
46
|
mount(id: string | HTMLElement): void;
|
|
30
|
-
resize(
|
|
47
|
+
resize(echartsProviderOrOptions?: any | IChartRenderRuntimeOptions): void;
|
|
31
48
|
private _ensureChartInstance;
|
|
32
49
|
get containerElement(): HTMLElement | null;
|
|
33
|
-
render(spec: EChartSpec,
|
|
50
|
+
render(spec: EChartSpec, echartsProviderOrOptions?: any | IChartRenderRuntimeOptions): void;
|
|
51
|
+
renderAsImage(spec: EChartSpec, options: IChartRenderAsImageOptions): Promise<ChartImageSource>;
|
|
52
|
+
on(type: ChartElementEventType, handler: ChartElementEventHandler): {
|
|
53
|
+
dispose: () => void;
|
|
54
|
+
};
|
|
55
|
+
setElementEditMode(enabled: boolean): void;
|
|
56
|
+
private _bindAllNativeEvents;
|
|
57
|
+
private _bindNativeEvent;
|
|
58
|
+
private _unbindNativeEvent;
|
|
59
|
+
private _bindNativeZrBlankEvent;
|
|
60
|
+
private _unbindNativeZrBlankEvent;
|
|
61
|
+
private _bindElementEditModeEvents;
|
|
62
|
+
private _unbindElementEditModeEvents;
|
|
63
|
+
private _emitChartElementEvent;
|
|
64
|
+
private _shouldSkipDuplicateElementEvent;
|
|
65
|
+
private _handleElementEditHover;
|
|
66
|
+
private _handleElementEditZrHover;
|
|
67
|
+
private _handleElementEditClick;
|
|
68
|
+
private _handleElementEditZrClick;
|
|
69
|
+
private _hideTooltip;
|
|
70
|
+
private _ensureEditOverlay;
|
|
71
|
+
private _removeEditOverlay;
|
|
72
|
+
private _clearHoverBorder;
|
|
73
|
+
private _clearFixedBorder;
|
|
34
74
|
exportImg(echartsProvider?: any): Promise<string>;
|
|
35
|
-
onDispose(): void;
|
|
36
75
|
dispose(): void;
|
|
37
76
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChartImageSource, IChartHostLease, IChartHostRect, IChartHostStyle, IImageChartHost } from '../types';
|
|
2
|
+
import { Disposable } from '@univerjs/core';
|
|
3
|
+
import { ChartHostRenderMode } from '../types';
|
|
4
|
+
export declare function chartImageSourceToDataUrl(image: ChartImageSource): string;
|
|
5
|
+
export declare abstract class ImageChartHost extends Disposable implements IImageChartHost {
|
|
6
|
+
readonly chartId: string;
|
|
7
|
+
readonly mode = ChartHostRenderMode.Image;
|
|
8
|
+
private readonly _offscreenChartHost;
|
|
9
|
+
constructor(chartId: string);
|
|
10
|
+
abstract getRect(): IChartHostRect | null;
|
|
11
|
+
abstract setStyle(style: IChartHostStyle): void;
|
|
12
|
+
abstract nextVersion(): number;
|
|
13
|
+
abstract commitSnapshot(image: ChartImageSource, version: number): boolean;
|
|
14
|
+
abstract requestPaint(): void;
|
|
15
|
+
abstract invalidateSnapshot(): void;
|
|
16
|
+
acquireOffscreenHost(rect: IChartHostRect): IChartHostLease;
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
@@ -2,7 +2,6 @@ import type { Injector } from '@univerjs/core';
|
|
|
2
2
|
import type { ChartTypeBits } from '../../enum';
|
|
3
3
|
import type { ChartStyle, IChartContext, IChartHostRect, IUniverDataSet } from '../../types';
|
|
4
4
|
import type { IChartLocaleTexts } from '../chart-locale-texts';
|
|
5
|
-
import { StaticChartSource } from '../../source/static-chart-source';
|
|
6
5
|
import { ChartModel } from '../chart-model';
|
|
7
6
|
/**
|
|
8
7
|
* The parameters for initializing a chart model.
|
|
@@ -53,7 +52,6 @@ export interface IChartModelInitParams {
|
|
|
53
52
|
isRowDirection?: boolean;
|
|
54
53
|
localeTexts?: IChartLocaleTexts;
|
|
55
54
|
}
|
|
56
|
-
export declare function generateChartModelContext(chartModel: ChartModel, dataSource: StaticChartSource): IChartContext;
|
|
57
55
|
/**
|
|
58
56
|
* Convert the initial data to a chart model.
|
|
59
57
|
* @param initJson The initial data of the chart model.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IChartHostLease, IChartHostRect } from '../types';
|
|
2
|
+
import { Disposable } from '@univerjs/core';
|
|
3
|
+
export declare class OffscreenChartHost extends Disposable {
|
|
4
|
+
private readonly _leases;
|
|
5
|
+
acquire(rect: IChartHostRect): IChartHostLease;
|
|
6
|
+
dispose(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type SeriesStyleKeyInput = string | number | null | undefined;
|
|
2
|
+
export interface ISeriesStyleSource {
|
|
3
|
+
seriesId?: SeriesStyleKeyInput;
|
|
4
|
+
seriesIndex?: SeriesStyleKeyInput;
|
|
5
|
+
baseSeriesIndex?: SeriesStyleKeyInput;
|
|
6
|
+
}
|
|
7
|
+
export declare function getSeriesStyleKey(source: ISeriesStyleSource): string | undefined;
|
|
8
|
+
export declare function resolveSeriesStyle<T extends object>(seriesStyleMap: Partial<Record<string, T | undefined>> | undefined, source: ISeriesStyleSource, fallbackSources?: readonly ISeriesStyleSource[]): T | undefined;
|
|
9
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OptionDataValue } from '../types';
|
|
2
2
|
import { ChartSourceDataTypeEnum } from '../enum';
|
|
3
|
-
export declare function getCategoryData(source: OptionDataValue[][], categoryIndex: number,
|
|
3
|
+
export declare function getCategoryData(source: OptionDataValue[][], categoryIndex: number, sourceType?: ChartSourceDataTypeEnum[][]): {
|
|
4
4
|
categoryData: Array<OptionDataValue | undefined>;
|
|
5
5
|
isAllDateTime: boolean;
|
|
6
6
|
};
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import type { IUniverDataSet } from '../types';
|
|
2
2
|
import { BehaviorSubject } from 'rxjs';
|
|
3
3
|
import { ChartDataSource } from './chart-source';
|
|
4
|
+
/**
|
|
5
|
+
* Legacy static init data uses `dimensions` as the table header row and
|
|
6
|
+
* `source` as row-major table cells. StaticChartSource adapts that input to the
|
|
7
|
+
* canonical vector-based IUniverDataSet returned by convertDataSet().
|
|
8
|
+
*/
|
|
9
|
+
type ILegacyTableDataSet = IUniverDataSet;
|
|
4
10
|
export declare class StaticChartSource extends ChartDataSource {
|
|
5
11
|
_canSwitchOrient$: BehaviorSubject<boolean>;
|
|
6
|
-
private
|
|
12
|
+
private _rawDataSet;
|
|
13
|
+
private _convertedDataSetCache;
|
|
7
14
|
constructor();
|
|
8
|
-
initData(data:
|
|
9
|
-
setData(data:
|
|
15
|
+
initData(data: ILegacyTableDataSet, isRowDirection?: boolean): void;
|
|
16
|
+
setData(data: ILegacyTableDataSet): void;
|
|
10
17
|
updateIsRowDirection(flag: boolean): void;
|
|
11
18
|
refresh(): void;
|
|
12
19
|
convertDataSet(): IUniverDataSet;
|
|
13
20
|
dispose(): void;
|
|
14
21
|
}
|
|
22
|
+
export {};
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IDisposable, Nullable } from '@univerjs/core';
|
|
2
2
|
import type { Observable } from 'rxjs';
|
|
3
3
|
import type { AreaLineStyle, AxisAlignEnum, AxisValueType, CategoryType, ChartBorderDashType, ChartSourceDataTypeEnum, ChartTrendlineType, ChartTypeBits, DataOrientation, InvalidValueType, IRuntimeAxisPosition, IRuntimeAxisPriority, LabelAlignEnum, LegendPositionEnum, LinePointShape, PieLabelPosition, RadarShape, RelationChartLayoutEnum, SelectModeEnum, SeriesLabelPosition, TitlePositionEnum, WaterfallSeriesTypeEnum, WaterfallStackTypeEnum, WordCloudShapeEnum } from './enum';
|
|
4
|
+
import type { ICartesianPointData } from './models/chart-data-operators/cartesian-point-data';
|
|
4
5
|
import type { IChartLocaleTexts } from './models/chart-locale-texts';
|
|
5
6
|
import type { IEchartTheme } from './models/constants/build-in-theme';
|
|
6
7
|
import type { BarSeriesOption } from './utils/echarts';
|
|
@@ -28,6 +29,17 @@ export type DimensionDefinitionLoose = IDimensionDefinition['name'] | IDimension
|
|
|
28
29
|
export type OptionDataValue = string | number | Date | null | undefined;
|
|
29
30
|
export type ChartDataSourceValue = OptionDataValue;
|
|
30
31
|
export type ChartDataSourceValues = ChartDataSourceValue[][];
|
|
32
|
+
/**
|
|
33
|
+
* Canonical chart dataset used by chart context operators and chart-data builders.
|
|
34
|
+
*
|
|
35
|
+
* Adapters must normalize their raw input before exposing this shape:
|
|
36
|
+
* - `dimensions[index]` is the optional header label for `source[index]`.
|
|
37
|
+
* - `source[index]` is one logical data vector, already oriented by the adapter.
|
|
38
|
+
* - `sourceType` and `sourceLabels`, when present, have the same vector shape as `source`.
|
|
39
|
+
*
|
|
40
|
+
* Category detection reads from `source` vectors only. `dimensions` must not be
|
|
41
|
+
* used as a fallback category vector.
|
|
42
|
+
*/
|
|
31
43
|
export interface IUniverDataSet {
|
|
32
44
|
source: OptionDataValue[][];
|
|
33
45
|
dimensions: Array<DimensionDefinitionLoose>;
|
|
@@ -49,15 +61,15 @@ export interface IChartContext {
|
|
|
49
61
|
categoryIndex?: number;
|
|
50
62
|
seriesIndexes?: number[];
|
|
51
63
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
scatterXIndex?: number;
|
|
65
|
+
scatterYIndex?: number;
|
|
66
|
+
scatterLabelIndex?: number;
|
|
67
|
+
bubbleSizeIndex?: number;
|
|
68
|
+
bubbleSeriesIndex?: number;
|
|
57
69
|
}
|
|
58
70
|
export interface IRelationNodes {
|
|
59
71
|
id: string;
|
|
60
|
-
category
|
|
72
|
+
category?: string;
|
|
61
73
|
name: string;
|
|
62
74
|
value: number;
|
|
63
75
|
symbolSize?: number;
|
|
@@ -80,34 +92,7 @@ export interface IChartData {
|
|
|
80
92
|
* the dataset of the chart, it should match echart dataset option
|
|
81
93
|
*/
|
|
82
94
|
dataset?: IUniverDataSet;
|
|
83
|
-
|
|
84
|
-
bubbleSizeData?: {
|
|
85
|
-
id: string;
|
|
86
|
-
name: string;
|
|
87
|
-
items: IChartDataItem[];
|
|
88
|
-
};
|
|
89
|
-
bubbleXData?: {
|
|
90
|
-
id: string;
|
|
91
|
-
name: string;
|
|
92
|
-
items: IChartDataItem[];
|
|
93
|
-
};
|
|
94
|
-
bubbleYData?: {
|
|
95
|
-
id: string;
|
|
96
|
-
name: string;
|
|
97
|
-
items: IChartDataItem[];
|
|
98
|
-
};
|
|
99
|
-
bubbleLabelData?: {
|
|
100
|
-
id: string;
|
|
101
|
-
name: string;
|
|
102
|
-
items: IChartDataItem[];
|
|
103
|
-
};
|
|
104
|
-
bubbleSeriesData?: {
|
|
105
|
-
id: string;
|
|
106
|
-
name: string;
|
|
107
|
-
items: IChartDataItem[];
|
|
108
|
-
};
|
|
109
|
-
isValidateBubbleSource?: boolean;
|
|
110
|
-
};
|
|
95
|
+
cartesianPoint?: ICartesianPointData;
|
|
111
96
|
heatmapData?: {
|
|
112
97
|
xData: string[];
|
|
113
98
|
yData: string[];
|
|
@@ -167,6 +152,8 @@ export interface IChartRuntimeContext {
|
|
|
167
152
|
axes: IRuntimeAxis[];
|
|
168
153
|
themeInfo: IEchartTheme;
|
|
169
154
|
wordCloudRenderConfig?: IWordCloudRenderConfig;
|
|
155
|
+
/** Runtime-only extra inset reserved by host adapters around chart content. */
|
|
156
|
+
layoutInset?: number;
|
|
170
157
|
/**
|
|
171
158
|
* The function to transform the color to the render color with considering the system theme is dark mode or not.
|
|
172
159
|
* @param {string} color - The color to be rendered.
|
|
@@ -326,6 +313,8 @@ export interface IChartStyle {
|
|
|
326
313
|
trendlines: ITrendLine[];
|
|
327
314
|
pie: {
|
|
328
315
|
doughnutHole: Nullable<number>;
|
|
316
|
+
/** Slice offset as a ratio of the pie radius. */
|
|
317
|
+
explosion?: number;
|
|
329
318
|
labelStyle: IPieLabelStyle;
|
|
330
319
|
borderColor: string;
|
|
331
320
|
hasPaddingAngle: boolean;
|
|
@@ -375,6 +364,7 @@ export interface IChartStyle {
|
|
|
375
364
|
pareto: {
|
|
376
365
|
lineStyle: ISeriesStyle;
|
|
377
366
|
barStyle: ISeriesStyle;
|
|
367
|
+
includeZeroValues?: boolean;
|
|
378
368
|
};
|
|
379
369
|
heatmap: {
|
|
380
370
|
visualMapType: 'continuous' | 'piecewise';
|
|
@@ -413,6 +403,89 @@ export interface IChartRenderSpecConverter<ChartRenderSpec = Record<string, any>
|
|
|
413
403
|
}
|
|
414
404
|
export type ChartConfigInterceptor = (config: IChartConfig) => IChartConfig;
|
|
415
405
|
export type RenderSpecOperator<ChartRenderSpec> = (spec: ChartRenderSpec, style: ChartStyle, config: IChartConfig, instance: IChartInstance) => void;
|
|
406
|
+
export declare enum ChartHostRenderMode {
|
|
407
|
+
Image = "image",
|
|
408
|
+
Dom = "dom"
|
|
409
|
+
}
|
|
410
|
+
export interface IChartHostBorderStyle {
|
|
411
|
+
color?: string;
|
|
412
|
+
width?: number;
|
|
413
|
+
}
|
|
414
|
+
export interface IChartHostStyle {
|
|
415
|
+
stroke?: string;
|
|
416
|
+
fill?: string;
|
|
417
|
+
border?: IChartHostBorderStyle;
|
|
418
|
+
radius?: number;
|
|
419
|
+
[key: string]: any;
|
|
420
|
+
}
|
|
421
|
+
export interface IChartHostLease extends IDisposable {
|
|
422
|
+
readonly mountNode: HTMLElement;
|
|
423
|
+
}
|
|
424
|
+
export interface IChartHost extends IDisposable {
|
|
425
|
+
readonly chartId: string;
|
|
426
|
+
readonly mode: ChartHostRenderMode;
|
|
427
|
+
getRect(): IChartHostRect | null;
|
|
428
|
+
setStyle(style: IChartHostStyle): void;
|
|
429
|
+
}
|
|
430
|
+
export interface IImageChartHost extends IChartHost {
|
|
431
|
+
readonly mode: ChartHostRenderMode.Image;
|
|
432
|
+
nextVersion(): number;
|
|
433
|
+
commitSnapshot(image: ChartImageSource, version: number): boolean;
|
|
434
|
+
requestPaint(): void;
|
|
435
|
+
invalidateSnapshot(): void;
|
|
436
|
+
acquireOffscreenHost(rect: IChartHostRect): IChartHostLease;
|
|
437
|
+
}
|
|
438
|
+
export interface IDomChartHost extends IChartHost {
|
|
439
|
+
readonly mode: ChartHostRenderMode.Dom;
|
|
440
|
+
ensureMount(): Promise<HTMLElement | null>;
|
|
441
|
+
checkMounted(): boolean;
|
|
442
|
+
syncLayout(): void;
|
|
443
|
+
markReady(): void;
|
|
444
|
+
markNotReady(): void;
|
|
445
|
+
}
|
|
446
|
+
export interface IChartRenderInput {
|
|
447
|
+
chartId: string;
|
|
448
|
+
config: IChartConfig;
|
|
449
|
+
style: ChartStyle;
|
|
450
|
+
}
|
|
451
|
+
export interface IChartRenderModelImageExportInput extends IChartRenderInput {
|
|
452
|
+
width: number;
|
|
453
|
+
height: number;
|
|
454
|
+
}
|
|
455
|
+
export interface IChartRenderModelImageExportOptions {
|
|
456
|
+
pixelRatio?: number;
|
|
457
|
+
backgroundColor?: string | null;
|
|
458
|
+
}
|
|
459
|
+
export interface IChartRenderModelImageExportResult {
|
|
460
|
+
dataUrl: string;
|
|
461
|
+
width: number;
|
|
462
|
+
height: number;
|
|
463
|
+
pixelRatio: number;
|
|
464
|
+
}
|
|
465
|
+
export interface IChartRenderInstance extends IDisposable {
|
|
466
|
+
readonly mode: ChartHostRenderMode;
|
|
467
|
+
bind(host: IChartHost): void;
|
|
468
|
+
render(input: IChartRenderInput): Promise<void>;
|
|
469
|
+
exportImg(): Promise<string | undefined>;
|
|
470
|
+
resize(): void;
|
|
471
|
+
on(type: ChartElementEventType, handler: ChartElementEventHandler): IDisposable;
|
|
472
|
+
setElementEditMode(enabled: boolean): void;
|
|
473
|
+
}
|
|
474
|
+
export interface IChartRenderInstanceStyleInput<Spec = Record<string, any>> extends IChartRenderInput {
|
|
475
|
+
mode: ChartHostRenderMode;
|
|
476
|
+
spec?: Spec;
|
|
477
|
+
}
|
|
478
|
+
export interface IChartRenderInstanceSpecInput<Spec = Record<string, any>> extends IChartRenderInput {
|
|
479
|
+
mode: ChartHostRenderMode;
|
|
480
|
+
spec: Spec;
|
|
481
|
+
}
|
|
482
|
+
export interface IChartRenderInstanceCreateContext<Spec = Record<string, any>> {
|
|
483
|
+
resolveHostStyle?: (input: IChartRenderInstanceStyleInput<Spec>) => IChartHostStyle;
|
|
484
|
+
resolveRenderBackgroundColor?: (input: IChartRenderInstanceStyleInput<Spec> & {
|
|
485
|
+
hostStyle: IChartHostStyle;
|
|
486
|
+
}) => string | undefined;
|
|
487
|
+
prepareSpec?: (input: IChartRenderInstanceSpecInput<Spec>) => Spec;
|
|
488
|
+
}
|
|
416
489
|
export interface IChartRenderModelStylizeInit<Spec> {
|
|
417
490
|
chartStyle: ChartStyle;
|
|
418
491
|
chartConfig: IChartConfig;
|
|
@@ -421,19 +494,99 @@ export interface IChartRenderModelStylizeInit<Spec> {
|
|
|
421
494
|
export interface IChartRenderModel<Spec extends Record<string, any> = Record<string, any>> extends IDisposable {
|
|
422
495
|
toSpec(chartConfig: IChartConfig, style: ChartStyle): Spec;
|
|
423
496
|
stylizeSpec(spec: Spec, stylizeInit: IChartRenderModelStylizeInit<Spec>, rect: IChartHostRect): Spec;
|
|
497
|
+
exportImage(input: IChartRenderModelImageExportInput, options?: IChartRenderModelImageExportOptions): Promise<IChartRenderModelImageExportResult>;
|
|
424
498
|
updateWatermark(addWatermark: boolean): void;
|
|
425
499
|
createChartInstance(): IChartInstance<Spec>;
|
|
500
|
+
createChartInstance(mode: ChartHostRenderMode, context?: IChartRenderInstanceCreateContext<Spec>): IChartRenderInstance;
|
|
501
|
+
clearRuntimeCache?(chartId: string): void;
|
|
502
|
+
clearAllRuntimeCache?(): void;
|
|
426
503
|
dispose(): void;
|
|
427
504
|
}
|
|
428
505
|
export interface IChartThemeOptions {
|
|
429
506
|
colors: string[];
|
|
430
507
|
}
|
|
508
|
+
export declare enum ChartImageSourceType {
|
|
509
|
+
Url = "url",
|
|
510
|
+
Canvas = "canvas",
|
|
511
|
+
ImageBitmap = "imageBitmap"
|
|
512
|
+
}
|
|
513
|
+
export type ChartImageSource = {
|
|
514
|
+
type: ChartImageSourceType.Url;
|
|
515
|
+
url: string;
|
|
516
|
+
} | {
|
|
517
|
+
type: ChartImageSourceType.Canvas;
|
|
518
|
+
canvas: HTMLCanvasElement;
|
|
519
|
+
} | {
|
|
520
|
+
type: ChartImageSourceType.ImageBitmap;
|
|
521
|
+
imageBitmap: ImageBitmap;
|
|
522
|
+
};
|
|
523
|
+
export interface IChartRenderAsImageOptions {
|
|
524
|
+
width: number;
|
|
525
|
+
height: number;
|
|
526
|
+
pixelRatio?: number;
|
|
527
|
+
backgroundColor?: string;
|
|
528
|
+
echartsProvider?: any;
|
|
529
|
+
chartId?: string;
|
|
530
|
+
host: HTMLElement;
|
|
531
|
+
}
|
|
532
|
+
export interface IChartRenderRuntimeOptions {
|
|
533
|
+
echartsProvider?: any;
|
|
534
|
+
chartId?: string;
|
|
535
|
+
width?: number;
|
|
536
|
+
height?: number;
|
|
537
|
+
}
|
|
538
|
+
export type ChartElementKind = 'blank' | 'chartArea' | 'title' | 'subtitle' | 'xAxisTitle' | 'yAxisTitle' | 'rightYAxisTitle' | 'xAxisLabel' | 'yAxisLabel' | 'rightYAxisLabel' | 'xAxisLine' | 'yAxisLine' | 'rightYAxisLine' | 'gridLine' | 'tick' | 'legend' | 'legendItem' | 'mark' | 'series' | 'dataPoint' | 'dataLabel';
|
|
539
|
+
export interface IChartElementBounds {
|
|
540
|
+
left: number;
|
|
541
|
+
top: number;
|
|
542
|
+
right: number;
|
|
543
|
+
bottom: number;
|
|
544
|
+
}
|
|
545
|
+
export interface IChartElementOverlay {
|
|
546
|
+
type: 'rect' | 'circle' | 'polyline' | 'polygon' | 'sector';
|
|
547
|
+
bounds: IChartElementBounds;
|
|
548
|
+
shape?: Record<string, any>;
|
|
549
|
+
padding?: number;
|
|
550
|
+
items?: IChartElementOverlay[];
|
|
551
|
+
}
|
|
552
|
+
export interface IChartElementHit {
|
|
553
|
+
kind: ChartElementKind;
|
|
554
|
+
bounds?: IChartElementBounds;
|
|
555
|
+
overlay?: IChartElementOverlay;
|
|
556
|
+
axisId?: 'xAxis' | 'yAxis' | 'rightYAxis';
|
|
557
|
+
axisIndex?: number;
|
|
558
|
+
axisPosition?: 'top' | 'right' | 'bottom' | 'left';
|
|
559
|
+
legendIndex?: number;
|
|
560
|
+
legendName?: string;
|
|
561
|
+
seriesIndex?: number;
|
|
562
|
+
seriesId?: string;
|
|
563
|
+
seriesName?: string;
|
|
564
|
+
dataIndex?: number;
|
|
565
|
+
baseSeriesIndex?: string;
|
|
566
|
+
waterfallSeriesType?: WaterfallSeriesTypeEnum;
|
|
567
|
+
}
|
|
568
|
+
export type ChartElementEventType = 'click' | 'dblclick' | 'pointerdown' | 'pointerup' | 'pointermove' | 'pointerenter' | 'pointerleave';
|
|
569
|
+
export interface IChartElementEvent {
|
|
570
|
+
type: ChartElementEventType;
|
|
571
|
+
hit: IChartElementHit;
|
|
572
|
+
localPoint: {
|
|
573
|
+
x: number;
|
|
574
|
+
y: number;
|
|
575
|
+
};
|
|
576
|
+
button?: number;
|
|
577
|
+
nativeEvent?: Event;
|
|
578
|
+
preventDefault?(): void;
|
|
579
|
+
}
|
|
580
|
+
export type ChartElementEventHandler = (event: IChartElementEvent) => void;
|
|
431
581
|
export interface IChartInstance<Spec = Record<string, any>> extends IDisposable {
|
|
432
582
|
container: HTMLElement | string;
|
|
433
583
|
mount(id: string | HTMLElement): void;
|
|
434
584
|
render(spec: Spec, echartsProvider?: any): void;
|
|
585
|
+
render(spec: Spec, options?: IChartRenderRuntimeOptions): void;
|
|
586
|
+
renderAsImage(spec: Spec, options: IChartRenderAsImageOptions): Promise<ChartImageSource>;
|
|
587
|
+
on(type: ChartElementEventType, handler: ChartElementEventHandler): IDisposable;
|
|
588
|
+
setElementEditMode(enabled: boolean): void;
|
|
435
589
|
exportImg(): Promise<string>;
|
|
436
|
-
onDispose?(dispose: () => void): void;
|
|
437
590
|
resize(): void;
|
|
438
591
|
}
|
|
439
592
|
export interface IChartInstanceConstructor<Spec> {
|
package/lib/types/util.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const chartBitsUtils: {
|
|
|
3
3
|
has(bit: number, attribute: number): boolean;
|
|
4
4
|
baseOn(bit: number, base: number): boolean;
|
|
5
5
|
remove(bit: number, attribute: number): number;
|
|
6
|
-
chartBitToString(bit: ChartTypeBits): "" | "line" | "
|
|
6
|
+
chartBitToString(bit: ChartTypeBits): "" | "line" | "bar" | "wordCloud" | "scatter" | "pie" | "radar" | "graph" | "funnel" | "sankey" | "boxplot" | "heatmap" | "combination";
|
|
7
7
|
};
|
|
8
8
|
export declare const setProperty: (data: Record<string, any>, propertyPath: string, value: any) => void;
|
|
9
9
|
export declare const getProperty: <T = any>(data: Record<string, any> | undefined, propertyPath: string) => T | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { echarts
|
|
1
|
+
import type { echarts } from '../../../utils/echarts';
|
|
2
2
|
import { WORD_CLOUD_SERIES_TYPE } from './echarts-options';
|
|
3
3
|
export interface IRegisterWordCloudChartViewContext {
|
|
4
4
|
createTextElement(layout: any, data: any, dataIndex: number, seriesModel: any): unknown;
|
|
5
5
|
}
|
|
6
|
-
export declare function registerWordCloudChartView(
|
|
6
|
+
export declare function registerWordCloudChartView(echartsInstance: typeof echarts, context: IRegisterWordCloudChartViewContext): void;
|
|
7
7
|
export { WORD_CLOUD_SERIES_TYPE };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { echarts
|
|
1
|
+
import type { echarts } from '../../../utils/echarts';
|
|
2
2
|
import type { IWordCloudEChartsSeriesOption } from '../../types';
|
|
3
|
-
export declare function registerWordCloudChart(
|
|
3
|
+
export declare function registerWordCloudChart(echartsInstance: typeof echarts): typeof echarts;
|
|
4
|
+
export declare function waitForWordCloudImageResourcesReady(spec: unknown, timeout?: number): Promise<void>;
|
|
4
5
|
export type { IWordCloudEChartsSeriesOption };
|