@univerjs-pro/engine-chart 1.0.0-alpha.6 → 1.0.0-alpha.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.
Files changed (93) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +1 -1
  3. package/lib/es/facade.js +1 -1
  4. package/lib/es/index.js +1 -1
  5. package/lib/facade.js +1 -1
  6. package/lib/index.js +1 -1
  7. package/lib/types/chart-builder/candlestick-inline-table.d.ts +4 -0
  8. package/lib/types/chart-builder/chart-builder-adapter.d.ts +3 -3
  9. package/lib/types/chart-builder/chart-builder.d.ts +3 -3
  10. package/lib/types/chart-builder/chart-color.d.ts +49 -0
  11. package/lib/types/chart-builder/chart-starter-data.d.ts +3 -0
  12. package/lib/types/chart-builder/chart-types.d.ts +109 -68
  13. package/lib/types/chart-builder/configuration/assertions.d.ts +3 -0
  14. package/lib/types/chart-builder/configuration/auto-gradient-fill.d.ts +4 -0
  15. package/lib/types/chart-builder/configuration/candlestick.d.ts +9 -0
  16. package/lib/types/chart-builder/configuration/chart-config-operation.d.ts +4 -0
  17. package/lib/types/chart-builder/configuration/histogram.d.ts +11 -0
  18. package/lib/types/chart-builder/configuration/index.d.ts +5 -0
  19. package/lib/types/chart-builder/configuration/pie.d.ts +5 -1
  20. package/lib/types/chart-builder/configuration/point-mapping.d.ts +3 -0
  21. package/lib/types/chart-builder/configuration/treemap.d.ts +8 -0
  22. package/lib/types/chart-builder/conversion/chart-config-converter.d.ts +8 -3
  23. package/lib/types/chart-builder/conversion/chart-context-patch.d.ts +5 -0
  24. package/lib/types/chart-builder/conversion/chart-model-fields.d.ts +6 -0
  25. package/lib/types/chart-builder/conversion/resolve-chart-model-data.d.ts +3 -3
  26. package/lib/types/chart-builder/index.d.ts +5 -0
  27. package/lib/types/chart-builder/internal/host-builder-runtime.d.ts +0 -2
  28. package/lib/types/chart-text-measure-canvas.d.ts +6 -0
  29. package/lib/types/enum.d.ts +34 -1
  30. package/lib/types/facade/builders/f-area-chart-builder.d.ts +2 -2
  31. package/lib/types/facade/builders/f-boxplot-chart-builder.d.ts +5 -0
  32. package/lib/types/facade/builders/f-bubble-chart-builder.d.ts +2 -2
  33. package/lib/types/facade/builders/f-candlestick-chart-builder.d.ts +133 -0
  34. package/lib/types/facade/builders/f-histogram-chart-builder.d.ts +74 -0
  35. package/lib/types/facade/builders/f-line-chart-builder.d.ts +2 -2
  36. package/lib/types/facade/builders/f-pie-chart-builder.d.ts +42 -1
  37. package/lib/types/facade/builders/f-relation-chart-builder.d.ts +38 -0
  38. package/lib/types/facade/builders/f-scatter-chart-builder.d.ts +2 -2
  39. package/lib/types/facade/builders/f-treemap-chart-builder.d.ts +34 -0
  40. package/lib/types/facade/builders/index.d.ts +4 -0
  41. package/lib/types/facade/chart-builder-type-map.d.ts +5 -2
  42. package/lib/types/facade/f-cartesian-chart-builder.d.ts +14 -4
  43. package/lib/types/facade/f-chart-base.d.ts +2 -2
  44. package/lib/types/facade/f-chart-builder-base.d.ts +31 -0
  45. package/lib/types/index.d.ts +10 -9
  46. package/lib/types/models/chart-data-operators/histogram-data.d.ts +10 -0
  47. package/lib/types/models/chart-data-operators/index.d.ts +1 -0
  48. package/lib/types/models/chart-data-operators/operators.d.ts +7 -1
  49. package/lib/types/models/chart-data-operators/treemap-data.d.ts +3 -0
  50. package/lib/types/models/chart-element-edit-overlay/chart-element-edit-overlay.d.ts +2 -1
  51. package/lib/types/models/chart-locale-texts.d.ts +15 -1
  52. package/lib/types/models/chart-model.d.ts +368 -164
  53. package/lib/types/models/constants/default-chart-style.d.ts +45 -0
  54. package/lib/types/models/constants/histogram-defaults.d.ts +4 -0
  55. package/lib/types/models/constants/treemap.d.ts +1 -0
  56. package/lib/types/models/data-context-transformers/candlestick-data-context-transformer.d.ts +4 -0
  57. package/lib/types/models/data-context-transformers/histogram-data-context-transformer.d.ts +7 -0
  58. package/lib/types/models/data-context-transformers/treemap-data-context-transformer.d.ts +11 -0
  59. package/lib/types/models/echart-render-model.d.ts +10 -7
  60. package/lib/types/models/echart-to-chart-model-init.d.ts +2 -1
  61. package/lib/types/models/mode-converter/converters/boxplot-chart-converter.d.ts +3 -2
  62. package/lib/types/models/mode-converter/converters/bubble-chart-converter.d.ts +3 -2
  63. package/lib/types/models/mode-converter/converters/candlestick-chart-converter.d.ts +5 -0
  64. package/lib/types/models/mode-converter/converters/combination-chart-converter.d.ts +3 -2
  65. package/lib/types/models/mode-converter/converters/funnel-chart-converter.d.ts +3 -2
  66. package/lib/types/models/mode-converter/converters/heatmap-chart-convert.d.ts +3 -2
  67. package/lib/types/models/mode-converter/converters/histogram-chart-converter.d.ts +4 -0
  68. package/lib/types/models/mode-converter/converters/pareto-chart-converter.d.ts +3 -2
  69. package/lib/types/models/mode-converter/converters/pie-chart-converter.d.ts +3 -2
  70. package/lib/types/models/mode-converter/converters/radar-chart-converter.d.ts +3 -2
  71. package/lib/types/models/mode-converter/converters/relation-chart-converter.d.ts +3 -2
  72. package/lib/types/models/mode-converter/converters/sankey-chart-converter.d.ts +3 -2
  73. package/lib/types/models/mode-converter/converters/scatter-chart-converter.d.ts +3 -2
  74. package/lib/types/models/mode-converter/converters/treemap-chart-converter.d.ts +4 -0
  75. package/lib/types/models/mode-converter/converters/waterfall-chart-converter.d.ts +3 -2
  76. package/lib/types/models/mode-converter/converters/word-cloud-converter.d.ts +3 -2
  77. package/lib/types/models/mode-converter/render-spec-operators/auto-gradient-presets.d.ts +5 -0
  78. package/lib/types/models/mode-converter/render-spec-operators/chart-color.d.ts +23 -0
  79. package/lib/types/models/mode-converter/render-spec-operators/rich-text-inheritance.operator.d.ts +2 -0
  80. package/lib/types/models/mode-converter/render-spec-operators/tool-tip-operator.d.ts +8 -2
  81. package/lib/types/models/mode-converter/render-spec-operators/tools.d.ts +3 -2
  82. package/lib/types/types.d.ts +147 -13
  83. package/lib/types/util.d.ts +1 -7
  84. package/lib/types/wordcloud-chart/canvas.d.ts +3 -3
  85. package/lib/types/wordcloud-chart/core/layout/word-shrink.d.ts +5 -8
  86. package/lib/types/wordcloud-chart/core/text/formatter.d.ts +2 -2
  87. package/lib/types/wordcloud-chart/core/text/normalize.d.ts +2 -2
  88. package/lib/types/wordcloud-chart/defaults.d.ts +2 -2
  89. package/lib/types/wordcloud-chart/index.d.ts +1 -1
  90. package/lib/types/wordcloud-chart/types.d.ts +0 -3
  91. package/lib/umd/facade.js +1 -1
  92. package/lib/umd/index.js +1 -1
  93. package/package.json +5 -5
