From 3f1f38b16bbdc777ff03347c81af0b163517fa7a Mon Sep 17 00:00:00 2001 From: SoraYama Date: Wed, 31 Jan 2018 03:00:58 +0800 Subject: [PATCH] Update index.d.ts (#23021) * Update index.d.ts add containPixel in interface ECharts. * Update index.d.ts 1. fix quotation marks in Japanese 2. desperate interface `finder` 3. change const `graphic` to interface * add getMap add getMap method declaration * Update index.d.ts 1. changed all comments to JSDoc type; 2. fix `graphic` variable & add interface `Graphic`; 3. add TypeScript version instruction; 4. changed `mapObj` interface to CamelCase; * delete import for travis --- types/echarts/index.d.ts | 95 ++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/types/echarts/index.d.ts b/types/echarts/index.d.ts index 2880216e46..1f42f8030c 100644 --- a/types/echarts/index.d.ts +++ b/types/echarts/index.d.ts @@ -2,6 +2,7 @@ // Project: http://echarts.baidu.com/ // Definitions by: Xie Jingyang , AntiMoron // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 declare namespace echarts { function init(dom: HTMLDivElement | HTMLCanvasElement, theme?: Object | string, opts?: { @@ -9,13 +10,13 @@ declare namespace echarts { renderer?: string }): ECharts; - const graphic: { + const graphic: Graphic; + + interface Graphic { clipPointsByRect(points: number[][], rect: ERectangle): number[][]; clipRectByRect(targetRect: ERectangle, rect: ERectangle): ERectangle; - LinearGradient: { new (x: number, y: number, x2: number, y2: number, colorStops: Array, globalCoord?: boolean): LinearGradient } - - }; - + LinearGradient: { new(x: number, y: number, x2: number, y2: number, colorStops: Array, globalCoord?: boolean): LinearGradient } + } function connect(group: string | Array): void; @@ -29,6 +30,15 @@ declare namespace echarts { function registerTheme(themeName: string, theme: Object): void; + interface MapObj { + /** geoJson data for map */ + geoJson: object, + /** special areas fro map */ + specialAreas: object + } + + function getMap(mapName: string): MapObj; + interface LinearGradient { colorStops: Array; global: boolean; @@ -39,9 +49,8 @@ declare namespace echarts { y2: number } - interface ECharts { - group: string; + group: string setOption(option: EChartOption, notMerge?: boolean, notRefreshImmediately?: boolean): void @@ -66,20 +75,20 @@ declare namespace echarts { hideLoading(): void getDataURL(opts: { - // 导出的格式,可选 png, jpeg + /** 导出的格式,可选 png, jpeg */ type?: string, - // 导出的图片分辨率比例,默认为 1。 + /** 导出的图片分辨率比例,默认为 1。*/ pixelRatio?: number, - // 导出的图片背景色,默认使用 option 里的 backgroundColor + /** 导出的图片背景色,默认使用 option 里的 backgroundColor */ backgroundColor?: string }): string getConnectedDataURL(opts: { - // 导出的格式,可选 png, jpeg + /** 导出的格式,可选 png, jpeg */ type: string, - // 导出的图片分辨率比例,默认为 1。 + /** 导出的图片分辨率比例,默认为 1。 */ pixelRatio: number, - // 导出的图片背景色,默认使用 option 里的 backgroundColor + /** 导出的图片背景色,默认使用 option 里的 backgroundColor */ backgroundColor: string }): string @@ -89,42 +98,32 @@ declare namespace echarts { dispose(): void - // 转换逻辑点到像素 - convertToPixel(finder: { - seriesIndex?: number, - seriesId?: string, - seriesName?: string, - geoIndex?: number, - geoId?: string, - geoName?: string, - xAxisIndex?: number, - xAxisId?: string, - xAxisName?: string, - yAxisIndex?: number, - yAxisId?: string, - yAxisName?: string, - gridIndex?: number, - gridId?: string - gridName?: string - } | string, value: string | Array): string | Array + /** 转换逻辑点到像素 */ + convertToPixel(finder: ConvertFinder | string, value: string | Array): string | Array - convertFromPixel(finder: { - seriesIndex?: number, - seriesId?: string, - seriesName?: string, - geoIndex?: number, - geoId?: string, - geoName?: string, - xAxisIndex?: number, - xAxisId?: string, - xAxisName?: string, - yAxisIndex?: number, - yAxisId?: string, - yAxisName?: string, - gridIndex?: number, - gridId?: string - gridName?: string - } | string, value: Array | string): Array | string + convertFromPixel(finder: ConvertFinder | string, value: Array | string): Array | string + + containPixel(finder: ConvertFinder | string, + /** 要被判断的点,为像素坐标值,以 echarts 实例的 dom 节点的左上角为坐标 [0, 0] 点。*/ + value: any[]): boolean + } + + interface ConvertFinder { + seriesIndex?: number, + seriesId?: string, + seriesName?: string, + geoIndex?: number, + geoId?: string, + geoName?: string, + xAxisIndex?: number, + xAxisId?: string, + xAxisName?: string, + yAxisIndex?: number, + yAxisId?: string, + yAxisName?: string, + gridIndex?: number, + gridId?: string + gridName?: string } interface ERectangle {