Skip to content

Commit

Permalink
feat: 将 Util 在从 core.ts 移到 src/index.ts 下
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ authored and hustcc committed Mar 13, 2020
1 parent 921a45f commit e8d05d1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
20 changes: 14 additions & 6 deletions examples/gallery/pie/demo/pie3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Chart } from '@antv/g2';
import { Chart, Util } from '@antv/g2';

const data = [
{ type: '一线城市', value: 0.19 },
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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);
8 changes: 8 additions & 0 deletions examples/interaction/others/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
9 changes: 0 additions & 9 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit e8d05d1

Please sign in to comment.