@univerjs-pro/engine-chart 0.6.7 → 0.6.8

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.
@@ -0,0 +1,5 @@
1
+ import { IEchartTheme } from './types';
2
+ export type axesType = 'category' | 'value' | 'time' | 'log' | 'all' | undefined;
3
+ export declare function getThemeAxesByType(themeInfo: IEchartTheme, axesType: axesType): import('./types').IEchartThemeAxisConfig | undefined;
4
+ export declare function getThemeTitleColor(themeInfo: IEchartTheme): string | undefined;
5
+ export declare function getThemeProps(themeInfo: IEchartTheme | undefined, key: string): undefined;
@@ -1,4 +1,4 @@
1
- interface IEchartThemeAxisConfig {
1
+ export interface IEchartThemeAxisConfig {
2
2
  type: string;
3
3
  name: string;
4
4
  axisLineShow: boolean;
@@ -74,4 +74,3 @@ export interface IEchartTheme {
74
74
  themeName: string;
75
75
  theme: IEchartThemeContent;
76
76
  }
77
- export {};
@@ -57,12 +57,29 @@ export declare const defaultChartConfig: {
57
57
  firstChartType: ChartTypeBits;
58
58
  otherChartType: ChartTypeBits;
59
59
  };
60
+ funnel: {
61
+ gap: number;
62
+ };
60
63
  radar: {
61
64
  shape: RadarShape;
62
65
  symbolSize: number;
63
66
  symbolType: LinePointShape;
64
67
  areaOpacity: number;
65
68
  };
69
+ wordCloud: {
70
+ maskImage: string;
71
+ repeat: boolean;
72
+ };
73
+ trendline: {
74
+ period: number;
75
+ order: number;
76
+ opacity: number;
77
+ width: number;
78
+ dashType: ChartBorderDashType;
79
+ color: string;
80
+ showFormula: boolean;
81
+ showR2: boolean;
82
+ };
66
83
  tooltipAxisLabelBackground: string;
67
84
  tooltipAxisLabelColor: string;
68
85
  indicatorLineType: ChartBorderDashType;
@@ -0,0 +1,3 @@
1
+ import { ChartModel } from '../chart-model';
2
+ import { ChartTypeBits } from '../../enum';
3
+ export declare const wordCloudDataContextTransformer: (fromType: ChartTypeBits, toType: ChartTypeBits, model: ChartModel) => void;
@@ -22,11 +22,11 @@ export declare class EChartRenderEngine extends Disposable implements EChartInst
22
22
  constructor();
23
23
  getDevicePixelRatio(): 1 | 2 | undefined;
24
24
  mount(id: string | HTMLElement): void;
25
- resize(): void;
25
+ resize(echartsProvider?: any): void;
26
26
  private _ensureChartInstance;
27
27
  get containerElement(): HTMLElement | null;
28
- render(spec: EChartSpec): void;
29
- exportImg(): Promise<string>;
28
+ render(spec: EChartSpec, echartsProvider?: any): void;
29
+ exportImg(echartsProvider?: any): Promise<string>;
30
30
  onDispose(): void;
31
31
  dispose(): void;
32
32
  }
@@ -0,0 +1,2 @@
1
+ import { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
+ export declare const funnelChartConverter: IChartRenderSpecConverter<EChartSpec>;
@@ -0,0 +1,2 @@
1
+ import { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
+ export declare const scatterChartConverter: IChartRenderSpecConverter<EChartSpec>;
@@ -0,0 +1,75 @@
1
+ import { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
+ interface IWordCloudTextStyle {
3
+ color?: string;
4
+ fontStyle?: string;
5
+ fontWeight?: string | number;
6
+ fontFamily?: string;
7
+ fontSize?: number | string;
8
+ align?: string;
9
+ verticalAlign?: string;
10
+ baseline?: string;
11
+ opacity?: number;
12
+ lineHeight?: number;
13
+ backgroundColor?: string | {
14
+ image: HTMLImageElement | HTMLCanvasElement | string;
15
+ };
16
+ borderColor?: string;
17
+ borderWidth?: number;
18
+ borderType?: string;
19
+ borderDashOffset?: number;
20
+ borderRadius?: number | number[];
21
+ padding?: number | number[];
22
+ width?: number | string;
23
+ height?: number;
24
+ textBorderColor?: string;
25
+ textBorderWidth?: number;
26
+ textBorderType?: string;
27
+ textBorderDashOffset?: number;
28
+ textShadowBlur?: number;
29
+ textShadowColor?: string;
30
+ textShadowOffsetX?: number;
31
+ textShadowOffsetY?: number;
32
+ }
33
+ export interface IWorldCloudDataItem {
34
+ name?: string;
35
+ value?: number | number[];
36
+ textStyle?: IWordCloudTextStyle;
37
+ emphasis?: {
38
+ textStyle?: IWordCloudTextStyle;
39
+ };
40
+ }
41
+ export interface IWordCloudSeriesOption {
42
+ mainType?: 'series';
43
+ type?: 'wordCloud';
44
+ silent?: boolean;
45
+ blendMode?: string;
46
+ /**
47
+ * Cursor when mouse on the elements
48
+ */
49
+ cursor?: string;
50
+ width?: number | string;
51
+ height?: number | string;
52
+ top?: number | string;
53
+ right?: number | string;
54
+ bottom?: number | string;
55
+ left?: number | string;
56
+ textStyle?: IWordCloudTextStyle | {
57
+ color?: (params?: any) => string;
58
+ };
59
+ emphasis?: {
60
+ focus?: 'self' | 'series' | 'none';
61
+ blurScope?: 'coordinateSystem' | 'global' | 'series';
62
+ textStyle?: IWordCloudTextStyle;
63
+ };
64
+ shape?: string;
65
+ maskImage?: HTMLImageElement | HTMLCanvasElement;
66
+ sizeRange?: number[];
67
+ rotationRange?: number[];
68
+ rotationStep?: number;
69
+ gridSize?: number;
70
+ drawOutOfBound?: boolean;
71
+ layoutAnimation?: boolean;
72
+ data?: IWorldCloudDataItem[];
73
+ }
74
+ export declare const wordCloudChartConverter: IChartRenderSpecConverter<EChartSpec>;
75
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { Injector } from '@univerjs/core';
2
2
  import { ChartTypeBits } from '../../enum';
3
3
  import { ChartStyle, IChartContext, IChartHostRect, IUniverDataSet } from '../../types';
4
+ import { StaticChartSource } from '../../source/static-chart-source';
4
5
  import { ChartModel } from '../chart-model';
5
6
  /**
6
7
  * The parameters for initializing a chart model.
@@ -50,6 +51,7 @@ export interface IChartModelInitParams {
50
51
  */
51
52
  isRowDirection?: boolean;
52
53
  }
54
+ export declare function generateChartModelContext(chartModel: ChartModel, dataSource: StaticChartSource): IChartContext | null;
53
55
  /**
54
56
  * Convert the initial data to a chart model.
55
57
  * @param initJson The initial data of the chart model.
@@ -0,0 +1,2 @@
1
+ import { EChartRenderSpecOperator } from '../../../../types';
2
+ export declare const trendlineOperator: EChartRenderSpecOperator;
@@ -0,0 +1,13 @@
1
+ type DataPoint = [number, number];
2
+ interface IRegressionResult {
3
+ formula: string;
4
+ execute: (x: number) => number;
5
+ R2: number;
6
+ }
7
+ declare function linearRegression(data: DataPoint[]): IRegressionResult;
8
+ declare function exponentialRegression(data: DataPoint[]): IRegressionResult;
9
+ declare function logarithmicRegression(data: DataPoint[]): IRegressionResult;
10
+ declare function powerRegression(data: DataPoint[]): IRegressionResult;
11
+ declare function polynomialRegression(data: DataPoint[], degree: number): IRegressionResult;
12
+ declare function movingAverage(data: DataPoint[], period: number): (number | null)[];
13
+ export { exponentialRegression, linearRegression, logarithmicRegression, movingAverage, polynomialRegression, powerRegression, };
@@ -0,0 +1,16 @@
1
+ import { Injector, Disposable } from '@univerjs/core';
2
+ export declare class WordCloudMuskImageService extends Disposable {
3
+ private _wordCloudMuskImageCollection;
4
+ constructor();
5
+ loadMuskImage(name: string, url: string): void;
6
+ loadMuskImages(): void;
7
+ getWordCloudImageMask(imgName: string): HTMLImageElement | undefined;
8
+ getWordCloudImageMaskMap(): Map<string, HTMLImageElement>;
9
+ dispose(): void;
10
+ }
11
+ /**
12
+ * This function is used to register the WordCloudMuskImageService service avoiding the repeated registration of the service.
13
+ * @param injector The injector to register the service.
14
+ * @returns {void}
15
+ */
16
+ export declare function registerWordCloudChartMakImageService(injector: Injector): void;
@@ -1,6 +1,8 @@
1
1
  import { IUniverDataSet } from '../types';
2
+ import { BehaviorSubject } from 'rxjs';
2
3
  import { ChartDataSource } from './chart-source';
3
4
  export declare class StaticChartSource extends ChartDataSource {
5
+ _canSwitchOrient$: BehaviorSubject<boolean>;
4
6
  private _columnDirectionDataSetCache;
5
7
  constructor();
6
8
  initData(data: IUniverDataSet, isRowDirection?: boolean): void;
@@ -1,6 +1,6 @@
1
1
  import { CellValue, IDisposable, LocaleService, Nullable } from '@univerjs/core';
2
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';
3
+ import { AreaLineStyle, AxisAlignEnum, AxisValueType, CategoryType, ChartBorderDashType, ChartTrendlineType, ChartTypeBits, DataOrientation, InvalidValueType, IRuntimeAxisPosition, IRuntimeAxisPriority, LabelAlignEnum, LegendPositionEnum, LinePointShape, PieLabelPosition, RadarShape, SelectModeEnum, SeriesLabelPosition, TitlePositionEnum, WordCloudShapeEnum } from './enum';
4
4
  import { IEchartTheme } from './model/constants/build-in-theme';
5
5
  export type DeepPartial<T> = T extends Record<string, any> ? T extends any[] ? T : {
6
6
  [key in keyof T]+?: DeepPartial<T[key]>;
@@ -63,7 +63,7 @@ export interface IChartDataSeries {
63
63
  name: string;
64
64
  items: IChartDataItem[];
65
65
  }
66
- interface IChartDataItem {
66
+ export interface IChartDataItem {
67
67
  value: OptionDataValue;
68
68
  label: string;
69
69
  }
@@ -79,6 +79,7 @@ export interface IChartRuntimeContext {
79
79
  hasSecondaryAxis: boolean;
80
80
  localeService: LocaleService;
81
81
  emptyTips: string;
82
+ wordCloudImageMaskMap: Map<string, HTMLImageElement>;
82
83
  }
83
84
  export interface ILabelStyle {
84
85
  visible: boolean;
@@ -95,6 +96,7 @@ export interface ILabelStyle {
95
96
  axisTitleAlign?: AxisAlignEnum | undefined;
96
97
  showMaxLabel?: boolean;
97
98
  showMinLabel?: boolean;
99
+ rotate?: number;
98
100
  }
99
101
  export interface ILegendStyle {
100
102
  position?: LegendPositionEnum;
@@ -157,6 +159,21 @@ export interface ISeriesStyle {
157
159
  export type RightYAxisOptions = Omit<IAxisOptions, 'reverse'>;
158
160
  export interface IAllSeriesStyle extends Pick<ISeriesStyle, 'border' | 'label' | 'rightYAxis' | 'point' | 'color'> {
159
161
  }
162
+ export interface ITrendLine {
163
+ seriesIndex: number;
164
+ type: ChartTrendlineType;
165
+ name: string;
166
+ color?: string;
167
+ width?: number;
168
+ opacity?: number;
169
+ dashType?: ChartBorderDashType;
170
+ order?: number;
171
+ period?: number;
172
+ showFormula?: boolean;
173
+ showR2?: boolean;
174
+ r2Color?: string;
175
+ formulaColor?: string;
176
+ }
160
177
  export interface IChartStyle {
161
178
  runtime: IChartRuntimeContext;
162
179
  width: number;
@@ -185,6 +202,7 @@ export interface IChartStyle {
185
202
  seriesStyleMap: {
186
203
  [id: string]: ISeriesStyle;
187
204
  };
205
+ trendlines: ITrendLine[];
188
206
  pie: {
189
207
  doughnutHole: Nullable<number>;
190
208
  labelStyle: IPieLabelStyle;
@@ -201,6 +219,15 @@ export interface IChartStyle {
201
219
  shape: RadarShape;
202
220
  fill: boolean;
203
221
  };
222
+ funnel: {
223
+ gap: number;
224
+ useAbsValue: boolean;
225
+ };
226
+ wordCloud: {
227
+ shape: WordCloudShapeEnum;
228
+ maskImage: string;
229
+ repeat: boolean;
230
+ };
204
231
  tooltip: {
205
232
  indicatorLabelColor: string;
206
233
  indicatorLineType: ChartBorderDashType;
@@ -247,7 +274,7 @@ export interface IChartThemeOptions {
247
274
  export interface IChartInstance<Spec = Record<string, any>> extends IDisposable {
248
275
  container: HTMLElement | string;
249
276
  mount(id: string | HTMLElement): void;
250
- render(spec: Spec): void;
277
+ render(spec: Spec, echartsProvider?: any): void;
251
278
  exportImg(): Promise<string>;
252
279
  onDispose?(dispose: () => void): void;
253
280
  resize(): void;
@@ -268,4 +295,3 @@ export interface IChartHostRect {
268
295
  width: number;
269
296
  height: number;
270
297
  }
271
- export {};
@@ -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" | "pie" | "bar" | "scatter" | "radar" | "combination";
6
+ chartBitToString(bit: ChartTypeBits): "" | "line" | "pie" | "bar" | "scatter" | "radar" | "funnel" | "combination" | "wordCloud";
7
7
  };
8
8
  export declare const setProperty: (data: Record<string, any>, propertyPath: string, value: any) => void;
9
9
  /**
@@ -19,4 +19,10 @@ interface ISize {
19
19
  export declare const ChartTextMeasureCache: Map<string, ISize>;
20
20
  export declare const calcPosition: (text: string, font: string) => ISize;
21
21
  export declare const clearChartTextMeasureCache: () => void;
22
+ /**
23
+ * We define the chart type can use trend line. In excel it also can use for combined chart ro bar chart.
24
+ * @param {ChartTypeBits} chartType The test chart type.
25
+ * @returns {boolean} If the chart type can use trend line, return true, otherwise return false.
26
+ */
27
+ export declare const chartTypeCanUseTrendLine: (chartType: ChartTypeBits) => boolean;
22
28
  export {};
@@ -0,0 +1,5 @@
1
+ interface IWordCloudResource {
2
+ [iconName: string]: string;
3
+ }
4
+ export declare const WordCloudResourceConfig: IWordCloudResource;
5
+ export {};