From e8d05d16fc388c525be46366e1646c88b09a1a72 Mon Sep 17 00:00:00 2001 From: simaQ Date: Thu, 12 Mar 2020 18:18:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=86=20Util=20=E5=9C=A8=E4=BB=8E?= =?UTF-8?q?=20core.ts=20=E7=A7=BB=E5=88=B0=20src/index.ts=20=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/gallery/pie/demo/pie3.ts | 20 ++++++++++++++------ examples/interaction/others/demo/meta.json | 8 ++++++++ src/core.ts | 9 --------- src/index.ts | 11 +++++++++++ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/examples/gallery/pie/demo/pie3.ts b/examples/gallery/pie/demo/pie3.ts index f0aa283272..8a1cbcac49 100644 --- a/examples/gallery/pie/demo/pie3.ts +++ b/examples/gallery/pie/demo/pie3.ts @@ -1,4 +1,4 @@ -import { Chart } from '@antv/g2'; +import { Chart, Util } from '@antv/g2'; const data = [ { type: '一线城市', value: 0.19 }, @@ -12,9 +12,10 @@ const chart = new Chart({ height: 500, }); chart.data(data); -chart.legend(false); +//chart.legend(false); chart.coordinate('theta', { radius: 0.75, + innerRadius: 0.4 }); chart.tooltip({ showMarkers: false @@ -26,6 +27,16 @@ const interval = chart .position('value') .color('type', ['#063d8a', '#1770d6', '#47abfc', '#38c060']) .style({ opacity: 0.4 }) + .state({ + active: { + style: (element) => { + const shape = element.shape; + return { + matrix: Util.zoom(shape, 1.1), + } + } + } + }) .label('type', (val) => { const opacity = val === '四线及以下' ? 1 : 0.5; return { @@ -43,10 +54,7 @@ const interval = chart }; }); -chart.interaction('element-single-selected'); +chart.interaction('legend-active'); chart.render(); -// 默认第一个选中 -const elements = interval.elements; -elements[0].setState('selected', true); diff --git a/examples/interaction/others/demo/meta.json b/examples/interaction/others/demo/meta.json index c17520d00d..c749357ec2 100644 --- a/examples/interaction/others/demo/meta.json +++ b/examples/interaction/others/demo/meta.json @@ -27,6 +27,14 @@ "en": "multipe view‘s tooltip" }, "screenshot": "https://gw.alipayobjects.com/mdn/rms_f5c722/afts/img/A*s-JWTrKjUP4AAAAAAAAAAABkARQnAQ" + }, + { + "filename": "pie-legend.ts", + "title": { + "zh": "饼图图例联动交互式", + "en": "pie chart legend" + }, + "screenshot": "https://gw.alipayobjects.com/mdn/rms_f5c722/afts/img/A*s-JWTrKjUP4AAAAAAAAAAABkARQnAQ" } ] } diff --git a/src/core.ts b/src/core.ts index 9729ee3514..c1ee183b0c 100644 --- a/src/core.ts +++ b/src/core.ts @@ -43,13 +43,4 @@ export { registerEngine, getEngine } from './engine'; // 注册动画函数 export { registerAnimation, getAnimation } from './animate/animation'; -// 一些工具方法导出 -import { rotate, translate, zoom, transform } from './util/transform'; -export const Util = { - translate, - rotate, - zoom, - transform, -}; - export { LAYER, DIRECTION } from './constant'; diff --git a/src/index.ts b/src/index.ts index e7f953f94c..7b43ea0e86 100644 --- a/src/index.ts +++ b/src/index.ts @@ -598,3 +598,14 @@ declare module './chart/view' { } export * from './core'; +// 一些工具方法导出 +import { getAngle, polarToCartesian } from './util/graphics'; +import { rotate, transform, translate, zoom } from './util/transform'; +export const Util = { + translate, + rotate, + zoom, + transform, + getAngle, + polarToCartesian, +};