@univerjs-pro/engine-chart 1.0.0-alpha.1 → 1.0.0-alpha.2
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/index.d.ts +6 -3
- package/lib/types/models/chart-data-operators/operators.d.ts +1 -2
- package/lib/types/models/chart-runtime-style.d.ts +1 -0
- package/lib/types/models/echart-render-model.d.ts +7 -3
- package/lib/types/models/image-chart-host.d.ts +17 -0
- package/lib/types/models/offscreen-chart-host.d.ts +7 -0
- package/lib/types/types.d.ts +90 -1
- package/lib/types/wordcloud-chart/adapters/echarts/install.d.ts +1 -0
- package/lib/types/wordcloud-chart/adapters/echarts/runtime-cache.d.ts +29 -0
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { AreaLineStyle, AxisAlignEnum, AxisValueType, CategoryType, ChartAttributeBits, ChartBorderDashType, ChartSourceDataTypeEnum, ChartTrendlineType, ChartTypeBits, DataOrientation, InvalidValueType, IRuntimeAxisPosition, IRuntimeAxisPriority, LabelAlignEnum, LabelContentType, LegendPositionEnum, LinePointShape, PieLabelPosition, RadarShape, RelationChartLayoutEnum, SelectModeEnum, SeriesLabelPosition, StackType, TextAlign, TextVerticalAlign, TitlePositionEnum, WaterfallSeriesTypeEnum, WaterfallStackTypeEnum, WordCloudShapeEnum, } from './enum';
|
|
2
2
|
export { buildChartData } from './models/chart-data-operators/build-chart-data';
|
|
3
|
-
export { defaultChartContextOperators, findCategoryIndexes,
|
|
3
|
+
export { defaultChartContextOperators, findCategoryIndexes, findSeriesOperator, generateChartModelContextByOperators, inferChartContextOperator, pieSeriesFilterOperator, } from './models/chart-data-operators/operators';
|
|
4
4
|
export type { IChartLocaleTexts } from './models/chart-locale-texts';
|
|
5
5
|
export { getDefaultChartLocaleTexts, replaceLocaleParams } from './models/chart-locale-texts';
|
|
6
6
|
export { ChartModel } from './models/chart-model';
|
|
7
7
|
export { CHART_DEBOUNCE_TIME } from './models/chart-model';
|
|
8
|
-
export { resolveChartRuntimeStyle } from './models/chart-runtime-style';
|
|
8
|
+
export { resolveChartRuntimeStyle, resolveChartStyleBackgroundColor } from './models/chart-runtime-style';
|
|
9
9
|
export { ChartThemeService, registerChartThemeService } from './models/chart-theme.service';
|
|
10
10
|
export { getThemeAxesByType } from './models/constants/build-in-theme';
|
|
11
11
|
export { themeDefault, UniverTheme1, UniverTheme2, UniverTheme3, UniverTheme4, UniverTheme5, UniverTheme6, UniverThemeGradient1, UniverThemeGradient2, UniverThemeGradient3, UniverThemeGradient4, UniverThemeGradient5, UniverThemeGradient6, } from './models/constants/build-in-theme';
|
|
@@ -16,12 +16,15 @@ export { defaultChartConfig, RTLChartStyle, themeColors } from './models/constan
|
|
|
16
16
|
export { EChartRenderModel } from './models/echart-render-model';
|
|
17
17
|
export type { IEChartRenderModelOptions } from './models/echart-render-model';
|
|
18
18
|
export { echartToChartModelInit, isChartModelInit } from './models/echart-to-chart-model-init';
|
|
19
|
+
export { chartImageSourceToDataUrl, ImageChartHost } from './models/image-chart-host';
|
|
19
20
|
export type { IChartModelInitParams } from './models/mode-converter/mode-converter';
|
|
20
21
|
export { convertModelFromInitData, convertModelToSpec, generateChartModelContext } from './models/mode-converter/mode-converter';
|
|
22
|
+
export { OffscreenChartHost } from './models/offscreen-chart-host';
|
|
21
23
|
export { registerWordCloudChartMakImageService, WordCloudMuskImageService } from './models/word-cloud-musk-image.service';
|
|
22
24
|
export { ChartDataSource } from './source/chart-source';
|
|
23
25
|
export { StaticChartSource } from './source/static-chart-source';
|
|
24
|
-
export
|
|
26
|
+
export { ChartImageSourceType } from './types';
|
|
27
|
+
export type { ChartDataSourceValue, ChartDataSourceValues, ChartHostRenderMode, ChartImageSource, DimensionDefinitionLoose, IChartDataSource, IChartHost, IChartHostLease, IChartHostStyle, IChartRenderAsImageOptions, IChartRenderInput, IChartRenderInstance, IChartRenderInstanceCreateContext, IChartRenderInstanceSpecInput, IChartRenderInstanceStyleInput, IDimensionDefinition, IDomChartHost, IImageChartHost, IUniverDataSet, OptionDataValue, } from './types';
|
|
25
28
|
export type { ChartDirection, ChartStyle, DeepPartial, IAllSeriesStyle, IAxisOptions, IChartConfig, IChartContext, IChartData, IChartDataAggregation, IChartDataCategory, IChartDataSeries, IChartHostRect, IChartInstance, IChartRenderModel, IChartSnapshot, IChartStyle, IGridLineStyle, ILabelStyle, ILegendStyle, IPieLabelStyle, IPointStyle, IRelationForceOptions, IRuntimeAxis, ISeriesLabelStyle, ISeriesStyle, ITrendLine, RightYAxisOptions, } from './types';
|
|
26
29
|
export { chartBitsUtils, chartTypeCanUseTrendLine } from './util';
|
|
27
30
|
export * from './utils/echarts';
|
|
@@ -12,8 +12,7 @@ export declare function countTypesFromArray(arrayData: Array<OptionDataValue | u
|
|
|
12
12
|
};
|
|
13
13
|
export declare function toColumnOrient<T = any>(dataSource: T[][]): T[][];
|
|
14
14
|
export declare function findCategoryIndexes(dataSource: ChartDataSource): number[];
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const findCategoryOperator: IChartContextOperator;
|
|
15
|
+
export declare const inferChartContextOperator: IChartContextOperator;
|
|
17
16
|
export declare const findSeriesOperator: IChartContextOperator;
|
|
18
17
|
export declare const pieSeriesFilterOperator: IChartContextOperator;
|
|
19
18
|
export declare const defaultChartContextOperators: IChartContextOperator[];
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import type { ChartStyle, EChartInstance, EChartSpec, IChartConfig, IChartHostRect, IChartInstance, IChartRenderModel, IChartRenderModelStylizeInit } from '../types';
|
|
1
|
+
import type { ChartHostRenderMode, ChartImageSource, ChartStyle, EChartInstance, EChartSpec, IChartConfig, IChartHostRect, IChartInstance, IChartRenderAsImageOptions, IChartRenderInstance, IChartRenderInstanceCreateContext, IChartRenderModel, IChartRenderModelStylizeInit, IChartRenderRuntimeOptions } from '../types';
|
|
2
2
|
import type { IWordCloudRenderConfig } from '../wordcloud-chart/word-cloud-render-config';
|
|
3
3
|
import { Disposable } from '@univerjs/core';
|
|
4
4
|
export interface IEChartRenderModelOptions {
|
|
@@ -14,6 +14,10 @@ export declare class EChartRenderModel extends Disposable implements IChartRende
|
|
|
14
14
|
private _addSpecConverters;
|
|
15
15
|
private _addSpecOperators;
|
|
16
16
|
createChartInstance(): IChartInstance<EChartSpec>;
|
|
17
|
+
createChartInstance(mode: ChartHostRenderMode, context?: IChartRenderInstanceCreateContext<EChartSpec>): IChartRenderInstance;
|
|
18
|
+
clearRuntimeCache(chartId: string): void;
|
|
19
|
+
clearAllRuntimeCache(): void;
|
|
20
|
+
dispose(): void;
|
|
17
21
|
toSpec(config: IChartConfig, style: ChartStyle): import("echarts").EChartsOption;
|
|
18
22
|
stylizeSpec(spec: EChartSpec, stylizeInit: IChartRenderModelStylizeInit<EChartSpec>, rect: IChartHostRect): import("echarts").EChartsOption | {
|
|
19
23
|
backgroundColor: string;
|
|
@@ -30,8 +34,8 @@ export declare class EChartRenderEngine extends Disposable implements EChartInst
|
|
|
30
34
|
resize(echartsProvider?: any): void;
|
|
31
35
|
private _ensureChartInstance;
|
|
32
36
|
get containerElement(): HTMLElement | null;
|
|
33
|
-
render(spec: EChartSpec,
|
|
37
|
+
render(spec: EChartSpec, echartsProviderOrOptions?: any | IChartRenderRuntimeOptions): void;
|
|
38
|
+
renderAsImage(spec: EChartSpec, options: IChartRenderAsImageOptions): Promise<ChartImageSource>;
|
|
34
39
|
exportImg(echartsProvider?: any): Promise<string>;
|
|
35
|
-
onDispose(): void;
|
|
36
40
|
dispose(): void;
|
|
37
41
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChartImageSource, IChartHostLease, IChartHostRect, IChartHostStyle, IImageChartHost } from '../types';
|
|
2
|
+
import { Disposable } from '@univerjs/core';
|
|
3
|
+
export declare function chartImageSourceToDataUrl(image: ChartImageSource): string;
|
|
4
|
+
export declare abstract class ImageChartHost extends Disposable implements IImageChartHost {
|
|
5
|
+
readonly chartId: string;
|
|
6
|
+
readonly mode: "image";
|
|
7
|
+
private readonly _offscreenChartHost;
|
|
8
|
+
constructor(chartId: string);
|
|
9
|
+
abstract getRect(): IChartHostRect | null;
|
|
10
|
+
abstract setStyle(style: IChartHostStyle): void;
|
|
11
|
+
abstract nextVersion(): number;
|
|
12
|
+
abstract commitSnapshot(image: ChartImageSource, version: number): boolean;
|
|
13
|
+
abstract requestPaint(): void;
|
|
14
|
+
abstract invalidateSnapshot(): void;
|
|
15
|
+
acquireOffscreenHost(rect: IChartHostRect): IChartHostLease;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
@@ -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
|
+
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -413,6 +413,63 @@ export interface IChartRenderSpecConverter<ChartRenderSpec = Record<string, any>
|
|
|
413
413
|
}
|
|
414
414
|
export type ChartConfigInterceptor = (config: IChartConfig) => IChartConfig;
|
|
415
415
|
export type RenderSpecOperator<ChartRenderSpec> = (spec: ChartRenderSpec, style: ChartStyle, config: IChartConfig, instance: IChartInstance) => void;
|
|
416
|
+
export type ChartHostRenderMode = 'image' | 'dom';
|
|
417
|
+
export interface IChartHostStyle {
|
|
418
|
+
stroke?: string;
|
|
419
|
+
fill?: string;
|
|
420
|
+
[key: string]: any;
|
|
421
|
+
}
|
|
422
|
+
export interface IChartHostLease extends IDisposable {
|
|
423
|
+
readonly mountNode: HTMLElement;
|
|
424
|
+
}
|
|
425
|
+
export interface IChartHost extends IDisposable {
|
|
426
|
+
readonly chartId: string;
|
|
427
|
+
readonly mode: ChartHostRenderMode;
|
|
428
|
+
getRect(): IChartHostRect | null;
|
|
429
|
+
setStyle(style: IChartHostStyle): void;
|
|
430
|
+
}
|
|
431
|
+
export interface IImageChartHost extends IChartHost {
|
|
432
|
+
readonly mode: 'image';
|
|
433
|
+
nextVersion(): number;
|
|
434
|
+
commitSnapshot(image: ChartImageSource, version: number): boolean;
|
|
435
|
+
requestPaint(): void;
|
|
436
|
+
invalidateSnapshot(): void;
|
|
437
|
+
acquireOffscreenHost(rect: IChartHostRect): IChartHostLease;
|
|
438
|
+
}
|
|
439
|
+
export interface IDomChartHost extends IChartHost {
|
|
440
|
+
readonly mode: 'dom';
|
|
441
|
+
ensureMount(): Promise<HTMLElement | null>;
|
|
442
|
+
checkMounted(): boolean;
|
|
443
|
+
syncLayout(): void;
|
|
444
|
+
markReady(): void;
|
|
445
|
+
markNotReady(): void;
|
|
446
|
+
}
|
|
447
|
+
export interface IChartRenderInput {
|
|
448
|
+
chartId: string;
|
|
449
|
+
config: IChartConfig;
|
|
450
|
+
style: ChartStyle;
|
|
451
|
+
}
|
|
452
|
+
export interface IChartRenderInstance extends IDisposable {
|
|
453
|
+
readonly mode: ChartHostRenderMode;
|
|
454
|
+
bind(host: IChartHost): void;
|
|
455
|
+
render(input: IChartRenderInput): Promise<void>;
|
|
456
|
+
resize(): void;
|
|
457
|
+
}
|
|
458
|
+
export interface IChartRenderInstanceStyleInput<Spec = Record<string, any>> extends IChartRenderInput {
|
|
459
|
+
mode: ChartHostRenderMode;
|
|
460
|
+
spec?: Spec;
|
|
461
|
+
}
|
|
462
|
+
export interface IChartRenderInstanceSpecInput<Spec = Record<string, any>> extends IChartRenderInput {
|
|
463
|
+
mode: ChartHostRenderMode;
|
|
464
|
+
spec: Spec;
|
|
465
|
+
}
|
|
466
|
+
export interface IChartRenderInstanceCreateContext<Spec = Record<string, any>> {
|
|
467
|
+
resolveHostStyle?: (input: IChartRenderInstanceStyleInput<Spec>) => IChartHostStyle;
|
|
468
|
+
resolveRenderBackgroundColor?: (input: IChartRenderInstanceStyleInput<Spec> & {
|
|
469
|
+
hostStyle: IChartHostStyle;
|
|
470
|
+
}) => string | undefined;
|
|
471
|
+
prepareSpec?: (input: IChartRenderInstanceSpecInput<Spec>) => Spec;
|
|
472
|
+
}
|
|
416
473
|
export interface IChartRenderModelStylizeInit<Spec> {
|
|
417
474
|
chartStyle: ChartStyle;
|
|
418
475
|
chartConfig: IChartConfig;
|
|
@@ -423,17 +480,49 @@ export interface IChartRenderModel<Spec extends Record<string, any> = Record<str
|
|
|
423
480
|
stylizeSpec(spec: Spec, stylizeInit: IChartRenderModelStylizeInit<Spec>, rect: IChartHostRect): Spec;
|
|
424
481
|
updateWatermark(addWatermark: boolean): void;
|
|
425
482
|
createChartInstance(): IChartInstance<Spec>;
|
|
483
|
+
createChartInstance(mode: ChartHostRenderMode, context?: IChartRenderInstanceCreateContext<Spec>): IChartRenderInstance;
|
|
484
|
+
clearRuntimeCache?(chartId: string): void;
|
|
485
|
+
clearAllRuntimeCache?(): void;
|
|
426
486
|
dispose(): void;
|
|
427
487
|
}
|
|
428
488
|
export interface IChartThemeOptions {
|
|
429
489
|
colors: string[];
|
|
430
490
|
}
|
|
491
|
+
export declare enum ChartImageSourceType {
|
|
492
|
+
Url = "url",
|
|
493
|
+
Canvas = "canvas",
|
|
494
|
+
ImageBitmap = "imageBitmap"
|
|
495
|
+
}
|
|
496
|
+
export type ChartImageSource = {
|
|
497
|
+
type: ChartImageSourceType.Url;
|
|
498
|
+
url: string;
|
|
499
|
+
} | {
|
|
500
|
+
type: ChartImageSourceType.Canvas;
|
|
501
|
+
canvas: HTMLCanvasElement;
|
|
502
|
+
} | {
|
|
503
|
+
type: ChartImageSourceType.ImageBitmap;
|
|
504
|
+
imageBitmap: ImageBitmap;
|
|
505
|
+
};
|
|
506
|
+
export interface IChartRenderAsImageOptions {
|
|
507
|
+
width: number;
|
|
508
|
+
height: number;
|
|
509
|
+
pixelRatio?: number;
|
|
510
|
+
backgroundColor?: string;
|
|
511
|
+
echartsProvider?: any;
|
|
512
|
+
chartId?: string;
|
|
513
|
+
host: HTMLElement;
|
|
514
|
+
}
|
|
515
|
+
export interface IChartRenderRuntimeOptions {
|
|
516
|
+
echartsProvider?: any;
|
|
517
|
+
chartId?: string;
|
|
518
|
+
}
|
|
431
519
|
export interface IChartInstance<Spec = Record<string, any>> extends IDisposable {
|
|
432
520
|
container: HTMLElement | string;
|
|
433
521
|
mount(id: string | HTMLElement): void;
|
|
434
522
|
render(spec: Spec, echartsProvider?: any): void;
|
|
523
|
+
render(spec: Spec, options?: IChartRenderRuntimeOptions): void;
|
|
524
|
+
renderAsImage(spec: Spec, options: IChartRenderAsImageOptions): Promise<ChartImageSource>;
|
|
435
525
|
exportImg(): Promise<string>;
|
|
436
|
-
onDispose?(dispose: () => void): void;
|
|
437
526
|
resize(): void;
|
|
438
527
|
}
|
|
439
528
|
export interface IChartInstanceConstructor<Spec> {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { echarts as EchartsType } from '../../../utils/echarts';
|
|
2
2
|
import type { IWordCloudEChartsSeriesOption } from '../../types';
|
|
3
3
|
export declare function registerWordCloudChart(echarts: typeof EchartsType): typeof EchartsType;
|
|
4
|
+
export declare function waitForWordCloudImageResourcesReady(spec: unknown, timeout?: number): Promise<void>;
|
|
4
5
|
export type { IWordCloudEChartsSeriesOption };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IWordCloudEncodedWord } from '../../types';
|
|
2
|
+
import type { IEChartsWordCloudRenderLayout } from './layout';
|
|
3
|
+
import type { IEChartsWordCloudDesignWordsBuildResult } from './words';
|
|
4
|
+
export interface IWordCloudRuntimeContext {
|
|
5
|
+
chartId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IWordCloudFinalLayoutCachePayload {
|
|
8
|
+
placed: IEChartsWordCloudRenderLayout[];
|
|
9
|
+
}
|
|
10
|
+
interface ICacheCounter {
|
|
11
|
+
hit: number;
|
|
12
|
+
miss: number;
|
|
13
|
+
}
|
|
14
|
+
export interface IWordCloudRuntimeCacheStats {
|
|
15
|
+
designWords: ICacheCounter;
|
|
16
|
+
layoutWords: ICacheCounter;
|
|
17
|
+
finalLayout: ICacheCounter;
|
|
18
|
+
}
|
|
19
|
+
export declare function withWordCloudRuntimeContext<T>(context: IWordCloudRuntimeContext, fn: () => T): T;
|
|
20
|
+
export declare function getCurrentWordCloudRuntimeContext(): IWordCloudRuntimeContext | undefined;
|
|
21
|
+
export declare function getOrCreateCachedWordCloudDesignWords(chartId: string | undefined, key: string, factory: () => IEChartsWordCloudDesignWordsBuildResult): IEChartsWordCloudDesignWordsBuildResult;
|
|
22
|
+
export declare function getOrCreateCachedWordCloudLayoutWords(chartId: string | undefined, key: string, factory: () => IWordCloudEncodedWord[]): IWordCloudEncodedWord[];
|
|
23
|
+
export declare function getCachedWordCloudFinalLayout(chartId: string | undefined, key: string): IWordCloudFinalLayoutCachePayload | undefined;
|
|
24
|
+
export declare function setCachedWordCloudFinalLayout(chartId: string | undefined, key: string, value: IWordCloudFinalLayoutCachePayload): void;
|
|
25
|
+
export declare function clearWordCloudRuntimeCache(chartId: string): void;
|
|
26
|
+
export declare function clearAllWordCloudRuntimeCache(): void;
|
|
27
|
+
export declare function getWordCloudRuntimeCacheStats(chartId?: string): IWordCloudRuntimeCacheStats;
|
|
28
|
+
export declare function createStableWordCloudCacheKey(parts: readonly unknown[]): string;
|
|
29
|
+
export {};
|