@univerjs-pro/sheets-chart 1.0.0-alpha.2 → 1.0.0-alpha.4
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 +8 -2
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/ar-SA.js +1 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/de-DE.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/id-ID.js +1 -1
- package/lib/cjs/locale/it-IT.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/pl-PL.js +1 -1
- package/lib/cjs/locale/pt-BR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-HK.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/es/locale/ar-SA.js +1 -1
- package/lib/es/locale/ca-ES.js +1 -1
- package/lib/es/locale/de-DE.js +1 -1
- package/lib/es/locale/en-US.js +1 -1
- package/lib/es/locale/es-ES.js +1 -1
- package/lib/es/locale/fa-IR.js +1 -1
- package/lib/es/locale/fr-FR.js +1 -1
- package/lib/es/locale/id-ID.js +1 -1
- package/lib/es/locale/it-IT.js +1 -1
- package/lib/es/locale/ja-JP.js +1 -1
- package/lib/es/locale/ko-KR.js +1 -1
- package/lib/es/locale/pl-PL.js +1 -1
- package/lib/es/locale/pt-BR.js +1 -1
- package/lib/es/locale/ru-RU.js +1 -1
- package/lib/es/locale/sk-SK.js +1 -1
- package/lib/es/locale/vi-VN.js +1 -1
- package/lib/es/locale/zh-CN.js +1 -1
- package/lib/es/locale/zh-HK.js +1 -1
- package/lib/es/locale/zh-TW.js +1 -1
- package/lib/facade.js +1 -1
- package/lib/index.js +1 -1
- package/lib/locale/ar-SA.js +1 -1
- package/lib/locale/ca-ES.js +1 -1
- package/lib/locale/de-DE.js +1 -1
- package/lib/locale/en-US.js +1 -1
- package/lib/locale/es-ES.js +1 -1
- package/lib/locale/fa-IR.js +1 -1
- package/lib/locale/fr-FR.js +1 -1
- package/lib/locale/id-ID.js +1 -1
- package/lib/locale/it-IT.js +1 -1
- package/lib/locale/ja-JP.js +1 -1
- package/lib/locale/ko-KR.js +1 -1
- package/lib/locale/pl-PL.js +1 -1
- package/lib/locale/pt-BR.js +1 -1
- package/lib/locale/ru-RU.js +1 -1
- package/lib/locale/sk-SK.js +1 -1
- package/lib/locale/vi-VN.js +1 -1
- package/lib/locale/zh-CN.js +1 -1
- package/lib/locale/zh-HK.js +1 -1
- package/lib/locale/zh-TW.js +1 -1
- package/lib/types/chart-builder/index.d.ts +10 -0
- package/lib/types/chart-builder/sheet-chart-builder-adapter.d.ts +41 -0
- package/lib/types/chart-builder/sheet-chart-builder.d.ts +17 -0
- package/lib/types/chart-builder/sheet-chart-create-spec.d.ts +6 -0
- package/lib/types/chart-builder/sheet-chart-description.d.ts +5 -0
- package/lib/types/chart-builder/sheet-chart-layout.d.ts +21 -0
- package/lib/types/chart-builder/sheet-chart-source.d.ts +32 -0
- package/lib/types/chart-builder/types.d.ts +159 -0
- package/lib/types/chart-source/chart-source.d.ts +14 -7
- package/lib/types/commands/commands/sheets-chart-update-config.command.d.ts +2 -0
- package/lib/types/commands/commands/sheets-chart.command.d.ts +3 -4
- package/lib/types/commands/mutations/sheets-chart-update-config.mutation.d.ts +1 -0
- package/lib/types/commands/mutations/sheets-chart.mutation.d.ts +15 -5
- package/lib/types/common/util.d.ts +1 -1
- package/lib/types/facade/chart/f-sheet-chart-builder.d.ts +83 -0
- package/lib/types/facade/chart/f-sheet-charts.d.ts +100 -0
- package/lib/types/facade/chart/index.d.ts +2 -0
- package/lib/types/facade/chart/sheet-chart-command-adapter.d.ts +13 -0
- package/lib/types/facade/f-chart.d.ts +1 -143
- package/lib/types/facade/f-enum.d.ts +7 -205
- package/lib/types/facade/f-worksheet-charts.d.ts +3 -19
- package/lib/types/facade/index.d.ts +3 -23
- package/lib/types/index.d.ts +7 -6
- package/lib/types/models/chart-model.d.ts +3 -3
- package/lib/types/models/types.d.ts +14 -1
- package/lib/types/plugin.d.ts +1 -0
- package/lib/types/services/chart-model.service.d.ts +2 -0
- package/lib/types/services/sheet-chart-range-watcher.d.ts +22 -0
- package/lib/types/services/sheets-chart.service.d.ts +8 -8
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +10 -10
- package/lib/types/facade/chart-builder/builder-util.d.ts +0 -5
- package/lib/types/facade/chart-builder/chart-builder-base.d.ts +0 -919
- package/lib/types/facade/chart-builder/line-chart-builder.d.ts +0 -165
- package/lib/types/facade/chart-builder/pie-chart-builder.d.ts +0 -196
- package/lib/types/facade/chart-builder/radar-chart-builder.d.ts +0 -100
- package/lib/types/facade/chart-builder/types.d.ts +0 -34
- package/lib/types/facade/chart-facade-adapter.d.ts +0 -58
- package/lib/types/facade/chart-facade-builders.d.ts +0 -62
- package/lib/types/facade/chart-facade-types.d.ts +0 -393
- package/lib/types/facade/f-worksheet.d.ts +0 -205
|
@@ -9,3 +9,4 @@ export interface IChartUpdateConfigMutationParams {
|
|
|
9
9
|
context?: IChartContext;
|
|
10
10
|
}
|
|
11
11
|
export declare const ChartUpdateConfigMutation: IMutation<IChartUpdateConfigMutationParams>;
|
|
12
|
+
export declare const ChartReplaceConfigMutation: IMutation<IChartUpdateConfigMutationParams>;
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import type { ChartTypeBits, IChartSnapshot } from '@univerjs-pro/engine-chart';
|
|
2
2
|
import type { IMutation, IRange } from '@univerjs/core';
|
|
3
3
|
import type { ISheetCommandSharedParams } from '@univerjs/sheets';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
rangeUnitId?: string;
|
|
7
|
-
rangeSubUnitId?: string;
|
|
4
|
+
import type { IChartSourceMultiRangeItem, ISheetChartSourceRanges } from '../../models/types';
|
|
5
|
+
type IInsertSheetsChartMutationCommonParams = ISheetCommandSharedParams & Omit<IChartSnapshot, 'id' | 'chartType' | 'orient'> & {
|
|
8
6
|
chartId: string;
|
|
9
7
|
chartType: ChartTypeBits;
|
|
8
|
+
};
|
|
9
|
+
/** Persisted source shape for insert-chart changesets. Keep `range` / `ranges` stable for replay compatibility. */
|
|
10
|
+
export type IInsertSheetsChartMutationSource = {
|
|
11
|
+
range: IRange;
|
|
12
|
+
rangeUnitId: string;
|
|
13
|
+
rangeSubUnitId: string;
|
|
10
14
|
isRowDirection?: boolean;
|
|
11
|
-
}
|
|
15
|
+
} | {
|
|
16
|
+
ranges: IChartSourceMultiRangeItem[];
|
|
17
|
+
};
|
|
18
|
+
export type IInsertSheetsChartMutationParams = IInsertSheetsChartMutationCommonParams & IInsertSheetsChartMutationSource;
|
|
19
|
+
/** Converts the internal chart source into the stable mutation shape without persisting `rangeInfo`. */
|
|
20
|
+
export declare function toInsertChartMutationSource(source: ISheetChartSourceRanges): IInsertSheetsChartMutationSource;
|
|
12
21
|
export interface IRemoveSheetsChartMutationParams extends ISheetCommandSharedParams {
|
|
13
22
|
chartId: string;
|
|
14
23
|
}
|
|
15
24
|
export declare const InsertSheetsChartMutation: IMutation<IInsertSheetsChartMutationParams>;
|
|
16
25
|
export declare const RemoveSheetsChartMutation: IMutation<IRemoveSheetsChartMutationParams>;
|
|
26
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import type { IAccessor } from '@univerjs/core';
|
|
|
2
2
|
export declare const BUILD_TIMESTAMP: number;
|
|
3
3
|
export declare const DefaultLimitedTypes: string[];
|
|
4
4
|
export declare const DefaultAllTypes: string[];
|
|
5
|
-
export declare const DefaultInValidTypes:
|
|
5
|
+
export declare const DefaultInValidTypes: string[];
|
|
6
6
|
export declare const setProperty: (data: Record<string, any>, propertyPath: string, value: any) => void;
|
|
7
7
|
/**
|
|
8
8
|
* Set graphic element to data.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { FChartBuilderBase, HostAnyChartBuilder, HostComposedChartBuilder, IChartBuilderTypeMap } from '@univerjs-pro/engine-chart/facade';
|
|
2
|
+
import type { ChartAnchorSpec, ChartSourceSpec } from '@univerjs-pro/sheets-chart';
|
|
3
|
+
export interface ISheetChartMethods {
|
|
4
|
+
/**
|
|
5
|
+
* Sets the source configuration and returns this builder for chaining.
|
|
6
|
+
*
|
|
7
|
+
* This method executes synchronously.
|
|
8
|
+
*
|
|
9
|
+
* @param source The host-owned chart source.
|
|
10
|
+
* @returns This builder for chaining.
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
14
|
+
* const builder = worksheet.charts.create();
|
|
15
|
+
* builder.setSource('A1:B8');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
setSource(source: ChartSourceSpec): ISheetChartMethods;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the current source value.
|
|
21
|
+
*
|
|
22
|
+
* This method executes synchronously.
|
|
23
|
+
*
|
|
24
|
+
* @returns The current host-owned chart source, or `undefined` when no source has been set.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
28
|
+
* const builder = worksheet.charts.create();
|
|
29
|
+
* builder.getSource();
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
getSource(): Readonly<ChartSourceSpec> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the position configuration and returns this builder for chaining.
|
|
35
|
+
*
|
|
36
|
+
* This method executes synchronously.
|
|
37
|
+
*
|
|
38
|
+
* @param anchor The document or cell anchor.
|
|
39
|
+
* @returns This builder for chaining.
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
43
|
+
* const builder = worksheet.charts.create();
|
|
44
|
+
* builder.setPosition('D2');
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
setPosition(anchor: ChartAnchorSpec): ISheetChartMethods;
|
|
48
|
+
/**
|
|
49
|
+
* Sets the absolute position configuration and returns this builder for chaining.
|
|
50
|
+
*
|
|
51
|
+
* This method executes synchronously.
|
|
52
|
+
*
|
|
53
|
+
* @param x The horizontal position.
|
|
54
|
+
* @param y The vertical position.
|
|
55
|
+
* @returns This builder for chaining.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
59
|
+
* const builder = worksheet.charts.create();
|
|
60
|
+
* builder.setAbsolutePosition(80, 80);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
setAbsolutePosition(x: number, y: number): ISheetChartMethods;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the size configuration and returns this builder for chaining.
|
|
66
|
+
*
|
|
67
|
+
* This method executes synchronously.
|
|
68
|
+
*
|
|
69
|
+
* @param width The width.
|
|
70
|
+
* @param height The height.
|
|
71
|
+
* @returns This builder for chaining.
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
75
|
+
* const builder = worksheet.charts.create();
|
|
76
|
+
* builder.setSize(640, 360);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
setSize(width: number, height: number): ISheetChartMethods;
|
|
80
|
+
}
|
|
81
|
+
export type FSheetChartBuilder<TBuilder extends FChartBuilderBase = FChartBuilderBase> = HostComposedChartBuilder<TBuilder, ISheetChartMethods>;
|
|
82
|
+
export type FSheetChartBuilderOf<T extends keyof IChartBuilderTypeMap> = FSheetChartBuilder<IChartBuilderTypeMap[T]>;
|
|
83
|
+
export type FSheetAnyChartBuilder = HostAnyChartBuilder<ISheetChartMethods>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { IEchartTheme } from '@univerjs-pro/engine-chart';
|
|
2
|
+
import type { IChartBuilderHostTypes } from '@univerjs-pro/engine-chart/facade';
|
|
3
|
+
import type { FWorksheet } from '@univerjs/sheets/facade';
|
|
4
|
+
import type { FSheetAnyChartBuilder, FSheetChartBuilder } from './f-sheet-chart-builder';
|
|
5
|
+
import { FChartsBase } from '@univerjs-pro/engine-chart/facade';
|
|
6
|
+
interface ISheetChartBuilderTypes extends IChartBuilderHostTypes {
|
|
7
|
+
Initial: FSheetChartBuilder;
|
|
8
|
+
Any: FSheetAnyChartBuilder;
|
|
9
|
+
}
|
|
10
|
+
export declare class FSheetCharts extends FChartsBase<ISheetChartBuilderTypes> {
|
|
11
|
+
private readonly _worksheet;
|
|
12
|
+
private readonly _commands;
|
|
13
|
+
constructor(_worksheet: FWorksheet);
|
|
14
|
+
/**
|
|
15
|
+
* Creates a detached chart builder without mutating the host.
|
|
16
|
+
*
|
|
17
|
+
* This method executes synchronously.
|
|
18
|
+
*
|
|
19
|
+
* @returns A detached chart builder.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
|
|
23
|
+
* charts.create();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
create(): FSheetChartBuilder;
|
|
27
|
+
/**
|
|
28
|
+
* Inserts a detached chart builder into this host.
|
|
29
|
+
*
|
|
30
|
+
* This method completes asynchronously.
|
|
31
|
+
*
|
|
32
|
+
* @param builder The detached chart builder to insert.
|
|
33
|
+
* @returns A promise that resolves to the inserted chart builder.
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
|
|
37
|
+
* const builder = charts.create().setSource('A1:B8');
|
|
38
|
+
* await charts.insert(builder);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
insert<T extends FSheetAnyChartBuilder>(builder: T): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a chart builder by its host-owned ID.
|
|
44
|
+
*
|
|
45
|
+
* This method executes synchronously.
|
|
46
|
+
*
|
|
47
|
+
* @param chartId The host-owned chart ID.
|
|
48
|
+
* @returns The matching chart builder, or null when absent.
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
|
|
52
|
+
* charts.get('chart-id');
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
get(chartId: string): FSheetAnyChartBuilder | null;
|
|
56
|
+
/**
|
|
57
|
+
* Returns every chart builder owned by this host.
|
|
58
|
+
*
|
|
59
|
+
* This method executes synchronously.
|
|
60
|
+
*
|
|
61
|
+
* @returns All chart builders owned by this host.
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
|
|
65
|
+
* charts.list();
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
list(): FSheetAnyChartBuilder[];
|
|
69
|
+
/**
|
|
70
|
+
* Removes a chart from this host.
|
|
71
|
+
*
|
|
72
|
+
* This method completes asynchronously.
|
|
73
|
+
*
|
|
74
|
+
* @param builderOrId A builder from this host or its chart ID.
|
|
75
|
+
* @returns A promise that resolves to `true` when the chart is removed, or `false` when it is absent.
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
|
|
79
|
+
* await charts.remove('chart-id');
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
remove(builderOrId: FSheetAnyChartBuilder | string): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* Registers a chart theme shared by every chart host in this Univer runtime.
|
|
85
|
+
*
|
|
86
|
+
* This method executes synchronously.
|
|
87
|
+
*
|
|
88
|
+
* @param name The stable registered name.
|
|
89
|
+
* @param theme The ECharts theme definition.
|
|
90
|
+
* Returns no value.
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
|
|
94
|
+
* charts.registerTheme('brand', { color: ['#1677ff'] });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
registerTheme(name: string, theme: IEchartTheme): void;
|
|
98
|
+
private _wrap;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IChartCreateSpec } from '@univerjs-pro/sheets-chart';
|
|
2
|
+
import type { FWorksheet } from '@univerjs/sheets/facade';
|
|
3
|
+
import { FChart } from '../f-chart';
|
|
4
|
+
/** Owns the Sheet collection-to-command boundary. It is not part of the public facade. */
|
|
5
|
+
export declare class SheetChartCommandAdapter {
|
|
6
|
+
private readonly _worksheet;
|
|
7
|
+
constructor(_worksheet: FWorksheet);
|
|
8
|
+
create(spec: IChartCreateSpec): Promise<FChart>;
|
|
9
|
+
get(chartId: string): FChart | null;
|
|
10
|
+
list(): FChart[];
|
|
11
|
+
remove(chartOrId: FChart | string): Promise<boolean>;
|
|
12
|
+
private _sourceContext;
|
|
13
|
+
}
|
|
@@ -1,143 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ISheetChartSourceSingleRange } from '@univerjs-pro/sheets-chart';
|
|
3
|
-
import type { Injector } from '@univerjs/core';
|
|
4
|
-
import type { ChartDescription, ChartInstanceCapabilities, ChartKnownTypeName, ChartLayoutPatch, ChartSourceSpec, ChartUpdatePatch, ChartUpdateResult, ChartValidationResult } from './chart-facade-types';
|
|
5
|
-
import { FChartBuilderBase } from './chart-builder/chart-builder-base';
|
|
6
|
-
import { ChartUpdateBuilder } from './chart-facade-builders';
|
|
7
|
-
/**
|
|
8
|
-
* The facade class for the chart.
|
|
9
|
-
* @hideconstructor
|
|
10
|
-
*/
|
|
11
|
-
export declare class FChart {
|
|
12
|
-
/**
|
|
13
|
-
* @ignore
|
|
14
|
-
*/
|
|
15
|
-
unitId: string;
|
|
16
|
-
/**
|
|
17
|
-
* @ignore
|
|
18
|
-
*/
|
|
19
|
-
subUnitId: string;
|
|
20
|
-
/**
|
|
21
|
-
* @ignore
|
|
22
|
-
*/
|
|
23
|
-
chartId: string;
|
|
24
|
-
private _injector;
|
|
25
|
-
constructor(unitId: string, subUnitId: string, chartId: string, injector: Injector);
|
|
26
|
-
/**
|
|
27
|
-
* Get the chart id.
|
|
28
|
-
* @returns {string} The chart id.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
33
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
34
|
-
* if (!fWorksheet) return;
|
|
35
|
-
* const charts = fWorksheet.getCharts();
|
|
36
|
-
* console.log(charts[0]?.getChartId());
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
getChartId(): string;
|
|
40
|
-
/**
|
|
41
|
-
* Get the range of the chart.
|
|
42
|
-
* @returns {ISheetChartSourceSingleRange|undefined} The range of the chart.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
47
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
48
|
-
* if (!fWorksheet) return;
|
|
49
|
-
* const charts = fWorksheet.getCharts();
|
|
50
|
-
* console.log(charts[0]?.getRange());
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
getRange(): ISheetChartSourceSingleRange | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* Update the range info of the chart. The range info includes the range of the chart and the direction in source.
|
|
56
|
-
* @param {ISheetChartSourceSingleRange} rangeInfo The new range of the chart.
|
|
57
|
-
* @param {IRange} rangeInfo.range.range The new range of the chart.
|
|
58
|
-
* @param {string} rangeInfo.range.subUnitId The new sheet id of the chart.
|
|
59
|
-
* @param {string} rangeInfo.range.unitId The new workbook id of the chart.
|
|
60
|
-
* @param {boolean} [rangeInfo.isRowDirection] Is treat row as category.
|
|
61
|
-
* @returns {Promise<boolean>} Whether the update is successful.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```ts
|
|
65
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
66
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
67
|
-
* if (!fWorksheet) return;
|
|
68
|
-
*
|
|
69
|
-
* // Get all charts on the active sheet.
|
|
70
|
-
* const charts = fWorksheet.getCharts();
|
|
71
|
-
*
|
|
72
|
-
* // Switch chart row direction
|
|
73
|
-
* if (charts.length > 0){
|
|
74
|
-
* const rangeInfo = { ...charts[0].getRange() };
|
|
75
|
-
* rangeInfo.isRowDirection = !rangeInfo.isRowDirection;
|
|
76
|
-
* charts[0].updateRange(rangeInfo);
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
updateRange(rangeInfo: ISheetChartSourceSingleRange): Promise<boolean>;
|
|
81
|
-
/**
|
|
82
|
-
* Get the series data list of the chart.
|
|
83
|
-
* @typedef ChartSeriesData
|
|
84
|
-
* @property {string} name The name of the series.
|
|
85
|
-
* @property {number} index The index of the series.
|
|
86
|
-
* @property {ChartSeriesItem[]} items The data of the series.
|
|
87
|
-
* @property {number} items.value The value of the series.
|
|
88
|
-
* @property {string} items.label The label of the series.
|
|
89
|
-
* @returns {IChartDataSeries[]|undefined} The series data list of the chart.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```ts
|
|
93
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
94
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
95
|
-
* if (!fWorksheet) return;
|
|
96
|
-
* const charts = fWorksheet.getCharts();
|
|
97
|
-
* if (charts.length > 0){
|
|
98
|
-
* const seriesData = charts[0].getSeriesData();
|
|
99
|
-
* console.log(seriesData);
|
|
100
|
-
* }
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
getSeriesData(): IChartDataSeries[] | undefined;
|
|
104
|
-
/**
|
|
105
|
-
* Get the category data of the chart.
|
|
106
|
-
* @type ChartCategoryData
|
|
107
|
-
* @property {string} name The name of the category.
|
|
108
|
-
* @property {number} index The index of the category.
|
|
109
|
-
* @property {CategoryType} type The type of the category.
|
|
110
|
-
* @property {string[]} keys The keys of the category.
|
|
111
|
-
* @property {IChartDataItem[]} items The data of the category.
|
|
112
|
-
* @property {number} items.value The value of the category.
|
|
113
|
-
* @property {string} items.label The label of the category.
|
|
114
|
-
* @returns The category data of the chart.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
119
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
120
|
-
* if (!fWorksheet) return;
|
|
121
|
-
* const charts = fWorksheet.getCharts();
|
|
122
|
-
* if (charts.length > 0){
|
|
123
|
-
* const categoryData = charts[0].getCategoryData();
|
|
124
|
-
* console.log(categoryData);
|
|
125
|
-
* }
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
getCategoryData(): IChartDataCategory | undefined;
|
|
129
|
-
/**
|
|
130
|
-
* Returns a new FChartBuilderBase instance that modifies this chart.
|
|
131
|
-
* @returns {FChartBuilderBase} The new FChartBuilderBase instance.
|
|
132
|
-
*/
|
|
133
|
-
modify(): FChartBuilderBase;
|
|
134
|
-
describe(): ChartDescription | null;
|
|
135
|
-
getCapabilities(): ChartInstanceCapabilities | null;
|
|
136
|
-
validateUpdate(patch: ChartUpdatePatch): ChartValidationResult<ChartUpdatePatch>;
|
|
137
|
-
newUpdateBuilder(): ChartUpdateBuilder;
|
|
138
|
-
update(patch: ChartUpdatePatch): Promise<ChartUpdateResult>;
|
|
139
|
-
setSource(source: ChartSourceSpec): Promise<ChartUpdateResult>;
|
|
140
|
-
setType(type: ChartKnownTypeName): Promise<ChartUpdateResult>;
|
|
141
|
-
setLayout(layout: ChartLayoutPatch): Promise<ChartUpdateResult>;
|
|
142
|
-
remove(): Promise<boolean>;
|
|
143
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,210 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
1
|
+
import { ChartSourceOrientation } from '@univerjs-pro/sheets-chart';
|
|
2
|
+
import { FEnum } from '@univerjs/core/facade';
|
|
3
|
+
/** @ignore */
|
|
5
4
|
export interface IFSheetsChartEnumMixin {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
13
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
14
|
-
* if (!fWorksheet) return;
|
|
15
|
-
*
|
|
16
|
-
* // Create a column chart with data source A1:D6.
|
|
17
|
-
* // The starting position is upper-left corner of cell B2.
|
|
18
|
-
* const chartInfo = fWorksheet.newChart()
|
|
19
|
-
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
20
|
-
* .addRange('A1:D6')
|
|
21
|
-
* .setPosition(1, 1, 0, 0)
|
|
22
|
-
* .build();
|
|
23
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
ChartType: typeof ChartTypeBits;
|
|
27
|
-
/**
|
|
28
|
-
* Represents the position of the legend in the chart. {@link LegendPositionEnum}
|
|
29
|
-
* The possible values are: BOTTOM, TOP, LEFT, RIGHT, HIDE.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
34
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
35
|
-
* if (!fWorksheet) return;
|
|
36
|
-
*
|
|
37
|
-
* // Create a line chart with data source A1:D6.
|
|
38
|
-
* // The starting position is upper-left corner of cell B2.
|
|
39
|
-
* // The legend is positioned at the top of the chart.
|
|
40
|
-
* const chartInfo = fWorksheet.newChart()
|
|
41
|
-
* .asLineChart()
|
|
42
|
-
* .addRange('A1:D6')
|
|
43
|
-
* .setPosition(1, 1, 0, 0)
|
|
44
|
-
* .setOptions('legend.position', univerAPI.Enum.LegendPositionEnum.Top)
|
|
45
|
-
* .build();
|
|
46
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
LegendPositionEnum: typeof LegendPositionEnum;
|
|
50
|
-
/**
|
|
51
|
-
* Represents the selection mode of the chart. {@link SelectModeEnum}
|
|
52
|
-
* The possible values are: SINGLE, MULTIPLE, Close. It used to specify the selection mode of the chart legend.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
57
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
58
|
-
* if (!fWorksheet) return;
|
|
59
|
-
*
|
|
60
|
-
* // Create a line chart with data source A1:D6.
|
|
61
|
-
* // The starting position is upper-left corner of cell B2.
|
|
62
|
-
* // The legend is in single selection mode.
|
|
63
|
-
* const chartInfo = fWorksheet.newChart()
|
|
64
|
-
* .asLineChart()
|
|
65
|
-
* .addRange('A1:D6')
|
|
66
|
-
* .setPosition(1, 1, 0, 0)
|
|
67
|
-
* .setOptions('legend.selectMode', univerAPI.Enum.SelectModeEnum.Single)
|
|
68
|
-
* .build();
|
|
69
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
SelectModeEnum: typeof SelectModeEnum;
|
|
73
|
-
/**
|
|
74
|
-
* Represents the alignment of the axis. {@link AxisAlignEnum}
|
|
75
|
-
* The possible values are: START, CENTER, END.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```ts
|
|
79
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
80
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
81
|
-
* if (!fWorksheet) return;
|
|
82
|
-
*
|
|
83
|
-
* // Create a line chart with data source A1:D6.
|
|
84
|
-
* // The starting position is upper-left corner of cell B2.
|
|
85
|
-
* // The x-axis title is set to 'X Axis Title' with red font color and aligned to the end of the axis.
|
|
86
|
-
* const chartInfo = fWorksheet.newChart()
|
|
87
|
-
* .asLineChart()
|
|
88
|
-
* .addRange('A1:D6')
|
|
89
|
-
* .setPosition(1, 1, 0, 0)
|
|
90
|
-
* .setOptions('', {
|
|
91
|
-
* xAxisTitle: {
|
|
92
|
-
* content: 'X Axis Title',
|
|
93
|
-
* fontColor: '#ff0000',
|
|
94
|
-
* axisAlignment: univerAPI.Enum.AxisAlignEnum.End,
|
|
95
|
-
* }
|
|
96
|
-
* })
|
|
97
|
-
* .build();
|
|
98
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
AxisAlignEnum: typeof AxisAlignEnum;
|
|
102
|
-
/**
|
|
103
|
-
* Represents the type of the border dash. {@link ChartBorderDashType}
|
|
104
|
-
* The possible values are: SOLID, DOTTED, DASHED.
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```ts
|
|
108
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
109
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
110
|
-
* if (!fWorksheet) return;
|
|
111
|
-
*
|
|
112
|
-
* // Create a line chart with data source A1:D6.
|
|
113
|
-
* // The starting position is upper-left corner of cell B2.
|
|
114
|
-
* // The axis pointer style is set.
|
|
115
|
-
* const chartInfo = fWorksheet.newChart()
|
|
116
|
-
* .asLineChart()
|
|
117
|
-
* .addRange('A1:D6')
|
|
118
|
-
* .setPosition(1, 1, 0, 0)
|
|
119
|
-
* .setAxisPointerStyle({
|
|
120
|
-
* indicatorLabelColor: '#ff0000',
|
|
121
|
-
* indicatorLineType: univerAPI.Enum.ChartBorderDashType.Solid,
|
|
122
|
-
* indicatorLineColor: '#00ff00',
|
|
123
|
-
* indicatorLabelTextColor: '#0000ff',
|
|
124
|
-
* })
|
|
125
|
-
* .build();
|
|
126
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
ChartBorderDashType: typeof ChartBorderDashType;
|
|
130
|
-
/**
|
|
131
|
-
* Represents the shape of the data point in the line chart. {@link LinePointShape}
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```ts
|
|
135
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
136
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
137
|
-
* if (!fWorksheet) return;
|
|
138
|
-
*
|
|
139
|
-
* // Create a line chart with data source A1:D6.
|
|
140
|
-
* // The starting position is upper-left corner of cell B2.
|
|
141
|
-
* // The data point shape is set to circle, color is red, and size is 10.
|
|
142
|
-
* const chartInfo = fWorksheet.newChart()
|
|
143
|
-
* .asLineChart()
|
|
144
|
-
* .addRange('A1:D6')
|
|
145
|
-
* .setPosition(1, 1, 0, 0)
|
|
146
|
-
* .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
|
|
147
|
-
* .setDataPointColor('#ff0000')
|
|
148
|
-
* .setDataPointSize(10)
|
|
149
|
-
* .build();
|
|
150
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
LinePointShape: typeof LinePointShape;
|
|
154
|
-
/**
|
|
155
|
-
* Represents the position of the title in the chart. {@link TitlePositionEnum}
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```ts
|
|
159
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
160
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
161
|
-
* if (!fWorksheet) return;
|
|
162
|
-
*
|
|
163
|
-
* // Create a line chart with data source A1:D6.
|
|
164
|
-
* // The starting position is upper-left corner of cell B2.
|
|
165
|
-
* // The title is positioned at the top of the chart.
|
|
166
|
-
* const chartInfo = fWorksheet.newChart()
|
|
167
|
-
* .asLineChart()
|
|
168
|
-
* .addRange('A1:D6')
|
|
169
|
-
* .setPosition(1, 1, 0, 0)
|
|
170
|
-
* .setOptions('', {
|
|
171
|
-
* title: {
|
|
172
|
-
* content: 'Chart Title',
|
|
173
|
-
* position: univerAPI.Enum.TitlePositionEnum.TOP,
|
|
174
|
-
* },
|
|
175
|
-
* })
|
|
176
|
-
* .build();
|
|
177
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
TitlePositionEnum: typeof TitlePositionEnum;
|
|
181
|
-
/**
|
|
182
|
-
* Represents the shape of the radar chart. {@link RadarShape}
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
187
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
188
|
-
* if (!fWorksheet) return;
|
|
189
|
-
*
|
|
190
|
-
* // Create a radar chart with data source A1:D6.
|
|
191
|
-
* // The starting position is upper-left corner of cell B2.
|
|
192
|
-
* // The shape of the radar chart is set to polygon and filled with red color.
|
|
193
|
-
* const chartInfo = fWorksheet.newChart()
|
|
194
|
-
* .asRadarChart()
|
|
195
|
-
* .addRange('A1:D6')
|
|
196
|
-
* .setPosition(1, 1, 0, 0)
|
|
197
|
-
* .setShape(univerAPI.Enum.RadarShape.Polygon)
|
|
198
|
-
* .setFill(true)
|
|
199
|
-
* .build();
|
|
200
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
RadarShape: typeof RadarShape;
|
|
5
|
+
ChartSourceOrientation: typeof ChartSourceOrientation;
|
|
6
|
+
}
|
|
7
|
+
export declare class FSheetsChartEnumMixin extends FEnum implements IFSheetsChartEnumMixin {
|
|
8
|
+
get ChartSourceOrientation(): typeof ChartSourceOrientation;
|
|
204
9
|
}
|
|
205
|
-
/**
|
|
206
|
-
* @ignore
|
|
207
|
-
*/
|
|
208
10
|
declare module '@univerjs/core/facade' {
|
|
209
11
|
interface FEnum extends IFSheetsChartEnumMixin {
|
|
210
12
|
}
|
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
import type { ChartCapabilities, ChartCreateSpec, ChartSourceSpec, ChartSuggestion, ChartUpdatePatch, ChartUpdateResult, ChartValidationResult } from './chart-facade-types';
|
|
2
1
|
import { FWorksheet } from '@univerjs/sheets/facade';
|
|
3
|
-
import {
|
|
4
|
-
import { FChart } from './f-chart';
|
|
5
|
-
export declare class FWorksheetCharts {
|
|
6
|
-
private readonly _worksheet;
|
|
7
|
-
constructor(_worksheet: FWorksheet);
|
|
8
|
-
create(spec: ChartCreateSpec): Promise<FChart>;
|
|
9
|
-
update(chart: FChart | string, patch: ChartUpdatePatch): Promise<ChartUpdateResult>;
|
|
10
|
-
remove(chart: FChart | string): Promise<boolean>;
|
|
11
|
-
list(): FChart[];
|
|
12
|
-
get(chartId: string): FChart | null;
|
|
13
|
-
validateCreate(spec: ChartCreateSpec): ChartValidationResult<ChartCreateSpec>;
|
|
14
|
-
getCapabilities(): ChartCapabilities;
|
|
15
|
-
newBuilder(): ChartCreateBuilder;
|
|
16
|
-
suggest(source: ChartSourceSpec): ChartSuggestion[];
|
|
17
|
-
private _sourceContext;
|
|
18
|
-
}
|
|
2
|
+
import { FSheetCharts } from './chart/f-sheet-charts';
|
|
19
3
|
export interface IFWorksheetChartsMixin {
|
|
20
|
-
readonly charts:
|
|
4
|
+
readonly charts: FSheetCharts;
|
|
21
5
|
}
|
|
22
6
|
export declare class FWorksheetChartsMixin extends FWorksheet implements IFWorksheetChartsMixin {
|
|
23
|
-
get charts():
|
|
7
|
+
get charts(): FSheetCharts;
|
|
24
8
|
}
|
|
25
9
|
declare module '@univerjs/sheets/facade' {
|
|
26
10
|
interface FWorksheet extends IFWorksheetChartsMixin {
|
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
import type { ILineChartBuilderMixin, IPieChartBuilderInfo, IPieChartBuilderMixin, IRadarChartBuilderMixin } from './chart-builder/types';
|
|
2
|
-
import './f-worksheet';
|
|
3
1
|
import './f-worksheet-charts';
|
|
4
2
|
import './f-enum';
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export { PieChartBuilder } from './chart-builder/pie-chart-builder';
|
|
9
|
-
export { RadarChartBuilder } from './chart-builder/radar-chart-builder';
|
|
10
|
-
export { ChartFacadeError } from './chart-facade-adapter';
|
|
11
|
-
export { ChartCreateBuilder, ChartUpdateBuilder } from './chart-facade-builders';
|
|
12
|
-
export type * from './chart-facade-types';
|
|
13
|
-
export { FChart } from './f-chart';
|
|
14
|
-
export type * from './f-chart';
|
|
15
|
-
export type * from './f-worksheet';
|
|
16
|
-
export { FWorksheetCharts } from './f-worksheet-charts';
|
|
17
|
-
/**
|
|
18
|
-
* @ignore
|
|
19
|
-
*/
|
|
20
|
-
declare module '@univerjs-pro/sheets-chart/facade' {
|
|
21
|
-
interface FChartBuilderBase extends IPieChartBuilderMixin, IRadarChartBuilderMixin, ILineChartBuilderMixin {
|
|
22
|
-
}
|
|
23
|
-
interface IChartBuildOptions extends IPieChartBuilderInfo {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
3
|
+
export type { FSheetAnyChartBuilder, FSheetChartBuilder, FSheetChartBuilderOf, ISheetChartMethods } from './chart';
|
|
4
|
+
export { FSheetCharts } from './chart';
|
|
5
|
+
export { ChartSourceOrientation } from '@univerjs-pro/sheets-chart';
|