@antv/g2plot 2.4.13 → 2.4.14

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.
@@ -6,6 +6,7 @@ import { Geometry } from '../../adaptor/geometries/base';
6
6
  import { Animation } from '../../types/animation';
7
7
  import { Annotation } from '../../types/annotation';
8
8
  import { Interaction } from '../../types/interaction';
9
+ import { Slider } from '../../types/slider';
9
10
  import { IPlotTypes } from './utils';
10
11
  /**
11
12
  * @title geometry 映射信息
@@ -65,16 +66,31 @@ export declare type IView = {
65
66
  * @title 子 plot 的配置
66
67
  */
67
68
  export declare type IPlot = IPlotTypes & {
69
+ /**
70
+ * @title 数据
71
+ * @description 设置画布具体的数据. 默认基础顶层 data
72
+ */
73
+ readonly data?: Record<string, any>[];
68
74
  /**
69
75
  * @title plot view 的布局范围
70
76
  * @default "占满全部"
71
77
  */
72
78
  readonly region?: Region;
79
+ /**
80
+ * @title 是否为顶层
81
+ * @description 设置为 true 时,几何图形挂在顶层 chart 对象上,而不是子 view 下。此时 region 设置无效,data 继承顶层 data 配置。
82
+ * @default false
83
+ */
84
+ readonly top?: boolean;
73
85
  };
74
86
  /**
75
87
  * @title 类型定义
76
88
  */