@@ -129,8 +129,53 @@ export declare const defaultChartConfig: {
129
129
  };
130
130
  pareto: {
131
131
  symbolSize: number;
132
+ barThemeColorIndex: number;
133
+ lineThemeColorIndex: number;
132
134
  };
133
135
  heatmap: {
134
136
  visualMapType: string;
135
137
  };
138
+ candlestick: {
139
+ rising: {
140
+ color: string;
141
+ fillOpacity: number;
142
+ border: {
143
+ color: string;
144
+ width: number;
145
+ opacity: number;
146
+ };
147
+ hollow: boolean;
148
+ };
149
+ falling: {
150
+ color: string;
151
+ fillOpacity: number;
152
+ border: {
153
+ color: string;
154
+ width: number;
155
+ opacity: number;
156
+ };
157
+ hollow: boolean;
158
+ };
159
+ doji: {
160
+ color: string;
161
+ fillOpacity: number;
162
+ border: {
163
+ color: string;
164
+ width: number;
165
+ opacity: number;
166
+ };
167
+ hollow: boolean;
168
+ };
169
+ };
170
+ histogram: {
171
+ binGap: number;
172
+ legendVisible: boolean;
173
+ };
174
+ treemap: {
175
+ parentLabelLayout: "banner";
176
+ label: {
177
+ visible: boolean;
178
+ contentType: LabelContentType;
179
+ };
180
+ };
136
181
  };
