@antv/g2plot 2.4.1 → 2.4.2
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.
- package/CHANGELOG.md +15 -0
- package/dist/g2plot.min.js +4 -4
- package/dist/g2plot.min.js.map +1 -1
- package/esm/index.d.ts +9 -1
- package/esm/index.js +9 -1
- package/esm/index.js.map +1 -1
- package/esm/plots/area/adaptor.js +15 -5
- package/esm/plots/area/adaptor.js.map +1 -1
- package/esm/plots/area/constants.d.ts +2 -0
- package/esm/plots/area/constants.js +2 -0
- package/esm/plots/area/constants.js.map +1 -1
- package/esm/plots/area/index.js +11 -4
- package/esm/plots/area/index.js.map +1 -1
- package/esm/plots/line/adaptor.js +30 -15
- package/esm/plots/line/adaptor.js.map +1 -1
- package/esm/plots/line/constants.d.ts +2 -0
- package/esm/plots/line/constants.js +3 -0
- package/esm/plots/line/constants.js.map +1 -1
- package/esm/plots/line/index.js +8 -1
- package/esm/plots/line/index.js.map +1 -1
- package/esm/plots/line/interactions/marker-active.js +8 -11
- package/esm/plots/line/interactions/marker-active.js.map +1 -1
- package/esm/utils/geometry.js +2 -1
- package/esm/utils/geometry.js.map +1 -1
- package/lib/index.d.ts +9 -1
- package/lib/index.js +13 -5
- package/lib/index.js.map +1 -1
- package/lib/plots/area/adaptor.js +13 -3
- package/lib/plots/area/adaptor.js.map +1 -1
- package/lib/plots/area/constants.d.ts +2 -0
- package/lib/plots/area/constants.js +3 -1
- package/lib/plots/area/constants.js.map +1 -1
- package/lib/plots/area/index.js +10 -3
- package/lib/plots/area/index.js.map +1 -1
- package/lib/plots/line/adaptor.js +29 -14
- package/lib/plots/line/adaptor.js.map +1 -1
- package/lib/plots/line/constants.d.ts +2 -0
- package/lib/plots/line/constants.js +4 -1
- package/lib/plots/line/constants.js.map +1 -1
- package/lib/plots/line/index.js +7 -0
- package/lib/plots/line/index.js.map +1 -1
- package/lib/plots/line/interactions/marker-active.js +8 -11
- package/lib/plots/line/interactions/marker-active.js.map +1 -1
- package/lib/utils/geometry.js +2 -1
- package/lib/utils/geometry.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +9 -1
- package/src/plots/area/adaptor.ts +16 -5
- package/src/plots/area/constants.ts +3 -0
- package/src/plots/area/index.ts +10 -3
- package/src/plots/line/adaptor.ts +35 -14
- package/src/plots/line/constants.ts +4 -0
- package/src/plots/line/index.ts +8 -1
- package/src/plots/line/interactions/marker-active.ts +9 -12
- package/src/utils/geometry.ts +2 -1
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const version = "2.4.
|
|
1
|
+
export declare const version = "2.4.2";
|
|
2
2
|
import * as G2 from '@antv/g2';
|
|
3
3
|
export { G2 };
|
|
4
4
|
import { registerLocale } from './core/locale';
|
|
@@ -88,6 +88,14 @@ export { Mix as Mix } from './plots/mix';
|
|
|
88
88
|
export type { MixOptions } from './plots/mix';
|
|
89
89
|
export { Facet } from './plots/facet';
|
|
90
90
|
export type { FacetOptions } from './plots/facet';
|
|
91
|
+
/** 提供一些工具方法 */
|
|
92
|
+
import { findGeometry, getAllGeometriesRecursively, findViewById } from './utils';
|
|
93
|
+
declare const Util: {
|
|
94
|
+
findGeometry: typeof findGeometry;
|
|
95
|
+
findViewById: typeof findViewById;
|
|
96
|
+
getAllGeometriesRecursively: typeof getAllGeometriesRecursively;
|
|
97
|
+
};
|
|
98
|
+
export { Util };
|
|
91
99
|
/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */
|
|
92
100
|
export { flow, measureTextWidth } from './utils';
|
|
93
101
|
/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export var version = '2.4.
|
|
1
|
+
export var version = '2.4.2';
|
|
2
2
|
// G2 自定义能力透出
|
|
3
3
|
import * as G2 from '@antv/g2';
|
|
4
4
|
export { G2 };
|
|
@@ -94,6 +94,14 @@ export { Mix as MultiView } from './plots/mix';
|
|
|
94
94
|
export { Mix as Mix } from './plots/mix';
|
|
95
95
|
// 分面图及类型定义 | author by [visiky](https://github.com/visiky)
|
|
96
96
|
export { Facet } from './plots/facet';
|
|
97
|
+
/** 提供一些工具方法 */
|
|
98
|
+
import { findGeometry, getAllGeometriesRecursively, findViewById } from './utils';
|
|
99
|
+
var Util = {
|
|
100
|
+
findGeometry: findGeometry,
|
|
101
|
+
findViewById: findViewById,
|
|
102
|
+
getAllGeometriesRecursively: getAllGeometriesRecursively,
|
|
103
|
+
};
|
|
104
|
+
export { Util };
|
|
97
105
|
/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */
|
|
98
106
|
export { flow, measureTextWidth } from './utils';
|
|
99
107
|
/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,CAAC;AAEd,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,8BAA8B;AAC9B,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,uBAAuB;AACvB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,WAAW;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,uBAAuB;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKnC,SAAS;AACT,cAAc,SAAS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I,GAAG,EAAE,MAAM,aAAa,CAAC;AAGzC,2DAA2D;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjD,0CAA0C;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASpF,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrG,MAAM,CAAC,IAAM,QAAQ,GAAG,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,OAAO,SAAA,EAAE,UAAU,YAAA,EAAE,WAAW,aAAA,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export const version = '2.4.1';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\nexport { G2 };\n\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n\n// 类型定义导出\nexport * from './types';\n\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\n\n// 已经废弃,更名为 Mix\nexport { Mix as MultiView } from './plots/mix';\nexport type { MixOptions as MultiViewOptions } from './plots/mix';\n/** 开放多图层图表 (mix) */\nexport { Mix as Mix } from './plots/mix';\nexport type { MixOptions } from './plots/mix';\n\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { line, interval, area, point, polygon, schema } from './adaptor/geometries';\nexport type {\n LineGeometryOptions,\n IntervalGeometryOptions,\n AreaGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common';\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,CAAC;AAEd,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,8BAA8B;AAC9B,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,uBAAuB;AACvB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,WAAW;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,uBAAuB;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKnC,SAAS;AACT,cAAc,SAAS,CAAC;AAExB,2DAA2D;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,2DAA2D;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM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AAE,YAAY,EAAE,2BAA2B,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClF,IAAM,IAAI,GAAG;IACX,YAAY,cAAA;IACZ,YAAY,cAAA;IACZ,2BAA2B,6BAAA;CAC5B,CAAC;AACF,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjD,0CAA0C;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASpF,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrG,MAAM,CAAC,IAAM,QAAQ,GAAG,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,OAAO,SAAA,EAAE,UAAU,YAAA,EAAE,WAAW,aAAA,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export const version = '2.4.2';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\nexport { G2 };\n\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n\n// 类型定义导出\nexport * from './types';\n\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\n\n// 已经废弃,更名为 Mix\nexport { Mix as MultiView } from './plots/mix';\nexport type { MixOptions as MultiViewOptions } from './plots/mix';\n/** 开放多图层图表 (mix) */\nexport { Mix as Mix } from './plots/mix';\nexport type { MixOptions } from './plots/mix';\n\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n\n/** 提供一些工具方法 */\nimport { findGeometry, getAllGeometriesRecursively, findViewById } from './utils';\nconst Util = {\n findGeometry,\n findViewById,\n getAllGeometriesRecursively,\n};\nexport { Util };\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { line, interval, area, point, polygon, schema } from './adaptor/geometries';\nexport type {\n LineGeometryOptions,\n IntervalGeometryOptions,\n AreaGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common';\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
|
-
import { each } from '@antv/util';
|
|
2
|
+
import { each, isNil } from '@antv/util';
|
|
3
3
|
import { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';
|
|
4
|
-
import { findGeometry } from '../../utils';
|
|
4
|
+
import { findGeometry, getAllGeometriesRecursively } from '../../utils';
|
|
5
5
|
import { area, point, line } from '../../adaptor/geometries';
|
|
6
6
|
import { flow, transformLabel, deepAssign } from '../../utils';
|
|
7
7
|
import { getDataWhetherPecentage } from '../../utils/transform/percent';
|
|
8
8
|
import { meta, legend, axis } from '../line/adaptor';
|
|
9
|
+
import { POINT_VIEW_ID } from './constants';
|
|
9
10
|
export { meta };
|
|
10
11
|
/**
|
|
11
12
|
* geometry 处理
|
|
@@ -42,11 +43,19 @@ function geometry(params) {
|
|
|
42
43
|
var lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {
|
|
43
44
|
options: { sizeField: seriesField, tooltip: false },
|
|
44
45
|
});
|
|
45
|
-
var pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
46
46
|
// area geometry 处理
|
|
47
47
|
area(primary);
|
|
48
48
|
line(lineParams);
|
|
49
|
-
|
|
49
|
+
var pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
50
|
+
if (pointMapping) {
|
|
51
|
+
var pointView = chart.createView({ id: POINT_VIEW_ID });
|
|
52
|
+
pointView.axis(false);
|
|
53
|
+
pointView.tooltip(false);
|
|
54
|
+
pointView.legend(false);
|
|
55
|
+
// [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)
|
|
56
|
+
pointView.data(data.filter(function (d) { return !isNil(d[yField]); }));
|
|
57
|
+
point(__assign(__assign({}, pointParams), { chart: pointView }));
|
|
58
|
+
}
|
|
50
59
|
return params;
|
|
51
60
|
}
|
|
52
61
|
/**
|
|
@@ -84,7 +93,8 @@ function adjust(params) {
|
|
|
84
93
|
var chart = params.chart, options = params.options;
|
|
85
94
|
var isStack = options.isStack, isPercent = options.isPercent, seriesField = options.seriesField;
|
|
86
95
|
if ((isPercent || isStack) && seriesField) {
|
|
87
|
-
|
|
96
|
+
var geometries = getAllGeometriesRecursively(chart);
|
|
97
|
+
each(geometries, function (g) {
|
|
88
98
|
g.adjust('stack');
|
|
89
99
|
});
|
|
90
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/area/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/area/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MA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,EAAE,eAAe,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;iBACnD,IACE,cAAc,CAAC,GAAG,CAAC,CACvB;SACF,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,MAAM,CAAC,MAA2B;IACjC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,OAAO,GAA6B,OAAO,QAApC,EAAE,SAAS,GAAkB,OAAO,UAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IACpD,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,WAAW,EAAE;QACzC,IAAM,UAAU,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,CAAC,UAAU,EAAE,UAAC,CAAW;YAC3B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,MAA2B;IACjD,0BAA0B;IAC1B,OAAO,IAAI,CACT,KAAK,EACL,OAAO,CAAC,WAAW,CAAC,EACpB,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EAAE,EACZ,WAAW,EACX,SAAS,EACT,WAAW,CACZ,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { each, isNil } from '@antv/util';\nimport { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';\nimport { findGeometry, getAllGeometriesRecursively } from '../../utils';\nimport { Params } from '../../core/adaptor';\nimport { area, point, line } from '../../adaptor/geometries';\nimport { flow, transformLabel, deepAssign } from '../../utils';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { Datum } from '../../types';\nimport { meta, legend, axis } from '../line/adaptor';\nimport { POINT_VIEW_ID } from './constants';\nimport { AreaOptions } from './types';\n\nexport { meta };\n\n/**\n * geometry 处理\n * @param params\n */\nfunction geometry(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const {\n data,\n areaStyle,\n color,\n point: pointMapping,\n line: lineMapping,\n isPercent,\n xField,\n yField,\n tooltip,\n seriesField,\n startOnZero,\n } = options;\n const pointState = pointMapping?.state;\n\n const chartData = getDataWhetherPecentage(data, yField, xField, yField, isPercent);\n chart.data(chartData);\n // 百分比堆积图,默认会给一个 % 格式化逻辑, 用户可自定义\n const tooltipOptions = isPercent\n ? {\n formatter: (datum: Datum) => ({\n name: datum[seriesField] || datum[xField],\n value: (Number(datum[yField]) * 100).toFixed(2) + '%',\n }),\n ...tooltip,\n }\n : tooltip;\n const primary = deepAssign({}, params, {\n options: {\n area: { color, style: areaStyle },\n // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。\n // 如果存在,才设置,否则为空\n line: lineMapping && {\n color,\n ...lineMapping,\n },\n point: pointMapping && {\n color,\n ...pointMapping,\n },\n tooltip: tooltipOptions,\n // label 不传递给各个 geometry adaptor,由 label adaptor 处理\n label: undefined,\n args: {\n startOnZero,\n },\n },\n });\n // 线默认 2px\n const lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {\n options: { sizeField: seriesField, tooltip: false },\n });\n\n // area geometry 处理\n area(primary);\n line(lineParams);\n\n const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n if (pointMapping) {\n const pointView = chart.createView({ id: POINT_VIEW_ID });\n pointView.axis(false);\n pointView.tooltip(false);\n pointView.legend(false);\n // [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)\n pointView.data(data.filter((d) => !isNil(d[yField])));\n point({ ...pointParams, chart: pointView });\n }\n\n return params;\n}\n\n/**\n * 数据标签\n * @param params\n */\nfunction label(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { label, yField } = options;\n\n const areaGeometry = findGeometry(chart, 'area');\n\n // label 为 false, 空 则不显示 label\n if (!label) {\n areaGeometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n areaGeometry.label({\n fields: [yField],\n callback,\n cfg: {\n layout: [\n { type: 'limit-in-plot' },\n { type: 'path-adjust-position' },\n { type: 'point-adjust-position' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ],\n ...transformLabel(cfg),\n },\n });\n }\n\n return params;\n}\n\n/**\n * 处理 adjust\n * @param params\n */\nfunction adjust(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { isStack, isPercent, seriesField } = options;\n if ((isPercent || isStack) && seriesField) {\n const geometries = getAllGeometriesRecursively(chart);\n each(geometries, (g: Geometry) => {\n g.adjust('stack');\n });\n }\n\n return params;\n}\n\n/**\n * 折线图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<AreaOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n theme,\n pattern('areaStyle'),\n geometry,\n meta,\n adjust,\n axis,\n legend,\n tooltip,\n label,\n slider,\n annotation(),\n interaction,\n animation,\n limitInPlot\n )(params);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/plots/area/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,EAAE;IACtE,OAAO,EAAE;QACP,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE;YACV,IAAI,EAAE,GAAG;SACV;KACF;IACD,OAAO,EAAE,IAAI;IACb,OAAO;IACP,IAAI,EAAE,EAAE;IACR,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { Plot } from '../../core/plot';\nimport { deepAssign } from '../../utils';\n\n/**\n * 面积图默认配置项\n */\nexport const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {\n tooltip: {\n shared: true,\n showMarkers: true,\n showCrosshairs: true,\n crosshairs: {\n type: 'x',\n },\n },\n isStack: true,\n // 默认开启\n line: {},\n legend: {\n position: 'top-left',\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/plots/area/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,kBAAkB;AAClB,MAAM,CAAC,IAAM,aAAa,GAAG,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,EAAE;IACtE,OAAO,EAAE;QACP,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE;YACV,IAAI,EAAE,GAAG;SACV;KACF;IACD,OAAO,EAAE,IAAI;IACb,OAAO;IACP,IAAI,EAAE,EAAE;IACR,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { Plot } from '../../core/plot';\nimport { deepAssign } from '../../utils';\n\n/** point 标注点视图 */\nexport const POINT_VIEW_ID = 'point-view';\n\n/**\n * 面积图默认配置项\n */\nexport const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {\n tooltip: {\n shared: true,\n showMarkers: true,\n showCrosshairs: true,\n crosshairs: {\n type: 'x',\n },\n },\n isStack: true,\n // 默认开启\n line: {},\n legend: {\n position: 'top-left',\n },\n});\n"]}
|
package/esm/plots/area/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
|
+
import { isNil } from '@antv/util';
|
|
2
3
|
import { Plot } from '../../core/plot';
|
|
3
4
|
import { getDataWhetherPecentage } from '../../utils/transform/percent';
|
|
5
|
+
import { findViewById } from '../../utils';
|
|
4
6
|
import { adaptor, meta } from './adaptor';
|
|
5
|
-
import { DEFAULT_OPTIONS } from './constants';
|
|
7
|
+
import { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';
|
|
6
8
|
var Area = /** @class */ (function (_super) {
|
|
7
9
|
__extends(Area, _super);
|
|
8
10
|
function Area() {
|
|
@@ -30,10 +32,15 @@ var Area = /** @class */ (function (_super) {
|
|
|
30
32
|
*/
|
|
31
33
|
Area.prototype.changeData = function (data) {
|
|
32
34
|
this.updateOption({ data: data });
|
|
33
|
-
var _a = this
|
|
34
|
-
var
|
|
35
|
+
var _a = this, chart = _a.chart, options = _a.options;
|
|
36
|
+
var isPercent = options.isPercent, xField = options.xField, yField = options.yField;
|
|
35
37
|
meta({ chart: chart, options: options });
|
|
36
|
-
|
|
38
|
+
var chartdata = getDataWhetherPecentage(data, yField, xField, yField, isPercent);
|
|
39
|
+
this.chart.changeData(chartdata);
|
|
40
|
+
var pointView = findViewById(this.chart, POINT_VIEW_ID);
|
|
41
|
+
if (pointView) {
|
|
42
|
+
pointView.changeData(data.filter(function (d) { return !isNil(d[yField]); }));
|
|
43
|
+
}
|
|
37
44
|
};
|
|
38
45
|
/**
|
|
39
46
|
* 获取 面积图 的适配器
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/area/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BA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CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QAC1D,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAjB,CAAiB,CAAC,CAAC,CAAC;SAC7D;IACH,CAAC;IAED;;OAEG;IACO,+BAAgB,GAA1B;QACE,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,WAAC;AAAD,CAAC,AA1CD,CAA0B,IAAI,GA0C7B","sourcesContent":["import { isNil } from '@antv/util';\nimport { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { findViewById } from '../../utils';\nimport { AreaOptions } from './types';\nimport { adaptor, meta } from './adaptor';\nimport { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';\n\nexport type { AreaOptions };\n\nexport class Area extends Plot<AreaOptions> {\n /**\n * 获取 面积图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<AreaOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public type: string = 'area';\n\n /**\n * 获取 面积图 默认配置\n */\n protected getDefaultOptions() {\n return Area.getDefaultOptions();\n }\n\n /**\n * @override\n * @param data\n */\n public changeData(data: AreaOptions['data']) {\n this.updateOption({ data });\n const { chart, options } = this;\n const { isPercent, xField, yField } = options;\n meta({ chart, options });\n const chartdata = getDataWhetherPecentage(data, yField, xField, yField, isPercent);\n this.chart.changeData(chartdata);\n const pointView = findViewById(this.chart, POINT_VIEW_ID);\n if (pointView) {\n pointView.changeData(data.filter((d) => !isNil(d[yField])));\n }\n }\n\n /**\n * 获取 面积图 的适配器\n */\n protected getSchemaAdaptor(): Adaptor<AreaOptions> {\n return adaptor;\n }\n}\n"]}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
|
-
import { each, isArray } from '@antv/util';
|
|
2
|
+
import { each, isArray, isNil, uniq } from '@antv/util';
|
|
3
3
|
import { tooltip, slider, interaction, animation, theme, scale, annotation, limitInPlot } from '../../adaptor/common';
|
|
4
|
-
import { findGeometry, transformLabel, deepAssign } from '../../utils';
|
|
4
|
+
import { flow, findGeometry, transformLabel, deepAssign, getAllGeometriesRecursively } from '../../utils';
|
|
5
5
|
import { point, line, area } from '../../adaptor/geometries';
|
|
6
|
-
import { flow } from '../../utils';
|
|
7
6
|
import { adjustYMetaByZero } from '../../utils/data';
|
|
7
|
+
import { POINT_VIEW_ID } from './constants';
|
|
8
8
|
/**
|
|
9
9
|
* geometry 配置处理
|
|
10
10
|
* @param params
|
|
11
11
|
*/
|
|
12
12
|
function geometry(params) {
|
|
13
13
|
var chart = params.chart, options = params.options;
|
|
14
|
-
var data = options.data, color = options.color, lineStyle = options.lineStyle, lineShape = options.lineShape, pointMapping = options.point, areaMapping = options.area, seriesField = options.seriesField;
|
|
14
|
+
var data = options.data, color = options.color, lineStyle = options.lineStyle, lineShape = options.lineShape, pointMapping = options.point, areaMapping = options.area, yField = options.yField, seriesField = options.seriesField;
|
|
15
15
|
var pointState = pointMapping === null || pointMapping === void 0 ? void 0 : pointMapping.state;
|
|
16
16
|
chart.data(data);
|
|
17
17
|
// line geometry 处理
|
|
@@ -32,11 +32,19 @@ function geometry(params) {
|
|
|
32
32
|
label: undefined,
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
|
-
var second = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
36
35
|
var areaParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
37
36
|
line(primary);
|
|
38
|
-
point(second);
|
|
39
37
|
area(areaParams);
|
|
38
|
+
var pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
39
|
+
if (pointMapping) {
|
|
40
|
+
var pointView = chart.createView({ id: POINT_VIEW_ID });
|
|
41
|
+
pointView.axis(false);
|
|
42
|
+
pointView.tooltip(false);
|
|
43
|
+
pointView.legend(false);
|
|
44
|
+
// [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)
|
|
45
|
+
pointView.data(data.filter(function (d) { return !isNil(d[yField]); }));
|
|
46
|
+
point(__assign(__assign({}, pointParams), { chart: pointView }));
|
|
47
|
+
}
|
|
40
48
|
return params;
|
|
41
49
|
}
|
|
42
50
|
/**
|
|
@@ -46,16 +54,22 @@ function geometry(params) {
|
|
|
46
54
|
export function meta(params) {
|
|
47
55
|
var _a, _b;
|
|
48
56
|
var options = params.options;
|
|
49
|
-
var xAxis = options.xAxis, yAxis = options.yAxis, xField = options.xField, yField = options.yField, data = options.data;
|
|
50
|
-
|
|
51
|
-
_a[xField] =
|
|
52
|
-
_a[yField] = yAxis,
|
|
53
|
-
_a), (_b = {},
|
|
54
|
-
_b[xField] = {
|
|
57
|
+
var xAxis = options.xAxis, yAxis = options.yAxis, xField = options.xField, yField = options.yField, data = options.data, seriesField = options.seriesField;
|
|
58
|
+
var defaultMeta = (_a = {},
|
|
59
|
+
_a[xField] = {
|
|
55
60
|
type: 'cat',
|
|
61
|
+
sync: true,
|
|
62
|
+
values: uniq(data.map(function (d) { return d[xField]; })),
|
|
56
63
|
},
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
_a[yField] = __assign(__assign({}, adjustYMetaByZero(data, yField)), { sync: true }),
|
|
65
|
+
_a);
|
|
66
|
+
if (seriesField) {
|
|
67
|
+
defaultMeta[seriesField] = { sync: true };
|
|
68
|
+
}
|
|
69
|
+
return flow(scale((_b = {},
|
|
70
|
+
_b[xField] = xAxis,
|
|
71
|
+
_b[yField] = yAxis,
|
|
72
|
+
_b), defaultMeta))(params);
|
|
59
73
|
}
|
|
60
74
|
/**
|
|
61
75
|
* 坐标系配置. 支持 reflect 镜像处理
|
|
@@ -145,8 +159,9 @@ function label(params) {
|
|
|
145
159
|
export function adjust(params) {
|
|
146
160
|
var chart = params.chart, options = params.options;
|
|
147
161
|
var isStack = options.isStack;
|
|
162
|
+
var geometries = getAllGeometriesRecursively(chart);
|
|
148
163
|
if (isStack) {
|
|
149
|
-
each(
|
|
164
|
+
each(geometries, function (g) {
|
|
150
165
|
g.adjust('stack');
|
|
151
166
|
});
|
|
152
167
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/line/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAA2B;IACnC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,IAAI,GAAuF,OAAO,KAA9F,EAAE,KAAK,GAAgF,OAAO,MAAvF,EAAE,SAAS,GAAqE,OAAO,UAA5E,EAAE,SAAS,GAA0D,OAAO,UAAjE,EAAS,YAAY,GAAqC,OAAO,MAA5C,EAAQ,WAAW,GAAkB,OAAO,KAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IAC3G,IAAM,UAAU,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,CAAC;IAEvC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjB,mBA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AE;oBAChC,EAAE,IAAI,EAAE,uBAAuB,EAAE;oBACjC,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;iBACnD,IACE,cAAc,CAAC,GAAG,CAAC,CACvB;SACF,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,MAA4C;IACzD,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;IAE5B,IAAI,OAAO,EAAE;QACX,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAC,CAAW;YACjC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,MAA2B;IACjD,0BAA0B;IAC1B,OAAO,IAAI,CACT,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,KAAK,EACL,UAAU,EACV,IAAI,EACJ,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,WAAW,EACX,SAAS,EACT,UAAU,EAAE,EACZ,WAAW,CACZ,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { each, isArray } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { tooltip, slider, interaction, animation, theme, scale, annotation, limitInPlot } from '../../adaptor/common';\nimport { findGeometry, transformLabel, deepAssign } from '../../utils';\nimport { point, line, area } from '../../adaptor/geometries';\nimport { flow } from '../../utils';\nimport { adjustYMetaByZero } from '../../utils/data';\nimport { LineOptions } from './types';\n\n/**\n * geometry 配置处理\n * @param params\n */\nfunction geometry(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { data, color, lineStyle, lineShape, point: pointMapping, area: areaMapping, seriesField } = options;\n const pointState = pointMapping?.state;\n\n chart.data(data);\n\n // line geometry 处理\n const primary = deepAssign({}, params, {\n options: {\n shapeField: seriesField,\n line: {\n color,\n style: lineStyle,\n shape: lineShape,\n },\n // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。\n // 如果存在,才设置,否则为空\n point: pointMapping && {\n color,\n shape: 'circle',\n ...pointMapping,\n },\n // 面积配置\n area: areaMapping && {\n color,\n ...areaMapping,\n },\n // label 不传递给各个 geometry adaptor,由 label adaptor 处理\n label: undefined,\n },\n });\n const second = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n const areaParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n\n line(primary);\n point(second);\n area(areaParams);\n\n return params;\n}\n\n/**\n * meta 配置\n * @param params\n */\nexport function meta(params: Params<LineOptions>): Params<LineOptions> {\n const { options } = params;\n const { xAxis, yAxis, xField, yField, data } = options;\n\n return flow(\n scale(\n {\n [xField]: xAxis,\n [yField]: yAxis,\n },\n {\n [xField]: {\n type: 'cat',\n },\n [yField]: adjustYMetaByZero(data, yField),\n }\n )\n )(params);\n}\n\n/**\n * 坐标系配置. 支持 reflect 镜像处理\n * @param params\n */\nfunction coordinate(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { reflect } = options;\n if (reflect) {\n let p = reflect as any;\n if (!isArray(p)) {\n p = [p];\n }\n const actions = p.map((d) => ['reflect', d]);\n\n chart.coordinate({ type: 'rect', actions });\n }\n\n return params;\n}\n\n/**\n * axis 配置\n * @param params\n */\nexport function axis(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { xAxis, yAxis, xField, yField } = options;\n\n // 为 false 则是不显示轴\n if (xAxis === false) {\n chart.axis(xField, false);\n } else {\n chart.axis(xField, xAxis);\n }\n\n if (yAxis === false) {\n chart.axis(yField, false);\n } else {\n chart.axis(yField, yAxis);\n }\n\n return params;\n}\n\n/**\n * legend 配置\n * @param params\n */\nexport function legend(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { legend, seriesField } = options;\n\n if (legend && seriesField) {\n chart.legend(seriesField, legend);\n } else if (legend === false) {\n chart.legend(false);\n }\n\n return params;\n}\n\n/**\n * 数据标签\n * @param params\n */\nfunction label(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { label, yField } = options;\n\n const lineGeometry = findGeometry(chart, 'line');\n\n // label 为 false, 空 则不显示 label\n if (!label) {\n lineGeometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n lineGeometry.label({\n fields: [yField],\n callback,\n cfg: {\n layout: [\n { type: 'limit-in-plot' },\n { type: 'path-adjust-position' },\n { type: 'point-adjust-position' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ],\n ...transformLabel(cfg),\n },\n });\n }\n\n return params;\n}\n\n/**\n * 统一处理 adjust\n * @param params\n */\nexport function adjust(params: Params<Pick<LineOptions, 'isStack'>>): Params<any> {\n const { chart, options } = params;\n const { isStack } = options;\n\n if (isStack) {\n each(chart.geometries, (g: Geometry) => {\n g.adjust('stack');\n });\n }\n\n return params;\n}\n\n/**\n * 折线图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<LineOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n geometry,\n meta,\n adjust,\n theme,\n coordinate,\n axis,\n legend,\n tooltip,\n label,\n slider,\n interaction,\n animation,\n annotation(),\n limitInPlot\n )(params);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/line/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBA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W,EACX,SAAS,EACT,UAAU,EAAE,EACZ,WAAW,CACZ,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { each, isArray, isNil, uniq } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { tooltip, slider, interaction, animation, theme, scale, annotation, limitInPlot } from '../../adaptor/common';\nimport { flow, findGeometry, transformLabel, deepAssign, getAllGeometriesRecursively } from '../../utils';\nimport { point, line, area } from '../../adaptor/geometries';\nimport { adjustYMetaByZero } from '../../utils/data';\nimport { POINT_VIEW_ID } from './constants';\nimport { LineOptions } from './types';\n\n/**\n * geometry 配置处理\n * @param params\n */\nfunction geometry(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { data, color, lineStyle, lineShape, point: pointMapping, area: areaMapping, yField, seriesField } = options;\n const pointState = pointMapping?.state;\n\n chart.data(data);\n\n // line geometry 处理\n const primary = deepAssign({}, params, {\n options: {\n shapeField: seriesField,\n line: {\n color,\n style: lineStyle,\n shape: lineShape,\n },\n // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。\n // 如果存在,才设置,否则为空\n point: pointMapping && {\n color,\n shape: 'circle',\n ...pointMapping,\n },\n // 面积配置\n area: areaMapping && {\n color,\n ...areaMapping,\n },\n // label 不传递给各个 geometry adaptor,由 label adaptor 处理\n label: undefined,\n },\n });\n\n const areaParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n\n line(primary);\n area(areaParams);\n\n const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n if (pointMapping) {\n const pointView = chart.createView({ id: POINT_VIEW_ID });\n pointView.axis(false);\n pointView.tooltip(false);\n pointView.legend(false);\n // [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)\n pointView.data(data.filter((d) => !isNil(d[yField])));\n point({ ...pointParams, chart: pointView });\n }\n\n return params;\n}\n\n/**\n * meta 配置\n * @param params\n */\nexport function meta(params: Params<LineOptions>): Params<LineOptions> {\n const { options } = params;\n const { xAxis, yAxis, xField, yField, data, seriesField } = options;\n const defaultMeta = {\n [xField]: {\n type: 'cat',\n sync: true,\n values: uniq(data.map((d) => d[xField])),\n },\n [yField]: {\n ...adjustYMetaByZero(data, yField),\n sync: true,\n },\n };\n if (seriesField) {\n defaultMeta[seriesField] = { sync: true };\n }\n\n return flow(\n scale(\n {\n [xField]: xAxis,\n [yField]: yAxis,\n },\n defaultMeta\n )\n )(params);\n}\n\n/**\n * 坐标系配置. 支持 reflect 镜像处理\n * @param params\n */\nfunction coordinate(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { reflect } = options;\n if (reflect) {\n let p = reflect as any;\n if (!isArray(p)) {\n p = [p];\n }\n const actions = p.map((d) => ['reflect', d]);\n\n chart.coordinate({ type: 'rect', actions });\n }\n\n return params;\n}\n\n/**\n * axis 配置\n * @param params\n */\nexport function axis(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { xAxis, yAxis, xField, yField } = options;\n\n // 为 false 则是不显示轴\n if (xAxis === false) {\n chart.axis(xField, false);\n } else {\n chart.axis(xField, xAxis);\n }\n\n if (yAxis === false) {\n chart.axis(yField, false);\n } else {\n chart.axis(yField, yAxis);\n }\n\n return params;\n}\n\n/**\n * legend 配置\n * @param params\n */\nexport function legend(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { legend, seriesField } = options;\n\n if (legend && seriesField) {\n chart.legend(seriesField, legend);\n } else if (legend === false) {\n chart.legend(false);\n }\n\n return params;\n}\n\n/**\n * 数据标签\n * @param params\n */\nfunction label(params: Params<LineOptions>): Params<LineOptions> {\n const { chart, options } = params;\n const { label, yField } = options;\n\n const lineGeometry = findGeometry(chart, 'line');\n\n // label 为 false, 空 则不显示 label\n if (!label) {\n lineGeometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n lineGeometry.label({\n fields: [yField],\n callback,\n cfg: {\n layout: [\n { type: 'limit-in-plot' },\n { type: 'path-adjust-position' },\n { type: 'point-adjust-position' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ],\n ...transformLabel(cfg),\n },\n });\n }\n\n return params;\n}\n\n/**\n * 统一处理 adjust\n * @param params\n */\nexport function adjust(params: Params<Pick<LineOptions, 'isStack'>>): Params<any> {\n const { chart, options } = params;\n const { isStack } = options;\n\n const geometries = getAllGeometriesRecursively(chart);\n\n if (isStack) {\n each(geometries, (g: Geometry) => {\n g.adjust('stack');\n });\n }\n\n return params;\n}\n\n/**\n * 折线图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<LineOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n geometry,\n meta,\n adjust,\n theme,\n coordinate,\n axis,\n legend,\n tooltip,\n label,\n slider,\n interaction,\n animation,\n annotation(),\n limitInPlot\n )(params);\n}\n"]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Plot } from '../../core/plot';
|
|
2
2
|
import { deepAssign } from '../../utils';
|
|
3
|
+
/** point 标注点视图 */
|
|
4
|
+
export var POINT_VIEW_ID = 'point-view';
|
|
3
5
|
/**
|
|
4
6
|
* 折线图默认配置项
|
|
5
7
|
*/
|
|
6
8
|
export var DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
|
|
9
|
+
syncViewPadding: true,
|
|
7
10
|
tooltip: {
|
|
8
11
|
shared: true,
|
|
9
12
|
showMarkers: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/plots/line/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,EAAE;IACtE,OAAO,EAAE;QACP,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE;YACV,IAAI,EAAE,GAAG;SACV;KACF;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;KACrB;IACD,OAAO,EAAE,KAAK;CACf,CAAC,CAAC","sourcesContent":["import { Plot } from '../../core/plot';\nimport { deepAssign } from '../../utils';\n\n/**\n * 折线图默认配置项\n */\nexport const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {\n tooltip: {\n shared: true,\n showMarkers: true,\n showCrosshairs: true,\n crosshairs: {\n type: 'x',\n },\n },\n legend: {\n position: 'top-left',\n },\n isStack: false,\n});\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/plots/line/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,kBAAkB;AAClB,MAAM,CAAC,IAAM,aAAa,GAAG,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,EAAE;IACtE,eAAe,EAAE,IAAI;IACrB,OAAO,EAAE;QACP,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE;YACV,IAAI,EAAE,GAAG;SACV;KACF;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;KACrB;IACD,OAAO,EAAE,KAAK;CACf,CAAC,CAAC","sourcesContent":["import { Plot } from '../../core/plot';\nimport { deepAssign } from '../../utils';\n\n/** point 标注点视图 */\nexport const POINT_VIEW_ID = 'point-view';\n\n/**\n * 折线图默认配置项\n */\nexport const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {\n syncViewPadding: true,\n tooltip: {\n shared: true,\n showMarkers: true,\n showCrosshairs: true,\n crosshairs: {\n type: 'x',\n },\n },\n legend: {\n position: 'top-left',\n },\n isStack: false,\n});\n"]}
|
package/esm/plots/line/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
|
+
import { isNil } from '@antv/util';
|
|
2
3
|
import { Plot } from '../../core/plot';
|
|
4
|
+
import { findViewById } from '../../utils';
|
|
3
5
|
import { adaptor, meta } from './adaptor';
|
|
4
|
-
import { DEFAULT_OPTIONS } from './constants';
|
|
6
|
+
import { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';
|
|
5
7
|
import './interactions';
|
|
6
8
|
var Line = /** @class */ (function (_super) {
|
|
7
9
|
__extends(Line, _super);
|
|
@@ -25,8 +27,13 @@ var Line = /** @class */ (function (_super) {
|
|
|
25
27
|
Line.prototype.changeData = function (data) {
|
|
26
28
|
this.updateOption({ data: data });
|
|
27
29
|
var _a = this, chart = _a.chart, options = _a.options;
|
|
30
|
+
var yField = options.yField;
|
|
28
31
|
meta({ chart: chart, options: options });
|
|
29
32
|
this.chart.changeData(data);
|
|
33
|
+
var pointView = findViewById(this.chart, POINT_VIEW_ID);
|
|
34
|
+
if (pointView) {
|
|
35
|
+
pointView.changeData(data.filter(function (d) { return !isNil(d[yField]); }));
|
|
36
|
+
}
|
|
30
37
|
};
|
|
31
38
|
/**
|
|
32
39
|
* 获取 折线图 默认配置
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/line/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/line/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,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'@antv/util';\nimport { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { findViewById } from '../../utils';\nimport { LineOptions } from './types';\nimport { adaptor, meta } from './adaptor';\nimport { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';\nimport './interactions';\n\nexport type { LineOptions };\n\nexport class Line extends Plot<LineOptions> {\n /**\n * 获取 折线图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<LineOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public type: string = 'line';\n\n /**\n * @override\n * @param data\n */\n public changeData(data: LineOptions['data']) {\n this.updateOption({ data });\n const { chart, options } = this;\n const { yField } = options;\n meta({ chart, options });\n this.chart.changeData(data);\n const pointView = findViewById(this.chart, POINT_VIEW_ID);\n if (pointView) {\n pointView.changeData(data.filter((d) => !isNil(d[yField])));\n }\n }\n\n /**\n * 获取 折线图 默认配置\n */\n protected getDefaultOptions() {\n return Line.getDefaultOptions();\n }\n\n /**\n * 获取 折线图 的适配器\n */\n protected getSchemaAdaptor(): Adaptor<LineOptions> {\n return adaptor;\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
2
|
import { each, findIndex } from '@antv/util';
|
|
3
3
|
import { InteractionAction } from '@antv/g2';
|
|
4
|
+
import { findGeometry } from '../../../utils';
|
|
4
5
|
var MarkerActiveAction = /** @class */ (function (_super) {
|
|
5
6
|
__extends(MarkerActiveAction, _super);
|
|
6
7
|
function MarkerActiveAction() {
|
|
@@ -12,22 +13,18 @@ var MarkerActiveAction = /** @class */ (function (_super) {
|
|
|
12
13
|
if (evt.data) {
|
|
13
14
|
// items: 数组对象,当前 tooltip 显示的每条内容
|
|
14
15
|
var items_1 = evt.data.items;
|
|
15
|
-
var
|
|
16
|
-
each(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
element.setState('active', active);
|
|
20
|
-
});
|
|
16
|
+
var point = findGeometry(view, 'point');
|
|
17
|
+
each(point.elements, function (element) {
|
|
18
|
+
var active = findIndex(items_1, function (item) { return item.data === element.data; }) !== -1;
|
|
19
|
+
element.setState('active', active);
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
23
|
MarkerActiveAction.prototype.reset = function () {
|
|
25
24
|
var view = this.getView();
|
|
26
|
-
var
|
|
27
|
-
each(
|
|
28
|
-
|
|
29
|
-
element.setState('active', false);
|
|
30
|
-
});
|
|
25
|
+
var point = findGeometry(view, 'point');
|
|
26
|
+
each(point.elements, function (element) {
|
|
27
|
+
element.setState('active', false);
|
|
31
28
|
});
|
|
32
29
|
};
|
|
33
30
|
MarkerActiveAction.prototype.getView = function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker-active.js","sourceRoot":"","sources":["../../../../src/plots/line/interactions/marker-active.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"marker-active.js","sourceRoot":"","sources":["../../../../src/plots/line/interactions/marker-active.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAQ,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;IAAwC,sCAAiB;IAAzD;;IA0BA,CAAC;IAzBQ,mCAAM,GAAb;QACE,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/B,IAAI,GAAG,CAAC,IAAI,EAAE;YACZ,iCAAiC;YACzB,IAAA,OAAK,GAAK,GAAG,CAAC,IAAI,MAAb,CAAc;YAC3B,IAAM,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC1C,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAC,OAAO;gBAC3B,IAAM,MAAM,GAAG,SAAS,CAAC,OAAK,EAAE,UAAC,IAAI,IAAK,OAAC,IAAY,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,EAAnC,CAAmC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtF,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAEM,kCAAK,GAAZ;QACE,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAM,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAC,OAAO;YAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,oCAAO,GAAf;QACE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IACH,yBAAC;AAAD,CAAC,AA1BD,CAAwC,iBAAiB,GA0BxD","sourcesContent":["import { each, findIndex } from '@antv/util';\nimport { InteractionAction, View } from '@antv/g2';\nimport { findGeometry } from '../../../utils';\n\nexport class MarkerActiveAction extends InteractionAction {\n public active() {\n const view = this.getView();\n const evt = this.context.event;\n if (evt.data) {\n // items: 数组对象,当前 tooltip 显示的每条内容\n const { items } = evt.data;\n const point = findGeometry(view, 'point');\n each(point.elements, (element) => {\n const active = findIndex(items, (item) => (item as any).data === element.data) !== -1;\n element.setState('active', active);\n });\n }\n }\n\n public reset() {\n const view = this.getView();\n const point = findGeometry(view, 'point');\n each(point.elements, (element) => {\n element.setState('active', false);\n });\n }\n\n private getView(): View {\n return this.context.view;\n }\n}\n"]}
|
package/esm/utils/geometry.js
CHANGED
|
@@ -5,7 +5,8 @@ import { reduce, get } from '@antv/util';
|
|
|
5
5
|
* @param type
|
|
6
6
|
*/
|
|
7
7
|
export function findGeometry(view, type) {
|
|
8
|
-
|
|
8
|
+
var geometries = getAllGeometriesRecursively(view);
|
|
9
|
+
return geometries.find(function (g) { return g.type === type; });
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* 获取 View 的 所有 elements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/utils/geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,IAAY;IACnD,
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/utils/geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,IAAY;IACnD,IAAM,UAAU,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,UAAC,CAAW,IAAK,OAAA,CAAC,CAAC,IAAI,KAAK,IAAI,EAAf,CAAe,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAU;IACvC,OAAO,MAAM,CACX,IAAI,CAAC,UAAU,EACf,UAAC,CAAY,EAAE,QAAkB;QAC/B,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAU;IAClD,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE;QAC1C,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;KAC7B;IAED,OAAO,MAAM,CACX,IAAI,CAAC,KAAK,EACV,UAAC,GAAc,EAAE,OAAa;QAC5B,OAAO,GAAG,CAAC,MAAM,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC,EACD,cAAc,CAAC,IAAI,CAAC,CACrB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAU;IACpD,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE;QAC1C,OAAO,IAAI,CAAC,UAAU,CAAC;KACxB;IAED,OAAO,MAAM,CACX,IAAI,CAAC,KAAK,EACV,UAAC,GAAe,EAAE,OAAa;QAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC,EACD,IAAI,CAAC,UAAU,CAChB,CAAC;AACJ,CAAC","sourcesContent":["import { Geometry, View, Element } from '@antv/g2';\nimport { reduce, get } from '@antv/util';\n\n/**\n * 在 View 中查找第一个指定 type 类型的 geometry\n * @param view\n * @param type\n */\nexport function findGeometry(view: View, type: string): Geometry {\n const geometries = getAllGeometriesRecursively(view);\n return geometries.find((g: Geometry) => g.type === type);\n}\n\n/**\n * 获取 View 的 所有 elements\n */\nexport function getAllElements(view: View): Element[] {\n return reduce(\n view.geometries,\n (r: Element[], geometry: Geometry) => {\n return r.concat(geometry.elements);\n },\n []\n );\n}\n\n/**\n * 递归获取 View 的 所有 elements, 包括 View 的子 View\n */\nexport function getAllElementsRecursively(view: View): Element[] {\n if (get(view, ['views', 'length'], 0) <= 0) {\n return getAllElements(view);\n }\n\n return reduce(\n view.views,\n (ele: Element[], subView: View) => {\n return ele.concat(getAllElementsRecursively(subView));\n },\n getAllElements(view)\n );\n}\n\n/**\n * 递归获取 View 的 所有 geometries, 包括 View 的子 View\n */\nexport function getAllGeometriesRecursively(view: View): Geometry[] {\n if (get(view, ['views', 'length'], 0) <= 0) {\n return view.geometries;\n }\n\n return reduce(\n view.views,\n (ele: Geometry[], subView: View) => {\n return ele.concat(subView.geometries);\n },\n view.geometries\n );\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const version = "2.4.
|
|
1
|
+
export declare const version = "2.4.2";
|
|
2
2
|
import * as G2 from '@antv/g2';
|
|
3
3
|
export { G2 };
|
|
4
4
|
import { registerLocale } from './core/locale';
|
|
@@ -88,6 +88,14 @@ export { Mix as Mix } from './plots/mix';
|
|
|
88
88
|
export type { MixOptions } from './plots/mix';
|
|
89
89
|
export { Facet } from './plots/facet';
|
|
90
90
|
export type { FacetOptions } from './plots/facet';
|
|
91
|
+
/** 提供一些工具方法 */
|
|
92
|
+
import { findGeometry, getAllGeometriesRecursively, findViewById } from './utils';
|
|
93
|
+
declare const Util: {
|
|
94
|
+
findGeometry: typeof findGeometry;
|
|
95
|
+
findViewById: typeof findViewById;
|
|
96
|
+
getAllGeometriesRecursively: typeof getAllGeometriesRecursively;
|
|
97
|
+
};
|
|
98
|
+
export { Util };
|
|
91
99
|
/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */
|
|
92
100
|
export { flow, measureTextWidth } from './utils';
|
|
93
101
|
/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */
|