From eacf58fd2bd7083bc34583ec6976e356a4061fb2 Mon Sep 17 00:00:00 2001 From: hustcc Date: Tue, 25 Aug 2020 13:48:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=B0=E6=9F=A5=20&=20=E9=87=8D=E6=9E=84=20(?= =?UTF-8?q?#1489)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: remove unuse console.log * chore(export): export adaptor and params * refactor(scale): combile meta & axis into common adaptor scale --- src/adaptor/common.ts | 32 ++++++++++++++--- src/index.ts | 19 +++++----- src/plots/area/adaptor.ts | 7 ++-- src/plots/column/adaptor.ts | 27 ++++++-------- src/plots/dual-axes/adaptor.ts | 36 ++++++++----------- src/plots/heatmap/adaptor.ts | 29 +++++++-------- src/plots/histogram/adaptor.ts | 28 +++++++-------- src/plots/line/adaptor.ts | 31 +++++++--------- src/plots/pie/adaptor.ts | 17 +++++++-- .../pie/interaction/pie-legend-action.ts | 2 -- src/plots/progress/adaptor.ts | 16 ++------- src/plots/radar/adaptor.ts | 34 +++++++----------- src/plots/ring-progress/adaptor.ts | 16 ++------- src/plots/scatter/adaptor.ts | 28 +++++++-------- src/plots/tiny-area/adaptor.ts | 17 ++------- src/plots/tiny-column/adaptor.ts | 17 ++------- src/plots/tiny-line/adaptor.ts | 16 ++------- 17 files changed, 155 insertions(+), 217 deletions(-) diff --git a/src/adaptor/common.ts b/src/adaptor/common.ts index cea0220c63..8b04608aa8 100644 --- a/src/adaptor/common.ts +++ b/src/adaptor/common.ts @@ -1,11 +1,11 @@ -/** - * @file 通用的一些 adaptor - */ import { Geometry } from '@antv/g2'; -import { each } from '@antv/util'; +import { each, deepMix } from '@antv/util'; import { Params } from '../core/adaptor'; import { Options } from '../types'; import { Interaction } from '../types/interaction'; +import { Axis } from '../types/axis'; +import { AXIS_META_CONFIG_KEYS } from '../constant'; +import { pick } from '../utils'; /** * 通用 legend 配置, 适用于带 colorField 的图表 @@ -114,3 +114,27 @@ export function slider(params: Params): Params { return params; } + +/** + * scale 的 adaptor + * @param axes + */ +export function scale(axes: Record) { + return function >(params: Params): Params { + const { chart, options } = params; + const { meta } = options; + + // 1. 轴配置中的 scale 信息 + let scales: Record = {}; + each(axes, (axis: Axis, field: string) => { + scales[field] = pick(axis, AXIS_META_CONFIG_KEYS); + }); + + // 2. meta 直接是 scale 的信息 + scales = deepMix({}, meta, scales); + + chart.scale(scales); + + return params; + }; +} diff --git a/src/index.ts b/src/index.ts index f13e3e91d7..ae411cacbd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,14 @@ export const version = '2.0.0-beta.2'; // G2 自定义能力透出 -import * as G2 from '@antv/g2'; -export { G2 }; +export * as G2 from '@antv/g2'; +/** G2Plot 的 Plot 基类 */ export { Plot } from './core/plot'; +/** Adaptor 及其参数的类型定义 */ +export { Adaptor, Params } from './core/adaptor'; + // 类型定义导出 export * from './types'; @@ -18,12 +21,18 @@ export { Area, AreaOptions } from './plots/area'; // 柱形图及类型定义 export { Column, ColumnOptions } from './plots/column'; +// 条形图及类型定义 +export { Bar, BarOptions } from './plots/bar'; + // 饼图及类型定义 export { Pie, PieOptions } from './plots/pie'; // 散点图及类型定义 export { Scatter, ScatterOptions } from './plots/scatter'; +// 雷达图及类型定义 +export { Radar, RadarOptions } from './plots/radar'; + // 混合图形 export { DualAxes, DualAxesOption } from './plots/dual-axes'; @@ -45,11 +54,5 @@ export { Progress, ProgressOptions } from './plots/progress'; // 环形进度图及类型定义 export { RingProgress, RingProgressOptions } from './plots/ring-progress'; -// 条形图及类型定义 -export { Bar, BarOptions } from './plots/bar'; - -// 雷达图及类型定义 -export { Radar, RadarOptions } from './plots/radar'; - // 热力图及类型定义 export { Heatmap, HeatmapOptions } from './plots/heatmap'; diff --git a/src/plots/area/adaptor.ts b/src/plots/area/adaptor.ts index ccf66380ae..ef7cda27f0 100644 --- a/src/plots/area/adaptor.ts +++ b/src/plots/area/adaptor.ts @@ -17,10 +17,9 @@ function geometry(params: Params): Params { const { data, areaStyle, smooth } = options; chart.data(data); - // area geometry 处理 - flow(area)(deepMix({}, params, { options: { area: { smooth, style: areaStyle } } })); - return params; + // area geometry 处理 + return flow(area)(deepMix({}, params, { options: { area: { smooth, style: areaStyle } } })); } /** @@ -68,7 +67,7 @@ function adjust(params: Params): Params { */ export function adaptor(params: Params) { // flow 的方式处理所有的配置到 G2 API - flow( + return flow( geometry, meta, // line 面积线的配置处理 diff --git a/src/plots/column/adaptor.ts b/src/plots/column/adaptor.ts index df9a806b04..9ca38b2885 100644 --- a/src/plots/column/adaptor.ts +++ b/src/plots/column/adaptor.ts @@ -1,11 +1,10 @@ import { deepMix } from '@antv/util'; import { Params } from '../../core/adaptor'; import { findGeometry } from '../../utils'; -import { tooltip, slider, interaction, animation, theme } from '../../adaptor/common'; +import { tooltip, slider, interaction, animation, theme, scale } from '../../adaptor/common'; import { interval } from '../../adaptor/geometries'; -import { flow, pick } from '../../utils'; +import { flow } from '../../utils'; import { ColumnOptions } from './types'; -import { AXIS_META_CONFIG_KEYS } from '../../constant'; /** * 字段 @@ -17,7 +16,7 @@ function geometry(params: Params): Params { chart.data(data); - flow(interval)( + return flow(interval)( deepMix({}, params, { options: { interval: { @@ -28,8 +27,6 @@ function geometry(params: Params): Params { }, }) ); - - return params; } /** @@ -37,17 +34,15 @@ function geometry(params: Params): Params { * @param params */ function meta(params: Params): Params { - const { chart, options } = params; - const { meta, xAxis, yAxis, xField, yField } = options; - - const scales = deepMix({}, meta, { - [xField]: pick(xAxis, AXIS_META_CONFIG_KEYS), - [yField]: pick(yAxis, AXIS_META_CONFIG_KEYS), - }); - - chart.scale(scales); + const { options } = params; + const { xAxis, yAxis, xField, yField } = options; - return params; + return flow( + scale({ + [xField]: xAxis, + [yField]: yAxis, + }) + )(params); } /** diff --git a/src/plots/dual-axes/adaptor.ts b/src/plots/dual-axes/adaptor.ts index ac0ade6dde..e9cf5c3e80 100644 --- a/src/plots/dual-axes/adaptor.ts +++ b/src/plots/dual-axes/adaptor.ts @@ -1,11 +1,10 @@ import { deepMix } from '@antv/util'; -import { theme, tooltip, interaction, animation } from '../../adaptor/common'; +import { theme, tooltip, interaction, animation, scale } from '../../adaptor/common'; import { Params } from '../../core/adaptor'; -import { flow, pick } from '../../utils'; +import { flow } from '../../utils'; import { getOption } from './util/option'; import { drawSingleGeometry } from './util/geometry'; import { DualAxesOption } from './types'; -import { AXIS_META_CONFIG_KEYS } from '../../constant'; /** * 获取默认参数设置 @@ -71,23 +70,16 @@ function geometry(params: Params): Params { * @param params */ export function meta(params: Params): Params { - const { chart, options } = params; - const { meta = {}, xAxis, yAxis, xField, yField } = options; - - const xFieldScales = deepMix({}, meta[xField] || {}, pick(xAxis, AXIS_META_CONFIG_KEYS)); - const leftYFieldScales = deepMix({}, meta[yField[0]] || {}, pick(yAxis[0], AXIS_META_CONFIG_KEYS)); - const rightYFieldScales = deepMix({}, meta[yField[1]] || {}, pick(yAxis[1], AXIS_META_CONFIG_KEYS)); - - chart.views[0].scale({ - [xField]: xFieldScales, - [yField[0]]: leftYFieldScales, - }); - - chart.views[1].scale({ - [xField]: xFieldScales, - [yField[1]]: rightYFieldScales, - }); - return params; + const { options } = params; + const { xAxis, yAxis, xField, yField } = options; + + return flow( + scale({ + [xField]: xAxis, + [yField[0]]: yAxis[0], + [yField[1]]: yAxis[1], + }) + )(params); } /** @@ -150,7 +142,7 @@ export function legend(params: Params): Params { * @param chart * @param options */ -export function adaptor(params: Params) { +export function adaptor(params: Params): Params { // flow 的方式处理所有的配置到 G2 API - flow(transformOptions, geometry, meta, axis, legend, tooltip, theme, interaction, animation)(params); + return flow(transformOptions, geometry, meta, axis, legend, tooltip, theme, interaction, animation)(params); } diff --git a/src/plots/heatmap/adaptor.ts b/src/plots/heatmap/adaptor.ts index 7e79ec7d00..992d97aa55 100644 --- a/src/plots/heatmap/adaptor.ts +++ b/src/plots/heatmap/adaptor.ts @@ -1,9 +1,9 @@ -import { deepMix, isFunction, isObject } from '@antv/util'; +import { isFunction, isObject } from '@antv/util'; import { Params } from '../../core/adaptor'; import { findGeometry } from '../../utils'; -import { flow, pick } from '../../utils'; -import { AXIS_META_CONFIG_KEYS, DEFAULT_COLORS } from '../../constant'; -import { tooltip, interaction, animation, theme } from '../../adaptor/common'; +import { flow } from '../../utils'; +import { DEFAULT_COLORS } from '../../constant'; +import { tooltip, interaction, animation, theme, scale } from '../../adaptor/common'; import { HeatmapOptions, ShapeType, SHAPE_TYPES } from './types'; /** @@ -90,18 +90,15 @@ function field(params: Params): Params { * @param params */ function meta(params: Params): Params { - const { chart, options } = params; - const { meta, xAxis, yAxis, xField, yField } = options; - - // meta 直接是 scale 的信息 - const scales = deepMix({}, meta, { - [xField]: pick(xAxis, AXIS_META_CONFIG_KEYS), - [yField]: pick(yAxis, AXIS_META_CONFIG_KEYS), - }); - - chart.scale(scales); + const { options } = params; + const { xAxis, yAxis, xField, yField } = options; - return params; + return flow( + scale({ + [xField]: xAxis, + [yField]: yAxis, + }) + )(params); } /** @@ -227,5 +224,5 @@ function label(params: Params): Params { */ export function adaptor(params: Params) { // flow 的方式处理所有的配置到 G2 API - flow(field, meta, theme, axis, legend, tooltip, style, label, interaction, animation)(params); + return flow(field, meta, theme, axis, legend, tooltip, style, label, interaction, animation)(params); } diff --git a/src/plots/histogram/adaptor.ts b/src/plots/histogram/adaptor.ts index fb6294269b..3f5cb31cbc 100644 --- a/src/plots/histogram/adaptor.ts +++ b/src/plots/histogram/adaptor.ts @@ -1,10 +1,9 @@ import DataSet from '@antv/data-set'; -import { deepMix, isFunction } from '@antv/util'; +import { isFunction } from '@antv/util'; import { Params } from '../../core/adaptor'; -import { tooltip, interaction, animation, theme } from '../../adaptor/common'; +import { tooltip, interaction, animation, theme, scale } from '../../adaptor/common'; import { findGeometry } from '../../utils'; -import { flow, pick } from '../../utils'; -import { AXIS_META_CONFIG_KEYS } from '../../constant'; +import { flow } from '../../utils'; import { HistogramOptions } from './types'; /** @@ -48,18 +47,15 @@ function field(params: Params): Params { * @param params */ function meta(params: Params): Params { - const { chart, options } = params; - const { meta, xAxis, yAxis } = options; - - // 上面默认 x 轴 为 range 字段, y 轴字段为 count 字段 - const scales = deepMix({}, meta, { - range: pick(xAxis, AXIS_META_CONFIG_KEYS), - count: pick(yAxis, AXIS_META_CONFIG_KEYS), - }); - - chart.scale(scales); + const { options } = params; + const { xAxis, yAxis } = options; - return params; + return flow( + scale({ + range: xAxis, + count: yAxis, + }) + )(params); } /** @@ -151,5 +147,5 @@ function style(params: Params): Params { */ export function adaptor(params: Params) { // flow 的方式处理所有的配置到 G2 API - flow(field, meta, axis, legend, theme, label, style, tooltip, interaction, animation)(params); + return flow(field, meta, axis, legend, theme, label, style, tooltip, interaction, animation)(params); } diff --git a/src/plots/line/adaptor.ts b/src/plots/line/adaptor.ts index 749301ab70..90d37e2b78 100644 --- a/src/plots/line/adaptor.ts +++ b/src/plots/line/adaptor.ts @@ -1,10 +1,9 @@ import { deepMix } from '@antv/util'; import { Params } from '../../core/adaptor'; -import { tooltip, slider, interaction, animation, theme } from '../../adaptor/common'; +import { tooltip, slider, interaction, animation, theme, scale } from '../../adaptor/common'; import { findGeometry } from '../../utils'; -import { AXIS_META_CONFIG_KEYS } from '../../constant'; import { point, line } from '../../adaptor/geometries'; -import { flow, pick } from '../../utils'; +import { flow } from '../../utils'; import { LineOptions } from './types'; /** @@ -16,10 +15,9 @@ function geometry(params: Params): Params { const { data, color, lineStyle, connectNulls, smooth } = options; chart.data(data); - // line geometry 处理 - flow(line)(deepMix({}, params, { options: { line: { connectNulls, smooth, color, style: lineStyle } } })); - return params; + // line geometry 处理 + return flow(line)(deepMix({}, params, { options: { line: { connectNulls, smooth, color, style: lineStyle } } })); } /** @@ -27,18 +25,15 @@ function geometry(params: Params): Params { * @param params */ export function meta(params: Params): Params { - const { chart, options } = params; - const { meta, xAxis, yAxis, xField, yField } = options; - - // meta 直接是 scale 的信息 - const scales = deepMix({}, meta, { - [xField]: pick(xAxis, AXIS_META_CONFIG_KEYS), - [yField]: pick(yAxis, AXIS_META_CONFIG_KEYS), - }); - - chart.scale(scales); + const { options } = params; + const { xAxis, yAxis, xField, yField } = options; - return params; + return flow( + scale({ + [xField]: xAxis, + [yField]: yAxis, + }) + )(params); } /** @@ -112,5 +107,5 @@ function label(params: Params): Params { */ export function adaptor(params: Params) { // flow 的方式处理所有的配置到 G2 API - flow(geometry, meta, point, theme, axis, legend, tooltip, label, slider, interaction, animation)(params); + return flow(geometry, meta, point, theme, axis, legend, tooltip, label, slider, interaction, animation)(params); } diff --git a/src/plots/pie/adaptor.ts b/src/plots/pie/adaptor.ts index a9b3e2249d..cd23709f7d 100644 --- a/src/plots/pie/adaptor.ts +++ b/src/plots/pie/adaptor.ts @@ -167,7 +167,7 @@ function style(params: Params): Params { */ function annotation(params: Params): Params { const { chart, options } = params; - const { innerRadius, statistic, angleField, colorField } = options; + const { innerRadius, statistic, angleField } = options; const annotationController = chart.getController('annotation'); // todo remove ignore @@ -272,5 +272,18 @@ function annotation(params: Params): Params { */ export function adaptor(params: Params) { // flow 的方式处理所有的配置到 G2 API - flow(field, meta, theme, coord, legend, tooltip, label, state, style, annotation, interaction, animation)(params); + return flow( + field, + meta, + theme, + coord, + legend, + tooltip, + label, + state, + style, + annotation, + interaction, + animation + )(params); } diff --git a/src/plots/pie/interaction/pie-legend-action.ts b/src/plots/pie/interaction/pie-legend-action.ts index ba4bbfb5b1..e19b423cf1 100644 --- a/src/plots/pie/interaction/pie-legend-action.ts +++ b/src/plots/pie/interaction/pie-legend-action.ts @@ -59,8 +59,6 @@ export class PieLegendAction extends Action { } public active() { - console.log('active', this.context); - this.transfrom(); } diff --git a/src/plots/progress/adaptor.ts b/src/plots/progress/adaptor.ts index f9f051e469..4548303fbf 100644 --- a/src/plots/progress/adaptor.ts +++ b/src/plots/progress/adaptor.ts @@ -2,6 +2,7 @@ import { isFunction } from '@antv/util'; import { Params } from '../../core/adaptor'; import { flow } from '../../utils'; import { ProgressOptions } from './types'; +import { scale } from '../../adaptor/common'; /** * 字段 @@ -32,19 +33,6 @@ function field(params: Params): Params { return params; } -/** - * meta 配置 - * @param params - */ -function meta(params: Params): Params { - const { chart, options } = params; - const { meta } = options; - - chart.scale(meta); - - return params; -} - /** * axis 配置 * @param params @@ -118,5 +106,5 @@ function coordinate(params: Params): Params { * @param options */ export function adaptor(params: Params) { - flow(field, meta, axis, legend, tooltip, style, coordinate)(params); + return flow(field, scale({}), axis, legend, tooltip, style, coordinate)(params); } diff --git a/src/plots/radar/adaptor.ts b/src/plots/radar/adaptor.ts index da5aed72c8..9cfe716f7f 100644 --- a/src/plots/radar/adaptor.ts +++ b/src/plots/radar/adaptor.ts @@ -1,9 +1,8 @@ import { deepMix } from '@antv/util'; import { Params } from '../../core/adaptor'; -import { tooltip, interaction, animation, theme } from '../../adaptor/common'; +import { tooltip, interaction, animation, theme, scale } from '../../adaptor/common'; import { area, point, line } from '../../adaptor/geometries'; -import { AXIS_META_CONFIG_KEYS } from '../../constant'; -import { flow, pick } from '../../utils'; +import { flow } from '../../utils'; import { RadarOptions } from './types'; /** @@ -15,10 +14,9 @@ function geometry(params: Params): Params { const { data, lineStyle, smooth } = options; chart.data(data); - // line geometry 处理 - flow(line)(deepMix({}, params, { options: { line: { smooth, style: lineStyle } } })); - return params; + // line geometry 处理 + return flow(line)(deepMix({}, params, { options: { line: { smooth, style: lineStyle } } })); } /** @@ -26,21 +24,15 @@ function geometry(params: Params): Params { * @param params */ function meta(params: Params): Params { - const { chart, options } = params; - const { meta, xField, yField, xAxis, yAxis } = options; + const { options } = params; + const { xAxis, yAxis, xField, yField } = options; - // meta 直接是 scale 的信息 - const scales = deepMix( - { - [xField]: pick(xAxis, AXIS_META_CONFIG_KEYS), - [yField]: pick(yAxis, AXIS_META_CONFIG_KEYS), - }, - meta - ); - - chart.scale(scales); - - return params; + return flow( + scale({ + [xField]: xAxis, + [yField]: yAxis, + }) + )(params); } /** @@ -94,7 +86,7 @@ function label(params: Params): Params { */ export function adaptor(params: Params) { // flow 的方式处理所有的配置到 G2 API - flow( + return flow( geometry, meta, // 雷达图 point geometry 处理 diff --git a/src/plots/ring-progress/adaptor.ts b/src/plots/ring-progress/adaptor.ts index df7d53f385..7463f40dc8 100644 --- a/src/plots/ring-progress/adaptor.ts +++ b/src/plots/ring-progress/adaptor.ts @@ -2,6 +2,7 @@ import { isFunction } from '@antv/util'; import { Params } from '../../core/adaptor'; import { flow } from '../../utils'; import { RingProgressOptions } from './types'; +import { scale } from '../../adaptor/common'; /** * 字段 @@ -32,19 +33,6 @@ function field(params: Params): Params return params; } -/** - * meta 配置 - * @param params - */ -function meta(params: Params): Params { - const { chart, options } = params; - const { meta } = options; - - chart.scale(meta); - - return params; -} - /** * axis 配置 * @param params @@ -122,5 +110,5 @@ function coordinate(params: Params): Params) { - flow(field, meta, axis, legend, tooltip, style, coordinate)(params); + return flow(field, scale({}), axis, legend, tooltip, style, coordinate)(params); } diff --git a/src/plots/scatter/adaptor.ts b/src/plots/scatter/adaptor.ts index b548a8705e..cdb513afeb 100644 --- a/src/plots/scatter/adaptor.ts +++ b/src/plots/scatter/adaptor.ts @@ -1,10 +1,9 @@ -import { deepMix, isFunction, isNumber, isString } from '@antv/util'; +import { isFunction, isNumber, isString } from '@antv/util'; import { Params } from '../../core/adaptor'; -import { flow, pick } from '../../utils'; +import { flow } from '../../utils'; import { ScatterOptions } from './types'; -import { tooltip, interaction, animation, theme } from '../../adaptor/common'; +import { tooltip, interaction, animation, theme, scale } from '../../adaptor/common'; import { findGeometry } from '../../utils'; -import { AXIS_META_CONFIG_KEYS } from '../../constant'; /** * 字段 @@ -58,18 +57,15 @@ function field(params: Params): Params { * @param params */ function meta(params: Params): Params { - const { chart, options } = params; - const { meta, xAxis, yAxis, xField, yField } = options; - - // meta 直接是 scale 的信息 - const scales = deepMix({}, meta, { - [xField]: pick(xAxis, AXIS_META_CONFIG_KEYS), - [yField]: pick(yAxis, AXIS_META_CONFIG_KEYS), - }); - - chart.scale(scales); + const { options } = params; + const { xAxis, yAxis, xField, yField } = options; - return params; + return flow( + scale({ + [xField]: xAxis, + [yField]: yAxis, + }) + )(params); } /** @@ -154,5 +150,5 @@ function label(params: Params): Params { */ export function adaptor(params: Params) { // flow 的方式处理所有的配置到 G2 API - flow(field, meta, axis, legend, tooltip, style, label, interaction, animation, theme)(params); + return flow(field, meta, axis, legend, tooltip, style, label, interaction, animation, theme)(params); } diff --git a/src/plots/tiny-area/adaptor.ts b/src/plots/tiny-area/adaptor.ts index e9aa632da4..9286bac5a6 100644 --- a/src/plots/tiny-area/adaptor.ts +++ b/src/plots/tiny-area/adaptor.ts @@ -1,5 +1,5 @@ import { isFunction } from '@antv/util'; -import { theme } from '../../adaptor/common'; +import { theme, scale } from '../../adaptor/common'; import { Params } from '../../core/adaptor'; import { flow } from '../../utils'; import { TinyAreaOptions } from './types'; @@ -25,19 +25,6 @@ function field(params: Params): Params { return params; } -/** - * meta 配置 - * @param params - */ -function meta(params: Params): Params { - const { chart, options } = params; - const { meta } = options; - - chart.scale(meta); - - return params; -} - /** * axis 配置 * @param params @@ -148,5 +135,5 @@ function shape(params: Params): Params { * @param options */ export function adaptor(params: Params) { - flow(field, meta, axis, legend, tooltip, style, shape, theme)(params); + return flow(field, scale({}), axis, legend, tooltip, style, shape, theme)(params); } diff --git a/src/plots/tiny-column/adaptor.ts b/src/plots/tiny-column/adaptor.ts index 957dbd3974..4501a6ace8 100644 --- a/src/plots/tiny-column/adaptor.ts +++ b/src/plots/tiny-column/adaptor.ts @@ -1,5 +1,5 @@ import { isFunction } from '@antv/util'; -import { theme } from '../../adaptor/common'; +import { theme, scale } from '../../adaptor/common'; import { Params } from '../../core/adaptor'; import { flow } from '../../utils'; import { TinyColumnOptions } from './types'; @@ -24,19 +24,6 @@ function field(params: Params): Params { return params; } -/** - * meta 配置 - * @param params - */ -function meta(params: Params): Params { - const { chart, options } = params; - const { meta } = options; - - chart.scale(meta); - - return params; -} - /** * axis 配置 * @param params @@ -120,5 +107,5 @@ function style(params: Params): Params { * @param options */ export function adaptor(params: Params) { - flow(field, meta, axis, legend, tooltip, style, theme)(params); + return flow(field, scale({}), axis, legend, tooltip, style, theme)(params); } diff --git a/src/plots/tiny-line/adaptor.ts b/src/plots/tiny-line/adaptor.ts index a0b4e3a764..5bd8cb66aa 100644 --- a/src/plots/tiny-line/adaptor.ts +++ b/src/plots/tiny-line/adaptor.ts @@ -3,6 +3,7 @@ import { Params } from '../../core/adaptor'; import { flow } from '../../utils'; import { TinyLineOptions } from './types'; import { DEFAULT_TOOLTIP_OPTIONS } from './constants'; +import { scale } from '../../adaptor/common'; /** * 字段 @@ -23,19 +24,6 @@ function field(params: Params): Params { return params; } -/** - * meta 配置 - * @param params - */ -function meta(params: Params): Params { - const { chart, options } = params; - const { meta } = options; - - chart.scale(meta); - - return params; -} - /** * axis 配置 * @param params @@ -148,5 +136,5 @@ export function theme(params: Params): Params * @param options */ export function adaptor(params: Params) { - flow(field, meta, theme, axis, legend, tooltip, style, shape)(params); + return flow(field, scale({}), theme, axis, legend, tooltip, style, shape)(params); }