@@ -0,0 +1,4 @@
1
+ /** Ratio of each category band reserved as the default separator between Histogram bins. */
2
+ export declare const DEFAULT_HISTOGRAM_BIN_GAP = 0.007;
3
+ /** Largest supported ratio of a category band reserved between Histogram bins. */
4
+ export declare const MAX_HISTOGRAM_BIN_GAP = 0.9;
@@ -0,0 +1 @@
1
+ export declare const TREEMAP_MAPPING_DIAGNOSTIC = "Treemap requires at least one hierarchy field and one numeric value field.";
@@ -0,0 +1,4 @@
1
+ import type { ChartModel } from '../chart-model';
2
+ import { ChartTypeBits } from '../../enum';
3
+ /** Transforms canonical context when entering or leaving the Candlestick type. */
4
+ export declare function candlestickDataContextTransformer(fromType: ChartTypeBits, toType: ChartTypeBits, model: ChartModel): void;
@@ -0,0 +1,7 @@
1
+ import type { IChartContext, IChartDataSource } from '../../types';
2
+ import type { ChartModel } from '../chart-model';
3
+ import { ChartTypeBits } from '../../enum';
4
+ /** Selects the first finite-numeric source field without using header text. */
5
+ export declare function resolveHistogramField(dataSource: IChartDataSource, context: IChartContext): number | undefined;
6
+ /** Stashes normal mappings while Histogram owns exactly one active value field. */
7
+ export declare function histogramDataContextTransformer(fromType: ChartTypeBits, toType: ChartTypeBits, model: ChartModel): void;
@@ -0,0 +1,11 @@
1
+ import type { IChartDataSource } from '../../types';
2
+ import type { ChartModel } from '../chart-model';
3
+ import { ChartTypeBits } from '../../enum';
4
+ export interface IResolvedTreemapMapping {
5
+ hierarchyIndexes: number[];
6
+ seriesIndexes: [number];
7
+ }
8
+ /** Infers the last field containing finite numeric data as value and all preceding fields as hierarchy. */
9
+ export declare function resolveTreemapMapping(dataSource: IChartDataSource): IResolvedTreemapMapping | undefined;
10
+ /** Stashes ordinary category/series mapping while Treemap owns hierarchy plus one value. */
11
+ export declare function treemapDataContextTransformer(fromType: ChartTypeBits, toType: ChartTypeBits, model: ChartModel): void;
@@ -1,4 +1,5 @@
1
- import type { ChartElementEventHandler, ChartElementEventType, ChartImageSource, ChartStyle, EChartInstance, EChartSpec, IChartConfig, IChartHostRect, IChartInstance, IChartRenderAsImageOptions, IChartRenderInstance, IChartRenderInstanceCreateContext, IChartRenderModel, IChartRenderModelImageExportInput, IChartRenderModelImageExportOptions, IChartRenderModelImageExportResult, IChartRenderModelStylizeInit, IChartRenderRuntimeOptions } from '../types';
1
+ import type { ChartElementEventHandler, ChartElementEventType, ChartImageSource, ChartStyle, EChartInstance, IChartConfig, IChartElementHit, IChartHostRect, IChartInstance, IChartRenderAsImageOptions, IChartRenderInstance, IChartRenderInstanceCreateContext, IChartRenderModel, IChartRenderModelImageExportInput, IChartRenderModelImageExportOptions, IChartRenderModelImageExportResult, IChartRenderModelStylizeInit, IChartRenderRuntimeOptions } from '../types';
2
+ import type { EChartsOption } from '../utils/echarts';
2
3
  import type { IWordCloudRenderConfig } from '../wordcloud-chart/word-cloud-render-config';
3
4
  import { Disposable } from '@univerjs/core';
4
5
  import { ChartHostRenderMode } from '../types';
@@ -14,17 +15,19 @@ export declare class EChartRenderModel extends Disposable implements IChartRende
14
15
  updateWatermark(addWatermark: boolean): void;
15
16
  private _addSpecConverters;
16
17
  private _addSpecOperators;
17
- createChartInstance(): IChartInstance<EChartSpec>;
18
- createChartInstance(mode: ChartHostRenderMode, context?: IChartRenderInstanceCreateContext<EChartSpec>): IChartRenderInstance;
18
+ createChartInstance(): IChartInstance<EChartsOption>;
19
+ createChartInstance(mode: ChartHostRenderMode, context?: IChartRenderInstanceCreateContext<EChartsOption>): IChartRenderInstance;
19
20
  clearRuntimeCache(chartId: string): void;
20
21
  clearAllRuntimeCache(): void;
21
22
  dispose(): void;
22
- toSpec(config: IChartConfig, style: ChartStyle): import("echarts").EChartsOption;
23
- stylizeSpec(spec: EChartSpec, stylizeInit: IChartRenderModelStylizeInit<EChartSpec>, rect: IChartHostRect): import("echarts").EChartsOption | {
23
+ toSpec(config: IChartConfig, style: ChartStyle): EChartsOption;
24
+ stylizeSpec(spec: EChartsOption, stylizeInit: IChartRenderModelStylizeInit<EChartsOption>, rect: IChartHostRect): EChartsOption | {
24
25
  backgroundColor: string;
25
26
  };
26
27
  exportImage(input: IChartRenderModelImageExportInput, options?: IChartRenderModelImageExportOptions): Promise<IChartRenderModelImageExportResult>;
27
28
  }
