Closed LukeCG closed 3 years ago
可以帮忙搞一个 live demo 吗?
@hustcc https://stackblitz.com/edit/react-tayrhk?file=src%2Findex.js
另外,请教一个问题,折线图我们可以通过chart.getXY方法获取某个数据的画布坐标点,然后通过chart.showTooltip方法达到图表初始化的时候自动展示某个点的Tooltip;那么如果是饼图的话,也就是坐标系是 'theta'的时候,我们有没有办法获取饼图中某个对应的坐标点呢🤔?饼图的时候用chart.getXY方法获取某个数据的画布坐标点是报错的
另外,再请教一个问题,G2中,有没有类似echarts中通过 调用 dispatchAction 来触发的事件的方式呢,在实际的项目中,这种通过代码主动去触发某个事件的需求还是蛮多的;
echarts中对dispatchAction的描述:https://echarts.apache.org/zh/api.html#echartsInstance.dispatchAction
通过dispatchAction实现的一个简单案例:https://gallery.echartsjs.com/editor.html?c=xEG1fyp-v 参数:
@hustcc https://stackblitz.com/edit/react-tayrhk?file=src%2Findex.js
另外,请教一个问题,折线图我们可以通过chart.getXY方法获取某个数据的画布坐标点,然后通过chart.showTooltip方法达到图表初始化的时候自动展示某个点的Tooltip;那么如果是饼图的话,也就是坐标系是 'theta'的时候,我们有没有办法获取饼图中某个对应的坐标点呢🤔?饼图的时候用chart.getXY方法获取某个数据的画布坐标点是报错的
另外,再请教一个问题,G2中,有没有类似echarts中通过 调用 dispatchAction 来触发的事件的方式呢,在实际的项目中,这种通过代码主动去触发某个事件的需求还是蛮多的;
echarts中对dispatchAction的描述:https://echarts.apache.org/zh/api.html#echartsInstance.dispatchAction
通过dispatchAction实现的一个简单案例:https://gallery.echartsjs.com/editor.html?c=xEG1fyp-v 参数:
ref: https://github.com/ant-design/ant-design-charts/issues/465
tooltip 重复的问题,我告诉一下原理:
tooltip 的 item 会将所有的图形的 item 取出来,然后根据 color 映射的颜色进行去重,而在这个 case 中,你设置有 style,所以无法感知 color。
解法:使用 customItems: () => {} 进行自己的去重逻辑。
chart.tooltip({
customItems: (items) => newItems(item)
,})
上代码: import { Chart } from '@antv/g2'; const data = [ { year: '12/01', value: 2623, dun: 3.3 }, { year: '12/02', value: 4099, dun: 0.5 }, { year: '12/03', value: 3430, dun: 2.7 }, { year: '12/04', value: 2924, dun: 1.2 }, { year: '12/05', value: 3500, dun: 2.5 }, { year: '12/06', value: 3800, dun: 2.3 }, { year: '12/07', value: 5918, dun: 1.3 } ]; const chart = new Chart({ container: 'doubleYLine', width: 580, height: 300, appendPadding: [30, 0, 0, 0], });
如果把双Y轴的 chart.area()或者chart.line()注释某一个就没有问题