77
89
  export interface MixOptions extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'legend' | 'tooltip' | 'slider' | 'scrollbar'> {
90
+ /**
91
+ * @title 顶层数据配置
92
+ */
93
+ readonly data?: Options['data'];
78
94
  /**
79
95
  * @title 是否同步子 view 的配置
80
96
  * @description 目前仅仅支持 true / false,后续需要增加 function 的方式进行自定义 view 之前的布局同步
@@ -92,12 +108,18 @@ export interface MixOptions extends Omit<Options, 'data' | 'legend' | 'xAxis' |
92
108
  readonly plots?: IPlot[];
93
109
  /**
94
110
  * @title tooltip 配置
95
- * @description tooltip 配置在 chart 层配置
111
+ * @description Mix tooltip 组件配置,统一顶层配置
112
+ * TODO 字段映射
96
113
  */
97
114
  readonly tooltip?: Tooltip;
98
115
  /**
99
116
  * @title legend 配置
100
- * @description 统一顶层配置
117
+ * @description Mix 图例配置,统一顶层配置
101
118
  */
102
119
  readonly legend?: false | Record<string, Legend>;
120
+ /**
121
+ * @title slider 配置
122
+ * @description Mix 缩略轴配置,统一顶层配置
123
+ */
124
+ readonly slider?: Slider;
103
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/mix/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Data, Meta, Options, Region, Tooltip } from '../../types';\nimport { Axis } from '../../types/axis';\nimport { Legend } from '../../types/legend';\nimport { Geometry } from '../../adaptor/geometries/base';\nimport { Animation } from '../../types/animation';\nimport { Annotation } from '../../types/annotation';\nimport { Interaction } from '../../types/interaction';\nimport { IPlotTypes } from './utils';\n\n/**\n * @title geometry 映射信息\n */\nexport type IGeometry = Geometry & {\n adjust?: Types.AdjustOption;\n};\n/**\n * @title 子 view 的配置\n * @description 暂时不开嵌套 view 的情况\n */\nexport type IView = {\n /**\n * @title view 的布局范围\n * @default \"占满全部\"\n */\n readonly region?: Region;\n /**\n * @title view 中的数据\n */\n readonly data: Data;\n /**\n * @title view 中对应的 meta 字段配置\n */\n readonly meta?: Record<string, Meta>;\n /**\n * @title 坐标系的配置\n * @description 每一个 view 具有相同的坐标系\n */\n readonly coordinate?: Types.CoordinateOption;\n /**\n * @title 图形 geometry 及映射配置\n */\n readonly geometries: IGeometry[];\n /**\n * @title x,y 轴\n */\n readonly axes?: false | Record<string, Axis>;\n /**\n * @title interactions\n */\n readonly interactions?: Interaction[];\n /**\n * @title annotation\n */\n readonly annotations?: Annotation[];\n /**\n * @title annotation\n */\n readonly animation?: Animation;\n /**\n * @title tooltip\n */\n readonly tooltip?: Tooltip;\n};\n\n/**\n * @title 子 plot 的配置\n */\nexport type IPlot = IPlotTypes & {\n /**\n * @title plot view 的布局范围\n * @default \"占满全部\"\n */\n readonly region?: Region;\n};\n\n/**\n * @title 类型定义\n */\nexport interface MixOptions\n extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'legend' | 'tooltip' | 'slider' | 'scrollbar'> {\n /**\n * @title 是否同步子 view 的配置\n * @description 目前仅仅支持 true / false,后续需要增加 function 的方式进行自定义 view 之前的布局同步\n */\n readonly syncViewPadding?: boolean;\n /**\n * @title 每一个图层的配置\n * @description 每个图层包括有自己的:数据、图形、图形映射\n */\n readonly views?: IView[];\n /**\n * @title 限定与指定 plot 类型\n * @description 支持使用已有的 plot,限定与指定 plot 类型\n */\n readonly plots?: IPlot[];\n /**\n * @title tooltip 配置\n * @description tooltip 配置在 chart 层配置\n */\n readonly tooltip?: Tooltip;\n /**\n * @title legend 配置\n * @description 统一顶层配置\n */\n readonly legend?: false | Record<string, Legend>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/mix/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Data, Meta, Options, Region, Tooltip } from '../../types';\nimport { Axis } from '../../types/axis';\nimport { Legend } from '../../types/legend';\nimport { Geometry } from '../../adaptor/geometries/base';\nimport { Animation } from '../../types/animation';\nimport { Annotation } from '../../types/annotation';\nimport { Interaction } from '../../types/interaction';\nimport { Slider } from '../../types/slider';\nimport { IPlotTypes } from './utils';\n\n/**\n * @title geometry 映射信息\n */\nexport type IGeometry = Geometry & {\n adjust?: Types.AdjustOption;\n};\n/**\n * @title 子 view 的配置\n * @description 暂时不开嵌套 view 的情况\n */\nexport type IView = {\n /**\n * @title view 的布局范围\n * @default \"占满全部\"\n */\n readonly region?: Region;\n /**\n * @title view 中的数据\n */\n readonly data: Data;\n /**\n * @title view 中对应的 meta 字段配置\n */\n readonly meta?: Record<string, Meta>;\n /**\n * @title 坐标系的配置\n * @description 每一个 view 具有相同的坐标系\n */\n readonly coordinate?: Types.CoordinateOption;\n /**\n * @title 图形 geometry 及映射配置\n */\n readonly geometries: IGeometry[];\n /**\n * @title x,y 轴\n */\n readonly axes?: false | Record<string, Axis>;\n /**\n * @title interactions\n */\n readonly interactions?: Interaction[];\n /**\n * @title annotation\n */\n readonly annotations?: Annotation[];\n /**\n * @title annotation\n */\n readonly animation?: Animation;\n /**\n * @title tooltip\n */\n readonly tooltip?: Tooltip;\n};\n\n/**\n * @title 子 plot 的配置\n */\nexport type IPlot = IPlotTypes & {\n /**\n * @title 数据\n * @description 设置画布具体的数据. 默认基础顶层 data\n */\n readonly data?: Record<string, any>[];\n /**\n * @title plot view 的布局范围\n * @default \"占满全部\"\n */\n readonly region?: Region;\n /**\n * @title 是否为顶层\n * @description 设置为 true 时,几何图形挂在顶层 chart 对象上,而不是子 view 下。此时 region 设置无效,data 继承顶层 data 配置。\n * @default false\n */\n readonly top?: boolean;\n};\n\n/**\n * @title 类型定义\n */\nexport interface MixOptions\n extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'legend' | 'tooltip' | 'slider' | 'scrollbar'> {\n /**\n * @title 顶层数据配置\n */\n readonly data?: Options['data'];\n /**\n * @title 是否同步子 view 的配置\n * @description 目前仅仅支持 true / false,后续需要增加 function 的方式进行自定义 view 之前的布局同步\n */\n readonly syncViewPadding?: boolean;\n /**\n * @title 每一个图层的配置\n * @description 每个图层包括有自己的:数据、图形、图形映射\n */\n readonly views?: IView[];\n /**\n * @title 限定与指定 plot 类型\n * @description 支持使用已有的 plot,限定与指定 plot 类型\n */\n readonly plots?: IPlot[];\n /**\n * @title tooltip 配置\n * @description Mix tooltip 组件配置,统一顶层配置\n * TODO 字段映射\n */\n readonly tooltip?: Tooltip;\n /**\n * @title legend 配置\n * @description Mix 图例配置,统一顶层配置\n */\n readonly legend?: false | Record<string, Legend>;\n /**\n * @title slider 配置\n * @description Mix 缩略轴配置,统一顶层配置\n */\n readonly slider?: Slider;\n}\n"]}
@@ -15,9 +15,9 @@ import { HistogramOptions } from '../histogram';
15
15
  import { FunnelOptions } from '../funnel';
16
16
  import { StockOptions } from '../stock';
17
17
  /**
18
- * 移除 options 中的 width、height 设置
18
+ * 移除 options 中的 width、height、data 设置
19
19
  */