29
+ /** Normalizes renderer-private marks, including Treemap residual leaves, to their semantic identity. */
30
+ export declare function resolveEChartSeriesIdentity(spec: EChartsOption | null, seriesIndex: number | undefined, params?: any): Pick<IChartElementHit, 'seriesId' | 'seriesName' | 'baseSeriesIndex' | 'waterfallSeriesType'>;
28
31
  export declare class EChartRenderEngine extends Disposable implements EChartInstance {
29
32
  static engineName: string;
30
33
  private _instance;
@@ -47,8 +50,8 @@ export declare class EChartRenderEngine extends Disposable implements EChartInst
47
50
  resize(echartsProviderOrOptions?: any | IChartRenderRuntimeOptions): void;
48
51
  private _ensureChartInstance;
49
52
  get containerElement(): HTMLElement | null;
50
- render(spec: EChartSpec, echartsProviderOrOptions?: any | IChartRenderRuntimeOptions): void;
51
- renderAsImage(spec: EChartSpec, options: IChartRenderAsImageOptions): Promise<ChartImageSource>;
53
+ render(spec: EChartsOption, echartsProviderOrOptions?: any | IChartRenderRuntimeOptions): void;
54
+ renderAsImage(spec: EChartsOption, options: IChartRenderAsImageOptions): Promise<ChartImageSource>;
52
55
  on(type: ChartElementEventType, handler: ChartElementEventHandler): {
53
56
  dispose: () => void;
54
57
  };
@@ -1,3 +1,4 @@
1
+ import type { EChartsOption } from '../utils/echarts';
1
2
  import type { IChartModelInitParams } from './mode-converter/mode-converter';
2
- export declare function echartToChartModelInit(echartOption: echarts.EChartsOption): IChartModelInitParams;
3
+ export declare function echartToChartModelInit(echartOption: EChartsOption): IChartModelInitParams;
3
4
  export declare function isChartModelInit(option: any): option is IChartModelInitParams;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const boxplotChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const boxplotChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const bubbleChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const bubbleChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -0,0 +1,5 @@
1
+ import type { IChartCandlestickPoint, IChartRenderSpecConverter } from '../../../types';
2
+ import type { EChartsOption } from '../../../utils/echarts';
3
+ import { ChartCandlestickState } from '../../../enum';
4
+ export declare function classifyCandlestickPoint(point: Pick<IChartCandlestickPoint, 'open' | 'close'>): ChartCandlestickState;
5
+ export declare const candlestickChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const combinationChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const combinationChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const funnelChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const funnelChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const heatmapChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const heatmapChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -0,0 +1,4 @@
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartHistogramBin, IChartRenderSpecConverter } from '../../../types';
3
+ export declare function createHistogramIntervalFormatter(bins: readonly IChartHistogramBin[], pattern?: string): (bin: IChartHistogramBin, index: number) => string;
4
+ export declare const histogramChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const paretoChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const paretoChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const pieChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const pieChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const radarChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const radarChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const relationChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const relationChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const sankeyChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const sankeyChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const scatterChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const scatterChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -0,0 +1,4 @@
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const TREEMAP_RESIDUAL_ID_PREFIX = "__univer_treemap_residual__:";
4
+ export declare const treemapChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const waterfallChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { IChartRenderSpecConverter } from '../../../types';
2
+ import type { EChartsOption } from '../../../utils/echarts';
3
+ export declare const waterfallChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -1,2 +1,3 @@
1
- import type { EChartSpec, IChartRenderSpecConverter } from '../../../types';
2
- export declare const wordCloudChartConverter: IChartRenderSpecConverter<EChartSpec>;
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { IChartRenderSpecConverter } from '../../../types';
3
+ export declare const wordCloudChartConverter: IChartRenderSpecConverter<EChartsOption>;
@@ -0,0 +1,5 @@
1
+ import type { IChartLinearGradient } from '../../../chart-builder/chart-color';
2
+ export declare function createBarAutoGradient(color: string, isVerticalSeriesValue: boolean, isNegative?: boolean): IChartLinearGradient;
3
+ export declare function createAreaAutoGradient(color: string, isVerticalSeriesValue: boolean): IChartLinearGradient;
4
+ export declare function createLineAutoGradient(color: string, isVerticalSeriesValue: boolean): IChartLinearGradient;
5
+ export declare function createPieAutoGradient(color: string): IChartLinearGradient;
@@ -0,0 +1,23 @@
1
+ import type { ChartColor, IChartLinearGradient } from '../../../chart-builder/chart-color';
2
+ declare const ECHARTS_LINEAR_GRADIENT_TYPE = "linear";
3
+ export interface IEChartsLinearGradientColor {
4
+ type: typeof ECHARTS_LINEAR_GRADIENT_TYPE;
5
+ x: number;
6
+ y: number;
7
+ x2: number;
8
+ y2: number;
9
+ global: false;
10
+ colorStops: Array<{
11
+ offset: number;
12
+ color: string;
13
+ }>;
14
+ }
15
+ export type ChartRenderColor = string | IEChartsLinearGradientColor;
16
+ type RenderColorResolver = (color: string) => string;
17
+ type AutoGradientFactory = (color: string) => IChartLinearGradient;
18
+ export declare const keepRenderColor: RenderColorResolver;
19
+ export declare function getChartColorRepresentative(color: ChartColor): string;
20
+ export declare function toEChartsColor(color: ChartColor, getRenderColor: RenderColorResolver): ChartRenderColor;
21
+ export declare function resolveChartColor(color: ChartColor, autoGradientFill: boolean, createAutoGradient: AutoGradientFactory, getRenderColor: RenderColorResolver): ChartRenderColor;
22
+ export declare function resolveChartColorRepresentative(color: ChartColor, getRenderColor: RenderColorResolver): string;
23
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { EChartRenderSpecOperator } from '../../../types';
2
+ export declare const richTextInheritanceOperator: EChartRenderSpecOperator;
@@ -1,4 +1,5 @@
1
- import type { ChartDirection, ChartStyle, EChartRenderSpecOperator, EChartSpec, IChartConfig } from '../../../types';
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { ChartDirection, ChartStyle, EChartRenderSpecOperator, IChartConfig } from '../../../types';
2
3
  import { InvalidValueType } from '../../../enum';
