You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/09/09 05:01:24 UTC

[echarts] branch improve-types updated: fix(type): expose more type from custom series

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch improve-types
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/improve-types by this push:
     new 3f52052  fix(type): expose more type from custom series
3f52052 is described below

commit 3f520525e4c7189fc6db670ae273fe2f4facbc40
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Sep 9 13:00:28 2021 +0800

    fix(type): expose more type from custom series
---
 src/chart/custom/CustomSeries.ts | 45 ++++++++++++++++++++++++----------------
 src/chart/custom/CustomView.ts   |  5 +++--
 src/export/option.ts             | 13 ++++++++++--
 3 files changed, 41 insertions(+), 22 deletions(-)

diff --git a/src/chart/custom/CustomSeries.ts b/src/chart/custom/CustomSeries.ts
index c34cbdf..7167274 100644
--- a/src/chart/custom/CustomSeries.ts
+++ b/src/chart/custom/CustomSeries.ts
@@ -158,9 +158,6 @@ export interface CustomBaseElementOption extends Partial<Pick<
     extra?: Dictionary<unknown> & TransitionAnyOption;
     // updateDuringAnimation
     during?(params: CustomBaseDuringAPI): void;
-
-    focus?: 'none' | 'self' | 'series' | ArrayLike<number>
-    blurScope?: BlurScope
 };
 
 export interface CustomDisplayableOption extends CustomBaseElementOption, Partial<Pick<
@@ -192,7 +189,7 @@ export interface CustomGroupOption extends CustomBaseElementOption {
     height?: number;
     // @deprecated
     diffChildrenByName?: boolean;
-    children: CustomChildElementOption[];
+    children: CustomElementOption[];
     $mergeChildren?: false | 'byName' | 'byIndex';
 }
 export interface CustomBaseZRPathOption<T extends PathProps['shape'] = PathProps['shape']>