20
- declare type OmitSize<T> = Omit<T, 'width' | 'height'>;
20
+ declare type OmitPlotOptions<T> = Omit<T, 'width' | 'height' | 'data'>;
21
21
  /**
22
22
  * multi-view 中的支持的 plots 类型(带 options 定义)
23
23
  */
@@ -29,49 +29,49 @@ export declare type IPlotTypes = {
29
29
  /**
30
30
  * plot 配置
31
31
  */
32
- readonly options: OmitSize<LineOptions>;
32
+ readonly options: OmitPlotOptions<LineOptions>;
33
33
  } | {
34
34
  readonly type: 'pie';
35
- readonly options: OmitSize<PieOptions>;
35
+ readonly options: OmitPlotOptions<PieOptions>;
36
36
  } | {
37
37
  readonly type: 'bar';
38
- readonly options: OmitSize<BarOptions>;
38
+ readonly options: OmitPlotOptions<BarOptions>;
39
39
  } | {
40
40
  readonly type: 'column';
41
- readonly options: OmitSize<ColumnOptions>;
41
+ readonly options: OmitPlotOptions<ColumnOptions>;
42
42
  } | {
43
43
  readonly type: 'area';
44
- readonly options: OmitSize<AreaOptions>;
44
+ readonly options: OmitPlotOptions<AreaOptions>;
45
45
  } | {
46
46
  readonly type: 'gauge';
47
- readonly options: OmitSize<GaugeOptions>;
47
+ readonly options: OmitPlotOptions<GaugeOptions>;
48
48
  } | {
49
49
  readonly type: 'tiny-line';
50
- readonly options: OmitSize<TinyLineOptions>;
50
+ readonly options: OmitPlotOptions<TinyLineOptions>;
51
51
  } | {
52
52
  readonly type: 'tiny-area';
53
- readonly options: OmitSize<TinyAreaOptions>;
53
+ readonly options: OmitPlotOptions<TinyAreaOptions>;
54
54
  } | {
55
55
  readonly type: 'tiny-column';
56
- readonly options: OmitSize<TinyColumnOptions>;
56
+ readonly options: OmitPlotOptions<TinyColumnOptions>;
57
57
  } | {
58
58
  readonly type: 'ring-progress';
59
- readonly options: OmitSize<RingProgressOptions>;
59
+ readonly options: OmitPlotOptions<RingProgressOptions>;
60
60
  } | {
61
61
  readonly type: 'progress';
62
- readonly options: OmitSize<ProgressOptions>;
62
+ readonly options: OmitPlotOptions<ProgressOptions>;
63
63
  } | {
64
64
  readonly type: 'histogram';
65
- readonly options: OmitSize<HistogramOptions>;
65
+ readonly options: OmitPlotOptions<HistogramOptions>;
66
66
  } | {
67
67
  readonly type: 'scatter';
68
- readonly options: OmitSize<ScatterOptions>;
68
+ readonly options: OmitPlotOptions<ScatterOptions>;
69
69
  } | {
70
70
  readonly type: 'funnel';
71
- readonly options: OmitSize<FunnelOptions>;
71
+ readonly options: OmitPlotOptions<FunnelOptions>;
72
72
  } | {
73
73
  readonly type: 'stock';
74
- readonly options: OmitSize<StockOptions>;
74
+ readonly options: OmitPlotOptions<StockOptions>;
75
75
  };
