From e142547579dde522752fc6444864fa43262b4cfa Mon Sep 17 00:00:00 2001 From: Ruixue Liao Date: Tue, 1 Oct 2019 09:47:47 -0700 Subject: [PATCH] Move rich definition to text-stlyle.d.ts (#38733) --- types/echarts/index.d.ts | 58 +++------------------------ types/echarts/options/calendar.d.ts | 2 +- types/echarts/options/data-zoom.d.ts | 2 +- types/echarts/options/legend.d.ts | 2 +- types/echarts/options/text-style.d.ts | 34 +++++++++++++++- types/echarts/options/tooltip.d.ts | 2 +- types/echarts/options/visual-map.d.ts | 2 +- 7 files changed, 43 insertions(+), 59 deletions(-) diff --git a/types/echarts/index.d.ts b/types/echarts/index.d.ts index d39f3729d6..897cf055b8 100644 --- a/types/echarts/index.d.ts +++ b/types/echarts/index.d.ts @@ -778,7 +778,7 @@ declare namespace echarts { * * @see https://ecomfe.github.io/echarts-doc/public/en/option.html#textStyle */ - textStyle?: EChartOption.TextStyle, + textStyle?: EChartOption.BaseTextStyle, /** * Whether to enable animation. @@ -968,11 +968,11 @@ declare namespace echarts { text?: string; link?: string, target?: string, - textStyle?: object, + textStyle?: EChartOption.TextStyleWithRich, subtext?: string, sublink?: string, subtarget?: string, - subtextStyle?: object, + subtextStyle?: EChartOption.TextStyleWithRich, textAlign?: string, textVerticalAlign?: string, triggerEvent?: boolean, @@ -1114,7 +1114,7 @@ declare namespace echarts { * * @see https://ecomfe.github.io/echarts-doc/public/en/option.html#yAxis.nameTextStyle */ - nameTextStyle?: CartesianAxis.TextStyle; + nameTextStyle?: TextStyleWithRich; /** * Gap between axis name and axis line. @@ -1390,52 +1390,6 @@ declare namespace echarts { namespace CartesianAxis { type Type = 'value' | 'category' | 'time' | 'log'; - /** - * @todo describe - */ - interface Style { - color?: string; - fontStyle?: 'normal' | 'italic' | 'oblique'; - fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' - | '100' | '200' | '300' | '400'; - fontFamily?: string; - fontSize?: number; - align?: string; - verticalAlign?: string; - lineHeight?: number; - backgroundColor?: string | object; - borderColor?: string; - borderWidth?: number; - borderRadius?: number; - padding?: number | number[]; - shadowColor?: string; - shadowBlur?: number; - shadowOffsetX?: number; - shadowOffsetY?: number; - width?: number | string; - height?: number | string; - textBorderColor?: string; - textBorderWidth?: number; - textShadowColor?: string; - textShadowBlur?: number; - textShadowOffsetX?: number; - textShadowOffsetY?: number; - } - - /** - * @todo describe - */ - interface RichStyle { - [userStyleName: string]: Style; - } - - interface TextStyle extends Style { - /** - * @see https://ecomfe.github.io/echarts-doc/public/en/option.html#yAxis.data.textStyle.rich - */ - rich?: RichStyle; - } - /** * @todo describe */ @@ -1451,7 +1405,7 @@ declare namespace echarts { /** * @todo describe */ - interface Label extends TextStyle { + interface Label extends TextStyleWithRich { show?: boolean; interval?: number | Function; inside?: boolean; @@ -1492,7 +1446,7 @@ declare namespace echarts { */ interface DataObject { value?: string | number; - textStyle?: TextStyle; + textStyle?: TextStyleWithRich; } /** diff --git a/types/echarts/options/calendar.d.ts b/types/echarts/options/calendar.d.ts index 69a970fa26..fbf7e059da 100644 --- a/types/echarts/options/calendar.d.ts +++ b/types/echarts/options/calendar.d.ts @@ -155,7 +155,7 @@ declare namespace echarts { silent?: boolean; } namespace Calendar { - interface Label extends BasicComponents.CartesianAxis.TextStyle { + interface Label extends TextStyleWithRich { /** * Set this to false to prevent label from showing. * diff --git a/types/echarts/options/data-zoom.d.ts b/types/echarts/options/data-zoom.d.ts index 474ff417c1..606961f064 100644 --- a/types/echarts/options/data-zoom.d.ts +++ b/types/echarts/options/data-zoom.d.ts @@ -77,7 +77,7 @@ declare namespace echarts { showDetail?: boolean; showDataShadow?: string; realtime?: boolean; - textStyle?: object; + textStyle?: BaseTextStyle; xAxisIndex?: number | number[]; yAxisIndex?: number | number[]; radiusAxisIndex?: number | number[]; diff --git a/types/echarts/options/legend.d.ts b/types/echarts/options/legend.d.ts index 9a3d6d1b25..d4a2c7baed 100644 --- a/types/echarts/options/legend.d.ts +++ b/types/echarts/options/legend.d.ts @@ -198,7 +198,7 @@ declare namespace echarts { /** * Legend text style. */ - textStyle?: TextStyle; + textStyle?: TextStyleWithRich; /** * Tooltip configuration for legend tooltip, which is similar to tooltip. * diff --git a/types/echarts/options/text-style.d.ts b/types/echarts/options/text-style.d.ts index 8786216b78..7f59522a58 100644 --- a/types/echarts/options/text-style.d.ts +++ b/types/echarts/options/text-style.d.ts @@ -1,9 +1,10 @@ declare namespace echarts { namespace EChartOption { + /** - * @todo describe + * @see https://echarts.apache.org/en/option.html#textStyle */ - interface TextStyle { + interface BaseTextStyle { color?: string; fontStyle?: 'normal' | 'italic' | 'oblique'; fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' @@ -20,5 +21,34 @@ declare namespace echarts { textShadowOffsetX?: number; textShadowOffsetY?: number; } + + interface TextStyle extends BaseTextStyle { + align?: string; + verticalAlign?: string; + backgroundColor?: string | object; + borderColor?: string; + borderWidth?: number; + borderRadius?: number; + padding?: number | number[]; + shadowColor?: string; + shadowBlur?: number; + shadowOffsetX?: number; + shadowOffsetY?: number; + } + + /** + * @see https://echarts.apache.org/en/tutorial.html#Rich%20Text + */ + interface RichStyle { + [userStyleName: string]: TextStyle; + } + + interface BaseTextStyleWithRich { + rich?: RichStyle; + } + + interface TextStyleWithRich extends TextStyle { + rich?: RichStyle; + } } } diff --git a/types/echarts/options/tooltip.d.ts b/types/echarts/options/tooltip.d.ts index 489b73b43a..568e773a75 100644 --- a/types/echarts/options/tooltip.d.ts +++ b/types/echarts/options/tooltip.d.ts @@ -300,7 +300,7 @@ declare namespace echarts { /** * The text style of tooltip's floating layer. */ - textStyle?: {}; + textStyle?: BaseTextStyle; /** * Extra CSS style for floating layer. diff --git a/types/echarts/options/visual-map.d.ts b/types/echarts/options/visual-map.d.ts index 28c67234b9..fb786a03e7 100644 --- a/types/echarts/options/visual-map.d.ts +++ b/types/echarts/options/visual-map.d.ts @@ -40,7 +40,7 @@ declare namespace echarts { borderColor?: string; borderWidth?: number; color?: string[]; - textStyle?: EChartOption.TextStyle; + textStyle?: EChartOption.BaseTextStyleWithRich; formatter?: string | Function; } interface Piecewise {