@@ -204,17 +201,17 @@ export interface CustomBaseZRPathOption<T extends PathProps['shape'] = PathProps
 }
 
 interface BuiltinShapes {
-    'circle': Circle['shape']
-    'rect': Rect['shape']
-    'sector': Sector['shape']
-    'poygon': Polygon['shape']
-    'polyline': Polyline['shape']
-    'line': Line['shape']
-    'arc': Arc['shape']
-    'bezierCurve': BezierCurve['shape']
-    'ring': Ring['shape']
-    'ellipse': Ellipse['shape'],
-    'compoundPath': CompoundPath['shape']
+    circle: Partial<Circle['shape']>
+    rect: Partial<Rect['shape']>
+    sector: Partial<Sector['shape']>
+    poygon: Partial<Polygon['shape']>
+    polyline: Partial<Polyline['shape']>
+    line: Partial<Line['shape']>
+    arc: Partial<Arc['shape']>
+    bezierCurve: Partial<BezierCurve['shape']>
+    ring: Partial<Ring['shape']>
+    ellipse: Partial<Ellipse['shape']>
+    compoundPath: Partial<CompoundPath['shape']>
 }
 
 interface CustomSVGPathShapeOption {
@@ -270,7 +267,10 @@ export type CustomElementOption = CustomPathOption
     | CustomGroupOption;
 
 // Can only set focus, blur on the root element.
-export type CustomChildElementOption = Omit<CustomElementOption, 'focus' | 'blurScope'>;
+export type CustomRootElementOption = CustomElementOption & {
+    focus?: 'none' | 'self' | 'series' | ArrayLike<number>
+    blurScope?: BlurScope
+};
 
 export type CustomElementOptionOnState = CustomDisplayableOptionOnState
     | CustomImageOptionOnState;
@@ -287,7 +287,13 @@ export interface CustomSeriesRenderItemAPI extends
 
     value(dim: DimensionLoose, dataIndexInside?: number): ParsedValue;
     ordinalRawValue(dim: DimensionLoose, dataIndexInside?: number): ParsedValue | OrdinalRawValue;
+    /**
+     * @deprecated
+     */
     style(userProps?: ZRStyleProps, dataIndexInside?: number): ZRStyleProps;
+    /**
+     * @deprecated
+     */
     styleEmphasis(userProps?: ZRStyleProps, dataIndexInside?: number): ZRStyleProps;
     visual<VT extends NonStyleVisualProps | StyleVisualProps>(
         visualType: VT,
@@ -310,7 +316,7 @@ export interface CustomSeriesRenderItemCoordinateSystemAPI {
     ): number[];
     size?(
         dataSize: OptionDataValue | OptionDataValue[],
-        dataItem: OptionDataValue | OptionDataValue[]
+        dataItem?: OptionDataValue | OptionDataValue[]
     ): number | number[];
 }
 
@@ -330,6 +336,9 @@ export interface CustomSeriesRenderItemParams {
 
     actionType?: string;
 }
+
+export type CustomSeriesRenderItemReturn = CustomRootElementOption;
+
 type CustomSeriesRenderItem = (
     params: CustomSeriesRenderItemParams,
     api: CustomSeriesRenderItemAPI
@@ -354,7 +363,7 @@ export interface CustomSeriesOption extends
     /**
      * @deprecated
      */
-     itemStyle?: ItemStyleOption;
+    itemStyle?: ItemStyleOption;
     /**
      * @deprecated
      */
diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts
index ae042b7..f084d84 100644
--- a/src/chart/custom/CustomView.ts
+++ b/src/chart/custom/CustomView.ts
@@ -91,7 +91,8 @@ import CustomSeriesModel, {
     customInnerStore,
     LooseElementProps,
     PrepareCustomInfo,
-    CustomPathOption
+    CustomPathOption,
+    CustomRootElementOption
 } from './CustomSeries';
 import {
     prepareShapeOrExtraAllPropsFinal,
@@ -1148,7 +1149,7 @@ function createOrUpdateItem(
     api: ExtensionAPI,
     existsEl: Element,
     dataIndex: number,
-    elOption: CustomElementOption,
+    elOption: CustomRootElementOption,
     seriesModel: CustomSeriesModel,
     group: ViewRootGroup,
     data: SeriesData<CustomSeriesModel>
diff --git a/src/export/option.ts b/src/export/option.ts
index 7ed1b4b..c3256c3 100644
--- a/src/export/option.ts
+++ b/src/export/option.ts
@@ -86,7 +86,12 @@ import type {HeatmapSeriesOption as HeatmapSeriesOptionInner} from '../chart/hea
 import type {PictorialBarSeriesOption as PictorialBarSeriesOptionInner} from '../chart/bar/PictorialBarSeries';
 import type {ThemeRiverSeriesOption as ThemeRiverSeriesOptionInner} from '../chart/themeRiver/ThemeRiverSeries';
 import type {SunburstSeriesOption as SunburstSeriesOptionInner} from '../chart/sunburst/SunburstSeries';
-import type {CustomSeriesOption as CustomSeriesOptionInner} from '../chart/custom/CustomSeries';
+import type {
+    CustomSeriesOption as CustomSeriesOptionInner,
+    CustomSeriesRenderItemAPI,
+    CustomSeriesRenderItemParams,
+    CustomSeriesRenderItemReturn
+} from '../chart/custom/CustomSeries';
 
 import type { GraphicComponentLooseOption as GraphicComponentOption } from '../component/graphic/install';
 import type { DatasetOption as DatasetComponentOption } from '../component/dataset/install';
@@ -264,5 +269,9 @@ export {
     TooltipFormatterCallback as TooltipComponentFormatterCallback,
     TopLevelFormatterParams as TooltipComponentFormatterCallbackParams,
     TooltipPositionCallback as TooltipComponentPositionCallback,
-    TooltipPositionCallbackParams as TooltipComponentPositionCallbackParams
+    TooltipPositionCallbackParams as TooltipComponentPositionCallbackParams,
+
+    CustomSeriesRenderItemParams,
+    CustomSeriesRenderItemAPI,
+    CustomSeriesRenderItemReturn
 };

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org