76
76
  /**
77
77
  * 执行 plot 的 adaptor, 默认都带上 defaultOptions
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/plots/mix/utils.ts"],"names":[],"mappings":";;;AACA,mCAAiC;AACjC,qCAAyC;AACzC,2CAAyD;AACzD,0CAAuD;AACvD,6CAA6D;AAC7D,0CAAuD;AACvD,2CAAyD;AACzD,4CAA2D;AAC3D,gDAAkE;AAClE,kDAAsE;AACtE,gDAAkE;AAClE,qDAA0E;AAC1E,gDAAiE;AACjE,+CAA+D;AAC/D,iDAAmE;AACnE,8CAA6D;AAC7D,6CAA2D;AAC3D,gCAA4C;AAC5C,8BAAyC;AACzC,8BAAyC;AACzC,oCAAkD;AAClD,gCAA4C;AAC5C,kCAA+C;AAC/C,0CAAyD;AACzD,0CAAyD;AACzD,8CAA+D;AAC/D,kDAAqE;AACrE,wCAAwD;AACxD,sCAAqD;AACrD,0CAA2D;AAC3D,oCAAkD;AAClD,kCAA+C;AA8E/C;;GAEG;AACH,IAAM,aAAa,GAAG;IACpB,IAAI,EAAE,iBAAW;IACjB,GAAG,EAAE,iBAAU;IACf,MAAM,EAAE,iBAAa;IACrB,GAAG,EAAE,iBAAU;IACf,IAAI,EAAE,iBAAW;IACjB,KAAK,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QACL,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,kBAAU,CAAC,EAAE,EAAE,GAAG,CAAC,iBAAiB,EAAE,EAAE,UAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC;KAC9F,CAAC,CAAC;AACL,CAAC;AAfD,0CAeC","sourcesContent":["import { View } from '@antv/g2';\nimport { get } from '@antv/util';\nimport { deepAssign } from '../../utils';\nimport { adaptor as lineAdaptor } from '../line/adaptor';\nimport { adaptor as pieAdaptor } from '../pie/adaptor';\nimport { adaptor as columnAdaptor } from '../column/adaptor';\nimport { adaptor as barAdaptor } from '../bar/adaptor';\nimport { adaptor as areaAdaptor } from '../area/adaptor';\nimport { adaptor as gaugeAdaptor } from '../gauge/adaptor';\nimport { adaptor as tinyLineAdaptor } from '../tiny-line/adaptor';\nimport { adaptor as tinyColumnAdaptor } from '../tiny-column/adaptor';\nimport { adaptor as tinyAreaAdaptor } from '../tiny-area/adaptor';\nimport { adaptor as ringProgressAdaptor } from '../ring-progress/adaptor';\nimport { adaptor as progressAdaptor } from '../progress/adaptor';\nimport { adaptor as scatterAdaptor } from '../scatter/adaptor';\nimport { adaptor as histogramAdaptor } from '../histogram/adaptor';\nimport { adaptor as funnelAdaptor } from '../funnel/adaptor';\nimport { adaptor as stockAdaptor } from '../stock/adaptor';\nimport { Line, LineOptions } from '../line';\nimport { Pie, PieOptions } from '../pie';\nimport { Bar, BarOptions } from '../bar';\nimport { Column, ColumnOptions } from '../column';\nimport { Area, AreaOptions } from '../area';\nimport { Gauge, GaugeOptions } from '../gauge';\nimport { TinyLine, TinyLineOptions } from '../tiny-line';\nimport { TinyArea, TinyAreaOptions } from '../tiny-area';\nimport { TinyColumn, TinyColumnOptions } from '../tiny-column';\nimport { RingProgress, RingProgressOptions } from '../ring-progress';\nimport { Progress, ProgressOptions } from '../progress';\nimport { Scatter, ScatterOptions } from '../scatter';\nimport { Histogram, HistogramOptions } from '../histogram';\nimport { Funnel, FunnelOptions } from '../funnel';\nimport { Stock, StockOptions } from '../stock';\n\n/**\n * 移除 options 中的 width、height 设置\n */\ntype OmitSize<T> = Omit<T, 'width' | 'height'>;\n\n/**\n * multi-view 中的支持的 plots 类型(带 options 定义)\n */\nexport type IPlotTypes =\n | {\n /**\n * plot 类型\n */\n readonly type: 'line';\n /**\n * plot 配置\n */\n readonly options: OmitSize<LineOptions>;\n }\n | {\n readonly type: 'pie';\n readonly options: OmitSize<PieOptions>;\n }\n | {\n readonly type: 'bar';\n readonly options: OmitSize<BarOptions>;\n }\n | {\n readonly type: 'column';\n readonly options: OmitSize<ColumnOptions>;\n }\n | {\n readonly type: 'area';\n readonly options: OmitSize<AreaOptions>;\n }\n | {\n readonly type: 'gauge';\n readonly options: OmitSize<GaugeOptions>;\n }\n | {\n readonly type: 'tiny-line';\n readonly options: OmitSize<TinyLineOptions>;\n }\n | {\n readonly type: 'tiny-area';\n readonly options: OmitSize<TinyAreaOptions>;\n }\n | {\n readonly type: 'tiny-column';\n readonly options: OmitSize<TinyColumnOptions>;\n }\n | {\n readonly type: 'ring-progress';\n readonly options: OmitSize<RingProgressOptions>;\n }\n | {\n readonly type: 'progress';\n readonly options: OmitSize<ProgressOptions>;\n }\n | {\n readonly type: 'histogram';\n readonly options: OmitSize<HistogramOptions>;\n }\n | {\n readonly type: 'scatter';\n readonly options: OmitSize<ScatterOptions>;\n }\n | {\n readonly type: 'funnel';\n readonly options: OmitSize<FunnelOptions>;\n }\n | {\n readonly type: 'stock';\n readonly options: OmitSize<StockOptions>;\n };\n\n/**\n * 可在 multi-view 中使用的 plots\n */\nconst PLOT_ADAPTORS = {\n line: lineAdaptor,\n pie: pieAdaptor,\n column: columnAdaptor,\n bar: barAdaptor,\n area: areaAdaptor,\n gauge: gaugeAdaptor,\n 'tiny-line': tinyLineAdaptor,\n 'tiny-column': tinyColumnAdaptor,\n 'tiny-area': tinyAreaAdaptor,\n 'ring-progress': ringProgressAdaptor,\n progress: progressAdaptor,\n scatter: scatterAdaptor,\n histogram: histogramAdaptor,\n funnel: funnelAdaptor,\n stock: stockAdaptor,\n};\n\n/**\n * 获取指定 plot 的 class contructor\n * @param {string} plot\n */\nconst PLOT_CONSTRUCTOR = {\n line: Line,\n pie: Pie,\n column: Column,\n bar: Bar,\n area: Area,\n gauge: Gauge,\n 'tiny-line': TinyLine,\n 'tiny-column': TinyColumn,\n 'tiny-area': TinyArea,\n 'ring-progress': RingProgress,\n progress: Progress,\n scatter: Scatter,\n histogram: Histogram,\n funnel: Funnel,\n stock: Stock,\n};\n\n/**\n * 在 mix 图表以及 facet 图表中,defaultOptions 进行复写简化\n */\nconst DEFAULT_OPTIONS_MAP = {\n pie: { label: false },\n column: { tooltip: { showMarkers: false } },\n bar: { tooltip: { showMarkers: false } },\n};\n\n/**\n * 执行 plot 的 adaptor, 默认都带上 defaultOptions\n * @param {string} plot\n */\nexport function execPlotAdaptor<T extends IPlotTypes['type']>(\n plot: T,\n view: View,\n options: IPlotTypes['options']\n): void {\n const cls = PLOT_CONSTRUCTOR[plot];\n if (!cls) {\n console.error(`could not find ${plot} plot`);\n return;\n }\n const module = PLOT_ADAPTORS[plot];\n module({\n chart: view,\n options: deepAssign({}, cls.getDefaultOptions(), get(DEFAULT_OPTIONS_MAP, plot, {}), options),\n });\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/plots/mix/utils.ts"],"names":[],"mappings":";;;AACA,mCAAiC;AACjC,qCAAyC;AACzC,2CAAyD;AACzD,0CAAuD;AACvD,6CAA6D;AAC7D,0CAAuD;AACvD,2CAAyD;AACzD,4CAA2D;AAC3D,gDAAkE;AAClE,kDAAsE;AACtE,gDAAkE;AAClE,qDAA0E;AAC1E,gDAAiE;AACjE,+CAA+D;AAC/D,iDAAmE;AACnE,8CAA6D;AAC7D,6CAA2D;AAC3D,gCAA4C;AAC5C,8BAAyC;AACzC,8BAAyC;AACzC,oCAAkD;AAClD,gCAA4C;AAC5C,kCAA+C;AAC/C,0C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GAGG;AACH,SAAgB,eAAe,CAC7B,IAAO,EACP,IAAU,EACV,OAA8B;IAE9B,IAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,oBAAkB,IAAI,UAAO,CAAC,CAAC;QAC7C,OAAO;KACR;IACD,IAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC;QACL,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,kBAAU,CAAC,EAAE,EAAE,GAAG,CAAC,iBAAiB,EAAE,EAAE,UAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC;KAC9F,CAAC,CAAC;AACL,CAAC;AAfD,0CAeC","sourcesContent":["import { View } from '@antv/g2';\nimport { get } from '@antv/util';\nimport { deepAssign } from '../../utils';\nimport { adaptor as lineAdaptor } from '../line/adaptor';\nimport { adaptor as pieAdaptor } from '../pie/adaptor';\nimport { adaptor as columnAdaptor } from '../column/adaptor';\nimport { adaptor as barAdaptor } from '../bar/adaptor';\nimport { adaptor as areaAdaptor } from '../area/adaptor';\nimport { adaptor as gaugeAdaptor } from '../gauge/adaptor';\nimport { adaptor as tinyLineAdaptor } from '../tiny-line/adaptor';\nimport { adaptor as tinyColumnAdaptor } from '../tiny-column/adaptor';\nimport { adaptor as tinyAreaAdaptor } from '../tiny-area/adaptor';\nimport { adaptor as ringProgressAdaptor } from '../ring-progress/adaptor';\nimport { adaptor as progressAdaptor } from '../progress/adaptor';\nimport { adaptor as scatterAdaptor } from '../scatter/adaptor';\nimport { adaptor as histogramAdaptor } from '../histogram/adaptor';\nimport { adaptor as funnelAdaptor } from '../funnel/adaptor';\nimport { adaptor as stockAdaptor } from '../stock/adaptor';\nimport { Line, LineOptions } from '../line';\nimport { Pie, PieOptions } from '../pie';\nimport { Bar, BarOptions } from '../bar';\nimport { Column, ColumnOptions } from '../column';\nimport { Area, AreaOptions } from '../area';\nimport { Gauge, GaugeOptions } from '../gauge';\nimport { TinyLine, TinyLineOptions } from '../tiny-line';\nimport { TinyArea, TinyAreaOptions } from '../tiny-area';\nimport { TinyColumn, TinyColumnOptions } from '../tiny-column';\nimport { RingProgress, RingProgressOptions } from '../ring-progress';\nimport { Progress, ProgressOptions } from '../progress';\nimport { Scatter, ScatterOptions } from '../scatter';\nimport { Histogram, HistogramOptions } from '../histogram';\nimport { Funnel, FunnelOptions } from '../funnel';\nimport { Stock, StockOptions } from '../stock';\n\n/**\n * 移除 options 中的 width、height、data 设置\n */\ntype OmitPlotOptions<T> = Omit<T, 'width' | 'height' | 'data'>;\n\n/**\n * multi-view 中的支持的 plots 类型(带 options 定义)\n */\nexport type IPlotTypes =\n | {\n /**\n * plot 类型\n */\n readonly type: 'line';\n /**\n * plot 配置\n */\n readonly options: OmitPlotOptions<LineOptions>;\n }\n | {\n readonly type: 'pie';\n readonly options: OmitPlotOptions<PieOptions>;\n }\n | {\n readonly type: 'bar';\n readonly options: OmitPlotOptions<BarOptions>;\n }\n | {\n readonly type: 'column';\n readonly options: OmitPlotOptions<ColumnOptions>;\n }\n | {\n readonly type: 'area';\n readonly options: OmitPlotOptions<AreaOptions>;\n }\n | {\n readonly type: 'gauge';\n readonly options: OmitPlotOptions<GaugeOptions>;\n }\n | {\n readonly type: 'tiny-line';\n readonly options: OmitPlotOptions<TinyLineOptions>;\n }\n | {\n readonly type: 'tiny-area';\n readonly options: OmitPlotOptions<TinyAreaOptions>;\n }\n | {\n readonly type: 'tiny-column';\n readonly options: OmitPlotOptions<TinyColumnOptions>;\n }\n | {\n readonly type: 'ring-progress';\n readonly options: OmitPlotOptions<RingProgressOptions>;\n }\n | {\n readonly type: 'progress';\n readonly options: OmitPlotOptions<ProgressOptions>;\n }\n | {\n readonly type: 'histogram';\n readonly options: OmitPlotOptions<HistogramOptions>;\n }\n | {\n readonly type: 'scatter';\n readonly options: OmitPlotOptions<ScatterOptions>;\n }\n | {\n readonly type: 'funnel';\n readonly options: OmitPlotOptions<FunnelOptions>;\n }\n | {\n readonly type: 'stock';\n readonly options: OmitPlotOptions<StockOptions>;\n };\n\n/**\n * 可在 multi-view 中使用的 plots\n */\nconst PLOT_ADAPTORS = {\n line: lineAdaptor,\n pie: pieAdaptor,\n column: columnAdaptor,\n bar: barAdaptor,\n area: areaAdaptor,\n gauge: gaugeAdaptor,\n 'tiny-line': tinyLineAdaptor,\n 'tiny-column': tinyColumnAdaptor,\n 'tiny-area': tinyAreaAdaptor,\n 'ring-progress': ringProgressAdaptor,\n progress: progressAdaptor,\n scatter: scatterAdaptor,\n histogram: histogramAdaptor,\n funnel: funnelAdaptor,\n stock: stockAdaptor,\n};\n\n/**\n * 获取指定 plot 的 class contructor\n * @param {string} plot\n */\nconst PLOT_CONSTRUCTOR = {\n line: Line,\n pie: Pie,\n column: Column,\n bar: Bar,\n area: Area,\n gauge: Gauge,\n 'tiny-line': TinyLine,\n 'tiny-column': TinyColumn,\n 'tiny-area': TinyArea,\n 'ring-progress': RingProgress,\n progress: Progress,\n scatter: Scatter,\n histogram: Histogram,\n funnel: Funnel,\n stock: Stock,\n};\n\n/**\n * 在 mix 图表以及 facet 图表中,defaultOptions 进行复写简化\n */\nconst DEFAULT_OPTIONS_MAP = {\n pie: { label: false },\n column: { tooltip: { showMarkers: false } },\n bar: { tooltip: { showMarkers: false } },\n};\n\n/**\n * 执行 plot 的 adaptor, 默认都带上 defaultOptions\n * @param {string} plot\n */\nexport function execPlotAdaptor<T extends IPlotTypes['type']>(\n plot: T,\n view: View,\n options: IPlotTypes['options']\n): void {\n const cls = PLOT_CONSTRUCTOR[plot];\n if (!cls) {\n console.error(`could not find ${plot} plot`);\n return;\n }\n const module = PLOT_ADAPTORS[plot];\n module({\n chart: view,\n options: deepAssign({}, cls.getDefaultOptions(), get(DEFAULT_OPTIONS_MAP, plot, {}), options),\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2plot",
3
- "version": "2.4.13",
3
+ "version": "2.4.14",
4
4
  "description": "An interactive and responsive charting library",
5
5
  "keywords": [
6
6
  "chart",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '2.4.13';
1
+ export const version = '2.4.14';
2
2
 
3
3
  // G2 自定义能力透出
4
4
  import * as G2 from '@antv/g2';
@@ -1,7 +1,7 @@
1
1
  import { each } from '@antv/util';
2
2
  import { Geometry } from '@antv/g2';
3
3
  import { geometry as geometryAdaptor } from '../../adaptor/geometries/base';
4
- import { interaction, animation, theme, tooltip } from '../../adaptor/common';
4
+ import { interaction, animation, theme, tooltip, annotation } from '../../adaptor/common';
5
5
  import { Params } from '../../core/adaptor';
6
6
  import { PLOT_CONTAINER_OPTIONS } from '../../core/plot';
7
7
  import { AXIS_META_CONFIG_KEYS } from '../../constant';
@@ -122,24 +122,41 @@ function multiView(params: Params<MixOptions>): Params<MixOptions> {
122
122
  */
123
123
  function multiPlot(params: Params<MixOptions>): Params<MixOptions> {
124
124
  const { chart, options } = params;
125
- const { plots } = options;
125
+ const { plots, data = [] } = options;
126
126
 
127
127
  each(plots, (plot) => {
128
- const { type, region, options = {} } = plot;
128
+ const { type, region, options = {}, top } = plot;
129
129
  const { tooltip } = options;
130
130
 
131
+ if (top) {
132
+ execPlotAdaptor(type, chart, { ...options, data });
133
+ return;
134
+ }
135
+
131
136
  const viewOfG2 = chart.createView({ region, ...pick(options, PLOT_CONTAINER_OPTIONS) });
132
137
  if (tooltip) {
133
138
  // 配置 tooltip 交互
134
139
  viewOfG2.interaction('tooltip');
135
140
  }
136
141
 
137
- execPlotAdaptor(type, viewOfG2, options);
142
+ execPlotAdaptor(type, viewOfG2, { data, ...options });
138
143
  });
139
144
 
140
145
  return params;
141
146
  }
142
147
 
148
+ /**
149
+ * 处理缩略轴的 adaptor (mix)
150
+ * @param params
151
+ */
152
+ export function slider(params: Params<MixOptions>): Params<MixOptions> {
153
+ const { chart, options } = params;
154
+
155
+ chart.option('slider', options.slider);
156
+
157
+ return params;
158
+ }
159
+
143
160
  /**
144
161
  * 图适配器
145
162
  * @param chart
@@ -153,7 +170,9 @@ export function adaptor(params: Params<MixOptions>) {
153
170
  interaction,
154
171
  animation,
155
172
  theme,
156
- tooltip
173
+ tooltip,
174
+ slider,
175
+ annotation()
157
176
  // ... 其他的 adaptor flow
158
177
  )(params);
159
178
  }
@@ -6,6 +6,7 @@ import { Geometry } from '../../adaptor/geometries/base';
6
6
  import { Animation } from '../../types/animation';
7
7
  import { Annotation } from '../../types/annotation';
8
8
  import { Interaction } from '../../types/interaction';
9
+ import { Slider } from '../../types/slider';
9
10
  import { IPlotTypes } from './utils';
10
11
 
11
12
  /**
@@ -67,11 +68,22 @@ export type IView = {
67
68
  * @title 子 plot 的配置
68
69
  */
69
70
  export type IPlot = IPlotTypes & {
71
+ /**
72
+ * @title 数据
73
+ * @description 设置画布具体的数据. 默认基础顶层 data
74
+ */
75
+ readonly data?: Record<string, any>[];
70
76
  /**
71
77
  * @title plot view 的布局范围
72
78
  * @default "占满全部"
73
79
  */
74
80
  readonly region?: Region;
81
+ /**
82
+ * @title 是否为顶层
83
+ * @description 设置为 true 时,几何图形挂在顶层 chart 对象上,而不是子 view 下。此时 region 设置无效,data 继承顶层 data 配置。
84
+ * @default false
85
+ */
86
+ readonly top?: boolean;
75
87
  };
76
88
 
77
89
  /**
@@ -79,6 +91,10 @@ export type IPlot = IPlotTypes & {
79
91
  */
80
92
  export interface MixOptions
81
93
  extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'legend' | 'tooltip' | 'slider' | 'scrollbar'> {
94
+ /**
95
+ * @title 顶层数据配置
96
+ */
97
+ readonly data?: Options['data'];
82
98
  /**
83
99
  * @title 是否同步子 view 的配置
84
100
  * @description 目前仅仅支持 true / false,后续需要增加 function 的方式进行自定义 view 之前的布局同步
@@ -96,12 +112,18 @@ export interface MixOptions
96
112
  readonly plots?: IPlot[];
97
113
  /**
98
114
  * @title tooltip 配置
99
- * @description tooltip 配置在 chart 层配置
115
+ * @description Mix tooltip 组件配置,统一顶层配置
116
+ * TODO 字段映射
100
117
  */
101
118
  readonly tooltip?: Tooltip;
102
119
  /**
103
120
  * @title legend 配置
104
- * @description 统一顶层配置
121
+ * @description Mix 图例配置,统一顶层配置
105
122
  */
106
123
  readonly legend?: false | Record<string, Legend>;
124
+ /**
125
+ * @title slider 配置
126
+ * @description Mix 缩略轴配置,统一顶层配置
127
+ */
128
+ readonly slider?: Slider;
107
129
  }
@@ -33,9 +33,9 @@ import { Funnel, FunnelOptions } from '../funnel';
33
33
  import { Stock, StockOptions } from '../stock';
34
34
 
35
35
  /**
36
- * 移除 options 中的 width、height 设置
36
+ * 移除 options 中的 width、height、data 设置
37
37
  */
38
- type OmitSize<T> = Omit<T, 'width' | 'height'>;
38
+ type OmitPlotOptions<T> = Omit<T, 'width' | 'height' | 'data'>;
39
39
 
40
40
  /**
41
41
  * multi-view 中的支持的 plots 类型(带 options 定义)
@@ -49,63 +49,63 @@ export type IPlotTypes =
49
49
  /**
50
50
  * plot 配置
51
51
  */
52
- readonly options: OmitSize<LineOptions>;
52
+ readonly options: OmitPlotOptions<LineOptions>;
53
53
  }
54
54
  | {
55
55
  readonly type: 'pie';
56
- readonly options: OmitSize<PieOptions>;
56
+ readonly options: OmitPlotOptions<PieOptions>;
57
57
  }
58
58
  | {
59
59
  readonly type: 'bar';
60
- readonly options: OmitSize<BarOptions>;
60
+ readonly options: OmitPlotOptions<BarOptions>;
61
61
  }
62
62
  | {
63
63
  readonly type: 'column';
64
- readonly options: OmitSize<ColumnOptions>;
64
+ readonly options: OmitPlotOptions<ColumnOptions>;
65
65
  }
66
66
  | {
67
67
  readonly type: 'area';
68
- readonly options: OmitSize<AreaOptions>;
68
+ readonly options: OmitPlotOptions<AreaOptions>;
69
69
  }
70
70
  | {
71
71
  readonly type: 'gauge';
72
- readonly options: OmitSize<GaugeOptions>;
72
+ readonly options: OmitPlotOptions<GaugeOptions>;
73
73
  }
74
74
  | {
75
75
  readonly type: 'tiny-line';
76
- readonly options: OmitSize<TinyLineOptions>;
76
+ readonly options: OmitPlotOptions<TinyLineOptions>;
77
77
  }
78
78
  | {
79
79
  readonly type: 'tiny-area';
80
- readonly options: OmitSize<TinyAreaOptions>;
80
+ readonly options: OmitPlotOptions<TinyAreaOptions>;
81
81
  }
82
82
  | {
83
83
  readonly type: 'tiny-column';
84
- readonly options: OmitSize<TinyColumnOptions>;
84
+ readonly options: OmitPlotOptions<TinyColumnOptions>;
85
85
  }
86
86
  | {
87
87
  readonly type: 'ring-progress';
88
- readonly options: OmitSize<RingProgressOptions>;
88
+ readonly options: OmitPlotOptions<RingProgressOptions>;
89
89
  }
90
90
  | {
91
91
  readonly type: 'progress';
92
- readonly options: OmitSize<ProgressOptions>;
92
+ readonly options: OmitPlotOptions<ProgressOptions>;
93
93
  }
94
94
  | {
95
95
  readonly type: 'histogram';
96
- readonly options: OmitSize<HistogramOptions>;
96
+ readonly options: OmitPlotOptions<HistogramOptions>;
97
97
  }
98
98
  | {
99
99
  readonly type: 'scatter';
100
- readonly options: OmitSize<ScatterOptions>;
100
+ readonly options: OmitPlotOptions<ScatterOptions>;
101
101
  }
102
102
  | {
103
103
  readonly type: 'funnel';
104
- readonly options: OmitSize<FunnelOptions>;
104
+ readonly options: OmitPlotOptions<FunnelOptions>;
105
105
  }
106
106
  | {
107
107
  readonly type: 'stock';
108
- readonly options: OmitSize<StockOptions>;
108
+ readonly options: OmitPlotOptions<StockOptions>;
109
109
  };
110
110
 
111
111
  /**