3
4
  interface ITooltipFormatterDataContext {
4
5
  category: IChartConfig['category'];
@@ -14,6 +15,11 @@ interface ITooltipFormatterDataContext {
14
15
  maxText: string;
15
16
  wordText: string;
16
17
  frequencyText: string;
18
+ candlestickCategoryText: string;
19
+ candlestickOpenText: string;
20
+ candlestickHighText: string;
21
+ candlestickLowText: string;
22
+ candlestickCloseText: string;
17
23
  isDateAxis: boolean | undefined;
18
24
  allSeriesStyle: ChartStyle['allSeriesStyle'];
19
25
  seriesStyleMap: ChartStyle['seriesStyleMap'];
@@ -29,7 +35,7 @@ interface ITooltipFormatters {
29
35
  wordCloud: (params: any) => string;
30
36
  }
31
37
  export declare function excelDateToUnixMilliseconds(excelDate: number, useDefault1900DateSystem?: boolean): number;
32
- export declare function createTooltipFormatterDataContext(spec: EChartSpec, style: ChartStyle, config: IChartConfig): ITooltipFormatterDataContext;
38
+ export declare function createTooltipFormatterDataContext(spec: EChartsOption, style: ChartStyle, config: IChartConfig): ITooltipFormatterDataContext;
33
39
  export declare function createLTRTooltipFormatters(context: ITooltipFormatterDataContext, config: IChartConfig): ITooltipFormatters;
34
40
  export declare function createRTLTooltipFormatters(context: ITooltipFormatterDataContext, config: IChartConfig): ITooltipFormatters;
35
41
  export declare function createTooltipFormatters(context: ITooltipFormatterDataContext, config: IChartConfig, direction: ChartDirection): ITooltipFormatters;
@@ -1,10 +1,11 @@
1
- import type { ChartStyle, EChartSeriesItem, EChartSpec, ILabelStyle } from '../../../types';
1
+ import type { EChartsOption } from '../../../utils/echarts';
2
+ import type { ChartStyle, EChartSeriesItem, ILabelStyle } from '../../../types';
2
3
  import type { ISpecGrid } from './operator-types';
3
4
  type PartialLabelStyle = Partial<Pick<ILabelStyle, 'visible' | 'color' | 'fontSize' | 'family' | 'italic' | 'bold' | 'underline' | 'strikethrough' | 'showMaxLabel' | 'showMinLabel'>>;
4
5
  export declare function applyLabelStyle(spec: Record<string, any>, path: string, labelStyle: PartialLabelStyle): void;
5
6
  export declare function applyLineStyle(spec: Record<string, any>, path: string, labelStyle: PartialLabelStyle): void;
6
7
  export declare function toArray<T = unknown>(value: T | T[]): T[];
7
- export declare function seriesForEach(series: EChartSpec['series'], func: (item: EChartSeriesItem, index: number) => void): void;
8
+ export declare function seriesForEach(series: EChartsOption['series'], func: (item: EChartSeriesItem, index: number) => void): void;
8
9
  export declare function toPercentage(value: number, fixed?: number): string;
9
10
  export declare const getCategoryLabelVertical: (gridInfo: ISpecGrid, style: ChartStyle) => number;
10
11
  export declare const getCategoryLabelHorizontal: (gridInfo: ISpecGrid, style: ChartStyle, seriesCount: number, axisLabelMaxWidth?: number) => number;
@@ -1,14 +1,19 @@
1
1
  import type { IDisposable, Nullable } from '@univerjs/core';
2
2
  import type { Observable } from 'rxjs';
3
- import type { AreaLineStyle, AxisAlignEnum, AxisValueType, BarShape, CategoryType, ChartAxisDimension, ChartBorderDashType, ChartMarkLineLabelPosition, ChartSemanticAxis, ChartSourceDataTypeEnum, ChartTrendlineType, ChartTypeBits, ChartWaterfallPointRole, DataOrientation, InvalidValueType, IRuntimeAxisPosition, IRuntimeAxisPriority, LabelAlignEnum, LegendPositionEnum, LinePointShape, PieLabelPosition, RadarShape, RelationChartLayoutEnum, SelectModeEnum, SeriesLabelPosition, TitlePositionEnum, WaterfallSeriesTypeEnum, WaterfallStackTypeEnum, WordCloudShapeEnum } from './enum';
3
+ import type { ChartColor, IChartLinearGradient } from './chart-builder/chart-color';
4
+ import type { AreaLineStyle, AxisAlignEnum, AxisValueType, BarShape, CategoryType, ChartAxisDimension, ChartBorderDashType, ChartHistogramBinKind, ChartMarkLineLabelPosition, ChartSemanticAxis, ChartSourceDataTypeEnum, ChartTrendlineType, ChartTypeBits, ChartWaterfallPointRole, DataOrientation, HistogramBinningMode, InvalidValueType, IRuntimeAxisPosition, IRuntimeAxisPriority, LabelAlignEnum, LabelContentType, LegendPositionEnum, LinePointShape, PieLabelPosition, RadarShape, RelationChartLayoutEnum, SelectModeEnum, SeriesLabelPosition, TitlePositionEnum, TreemapParentLabelLayout, WaterfallSeriesTypeEnum, WaterfallStackTypeEnum, WordCloudShapeEnum } from './enum';
4
5
  import type { ICartesianPointData } from './models/chart-data-operators/cartesian-point-data';
5
6
  import type { IChartLocaleTexts } from './models/chart-locale-texts';
6
7
  import type { IEchartTheme } from './models/constants/build-in-theme';
7
- import type { BarSeriesOption } from './utils/echarts';
8
+ import type { BarSeriesOption, EChartsOption } from './utils/echarts';
8
9
  import type { IWordCloudRenderConfig } from './wordcloud-chart/word-cloud-render-config';
9
- export type DeepPartial<T> = T extends Record<string, any> ? T extends any[] ? T : {
10
+ export type DeepPartial<T> = T extends IChartLinearGradient ? T : T extends Record<string, any> ? T extends any[] ? T : {
10
11
  [key in keyof T]+?: DeepPartial<T[key]>;
11
12
  } : T;
13
+ /** Recursive patch shape that permits `null` at every field and treats arrays as atomic values. */
14
+ export type DeepNullish<T> = T extends (...args: never[]) => unknown ? T : T extends readonly unknown[] ? T : T extends object ? {
15
+ [K in keyof T]?: DeepNullish<T[K]> | null;
16
+ } : T;
12
17
  export type ChartDirection = 'ltr' | 'rtl';
13
18
  export interface IChartDataSource {
14
19
  data$: Observable<IUniverDataSet>;
@@ -27,8 +32,7 @@ export interface IDimensionDefinition {
27
32
  }
28
33
  export type DimensionDefinitionLoose = IDimensionDefinition['name'] | IDimensionDefinition;
29
34
  export type OptionDataValue = string | number | Date | null | undefined;
30
- export type ChartDataSourceValue = OptionDataValue;
31
- export type ChartDataSourceValues = ChartDataSourceValue[][];
35
+ export type ChartDataSourceValues = OptionDataValue[][];
32
36
  /**
33
37
  * Canonical chart dataset used by chart context operators and chart-data builders.
34
38
  *
@@ -46,10 +50,93 @@ export interface IUniverDataSet {
46
50
  sourceType?: ChartSourceDataTypeEnum[][];
47
51
  sourceLabels?: string[][];
48
52
  }
53
+ /** Ordered field names that define the persisted Candlestick OHLC mapping contract. */
54
+ export declare const CHART_CANDLESTICK_MAPPING_FIELDS: readonly ["openIndex", "highIndex", "lowIndex", "closeIndex"];
55
+ /** Required semantic OHLC source fields for one Candlestick series. */
56
+ export interface IChartCandlestickMappingSpec {
57
+ openIndex: number;
58
+ highIndex: number;
59
+ lowIndex: number;
60
+ closeIndex: number;
61
+ }
62
+ /** Semantic body and wick appearance for one Candlestick state. */
63
+ export interface IChartCandlestickStateStyleSpec {
64
+ color?: string;
65
+ fillOpacity?: number;
66
+ border?: {
67
+ color?: string;
68
+ width?: number;
69
+ opacity?: number;
70
+ };
71
+ hollow?: boolean;
72
+ }
73
+ /** Semantic Candlestick style overrides persisted by the chart model. */
74
+ export interface IChartCandlestickSpec {
75
+ rising?: IChartCandlestickStateStyleSpec;
76
+ falling?: IChartCandlestickStateStyleSpec;
77
+ doji?: IChartCandlestickStateStyleSpec;
78
+ candleWidth?: number;
79
+ }
80
+ /** Histogram bin sizing configuration persisted by the semantic chart model. */
81
+ export type IChartHistogramBinningSpec = {
82
+ mode: typeof HistogramBinningMode.Count;
83
+ count: number;
84
+ } | {
85
+ mode: typeof HistogramBinningMode.Width;
86
+ width: number;
87
+ };
88
+ /** Persisted Histogram data-processing options. Omission selects Scott Auto binning. */
89
+ export interface IChartHistogramDataSpec {
90
+ binning?: IChartHistogramBinningSpec;
91
+ underflowThreshold?: number;
92
+ overflowThreshold?: number;
93
+ }
94
+ /** Persisted Histogram appearance options. */
95
+ export interface IChartHistogramStyleSpec {
96
+ /** Gap ratio between adjacent bins. Effective values are from 0 through 0.9. */
97
+ binGap?: number;
98
+ }
99
+ /** Public Histogram semantic configuration. */
100
+ export interface IChartHistogramSpec extends IChartHistogramDataSpec, IChartHistogramStyleSpec {
101
+ }
102
+ /** Persisted leaf-label style supported by Treemap charts. */
103
+ export interface IChartTreemapLabelSpec {
104
+ visible?: boolean;
105
+ contentType?: LabelContentType;
106
+ color?: string;
107
+ fontSize?: number;
108
+ bold?: boolean;
109
+ italic?: boolean;
110
+ family?: string;
111
+ }
112
+ /** Public Treemap semantic style configuration. */
113
+ export interface IChartTreemapSpec {
114
+ parentLabelLayout?: TreemapParentLabelLayout;
115
+ label?: IChartTreemapLabelSpec;
116
+ }
117
+ /** Runtime-only renderer-independent Treemap node. */
118
+ export interface IChartTreemapNode {
119
+ id: string;
120
+ name: string;
121
+ path: string[];
122
+ value: number;
123
+ selfValue: number;
124
+ children?: IChartTreemapNode[];
125
+ }
126
+ /** Runtime-only Treemap data prepared from the canonical flat mapping. */
127
+ export interface IChartTreemapData {
128
+ valueFieldName: string;
129
+ nodes: IChartTreemapNode[];
130
+ /** Runtime-only top-level first-source order used for stable palette assignment. */
131
+ paletteOrder?: string[];
132
+ diagnostic?: string;
133
+ }
49
134
  export interface IChartContext {
50
135
  headers?: string[];
51
136
  categoryType?: CategoryType;
52
137
  categoryIndex?: number;
138
+ /** Ordered root-to-leaf hierarchy field indexes. Historical payloads omit it. */
139
+ hierarchyIndexes?: number[];
53
140
  /**
54
141
  * the flag to indicate whether the chart use date axis, only all category data is date type, the chart will use date axis, if there are some string type data, the chart will use category axis even the flag is true.
55
142
  */
@@ -66,6 +153,8 @@ export interface IChartContext {
66
153
  scatterLabelIndex?: number;
67
154
  bubbleSizeIndex?: number;
68
155
  bubbleSeriesIndex?: number;
156
+ candlestick?: IChartCandlestickMappingSpec;
157
+ histogram?: IChartHistogramDataSpec;
69
158
  }
70
159
  export interface IRelationNodes {
71
160
  id: string;
@@ -93,6 +182,9 @@ export interface IChartData {
93
182
  */
94
183
  dataset?: IUniverDataSet;
95
184
  cartesianPoint?: ICartesianPointData;
185
+ candlestickData?: IChartCandlestickData;
186
+ histogramData?: IChartHistogramData;
187
+ treemapData?: IChartTreemapData;
96
188
  heatmapData?: {
97
189
  xData: string[];
98
190
  yData: string[];
@@ -117,6 +209,38 @@ export interface IChartData {
117
209
  isCircular: boolean;
118
210
  };
119
211
  }
212
+ /** One semantic OHLC point. Renderer tuple order is intentionally absent. */
213
+ export interface IChartCandlestickPoint {
214
+ open: number;
215
+ high: number;
216
+ low: number;
217
+ close: number;
218
+ labels: {
219
+ open: string;
220
+ high: string;
221
+ low: string;
222
+ close: string;
223
+ };
224
+ }
225
+ /** One aligned semantic Candlestick series. */
226
+ export interface IChartCandlestickData {
227
+ name: string;
228
+ items: Array<IChartCandlestickPoint | null>;
229
+ }
230
+ /** Numeric semantic Histogram bin. Renderer labels are intentionally absent. */
231
+ export interface IChartHistogramBin {
232
+ kind: ChartHistogramBinKind;
233
+ lowerBound?: number;
234
+ upperBound?: number;
235
+ count: number;
236
+ }
237
+ /** Derived runtime-only Histogram data. */
238
+ export interface IChartHistogramData {
239
+ sourceIndex: number;
240
+ name: string;
241
+ validSampleCount: number;
242
+ bins: IChartHistogramBin[];
243
+ }
120
244
  export interface ISankeyNode {
121
245
  name: string;
122
246
  }
@@ -226,7 +350,8 @@ export interface IPointStyle {
226
350
  size: number;
227
351
  color: Nullable<string>;
228
352
  }
229
- export interface IDataPointStyle extends IPointStyle {
353
+ export interface IDataPointStyle extends Omit<IPointStyle, 'color'> {
354
+ color: Nullable<ChartColor>;
230
355
  /** Fill opacity for this data point, from 0 (transparent) to 1 (opaque). */
231
356
  fillOpacity?: number;
232
357
  }
@@ -234,7 +359,7 @@ export interface ISeriesStyle {
234
359
  chartType?: ChartTypeBits.Line | ChartTypeBits.Column | ChartTypeBits.Area;
235
360
  /** Compatibility switch for placing this series on the secondary vertical axis. It does not change the yAxis/rightYAxis option bucket semantics. */
236
361
  rightYAxis?: boolean;
237
- color: Nullable<string>;
362
+ color: Nullable<ChartColor>;
238
363
  /** Fill opacity for this series, from 0 (transparent) to 1 (opaque). */
239
364
  fillOpacity: number;
240
365
  border: {
@@ -378,6 +503,13 @@ export interface IChartStyle {
378
503
  valueScale: number;
379
504
  valueSuffix: string;
380
505
  digitalFixed: number;
506
+ /** Persisted sparse slice overrides. Slice data remains owned by the chart data source. */
507
+ sliceStyles: {
508
+ [index: number]: {
509
+ color: Nullable<ChartColor>;
510
+ fillOpacity?: number;
511
+ };
512
+ };
381
513
  };
382
514
  area: {
383
515
  lineStyle: AreaLineStyle;
@@ -430,6 +562,9 @@ export interface IChartStyle {
430
562
  unit?: string;
431
563
  label?: ISeriesLabelStyle;
432
564
  };
565
+ candlestick: IChartCandlestickSpec;
566
+ histogram: IChartHistogramStyleSpec;
567
+ treemap: IChartTreemapSpec;
433
568
  }
434
569
  export interface IRelationForceOptions {
435
570
  repulsion?: number;
@@ -448,13 +583,13 @@ export interface IChartSnapshot {
448
583
  id: string;
449
584
  chartType: ChartTypeBits;
450
585
  orient?: DataOrientation;
451
- context?: Pick<IChartContext, 'categoryIndex' | 'seriesIndexes' | 'transform'>;
586
+ context?: Pick<IChartContext, 'categoryIndex' | 'hierarchyIndexes' | 'seriesIndexes' | 'transform' | 'candlestick' | 'histogram'>;
452
587
  style?: ChartStyle;
453
588
  dataAggregation?: IChartDataAggregation;
454
589
  }
455
590
  export interface IWaterfallLegendData {
456
591
  name: string;
457
- color: string;
592
+ color: ChartColor;
458
593
  }
459
594
  export interface IChartRenderSpecConverter<ChartRenderSpec = Record<string, any>> {
460
595
  canConvert: (config: IChartConfig) => boolean;
@@ -653,13 +788,12 @@ export interface IChartInstanceConstructor<Spec> {
653
788
  }
654
789
  export type OptionalDataValue = number | string | null | undefined;
655
790
  export type ExtractArrayItem<T> = T extends Array<infer U> ? U : never;
656
- export type EChartSpec = echarts.EChartsOption;
657
- export type EChartSeriesItem = ExtractArrayItem<EChartSpec['series']> & {
791
+ export type EChartSeriesItem = ExtractArrayItem<EChartsOption['series']> & {
658
792
  rawData?: number[];
659
793
  seriesId: string;
660
794
  };
661
- export type EChartInstance = IChartInstance<EChartSpec>;
662
- export type EChartRenderSpecOperator = RenderSpecOperator<EChartSpec>;
795
+ export type EChartInstance = IChartInstance<EChartsOption>;
796
+ export type EChartRenderSpecOperator = RenderSpecOperator<EChartsOption>;
663
797
  export interface IChartHostRect {
664
798
  width: number;
665
799
  height: number;
@@ -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" | "bar" | "wordCloud" | "scatter" | "pie" | "radar" | "graph" | "funnel" | "sankey" | "boxplot" | "heatmap" | "combination";
6
+ chartBitToString(bit: ChartTypeBits): "" | "line" | "bar" | "wordCloud" | "candlestick" | "scatter" | "pie" | "radar" | "treemap" | "graph" | "funnel" | "sankey" | "boxplot" | "heatmap" | "combination";
7
7
  };
8
8
  export declare function mergeChartConfig<T extends object>(current: T | undefined, update: Partial<T>): T;
9
9
  export declare const setProperty: (data: Record<string, any>, propertyPath: string, value: any) => void;
@@ -14,11 +14,6 @@ export declare const getProperty: <T = any>(data: Record<string, any> | undefine
14
14
  */
15
15
  export declare const setGraphicToSpec: (spec: Record<string, any>, graphicElements: unknown[]) => void;
16
16
  export declare const translateAngleToRadian: (angle: number) => number;
17
- interface ISize {
18
- width: number;
19
- height: number;
20
- }
21
- export declare const calcPosition: (text: string, font: string) => ISize;
22
17
  /**
23
18
  * We define the chart type can use trend line. In excel it also can use for combined chart ro bar chart.
24
19
  * @param {ChartTypeBits} chartType The test chart type.
@@ -26,4 +21,3 @@ export declare const calcPosition: (text: string, font: string) => ISize;
26
21
  */
27
22
  export declare const chartTypeCanUseTrendLine: (chartType: ChartTypeBits) => boolean;
28
23
  export declare function isNegativeRedCached(fmt: string): boolean | undefined;
29
- export {};