Incubator-echarts: magic

Created on 3 Dec 2018  ·  10Comments  ·  Source: apache/incubator-echarts

Most helpful comment

let option = Object.getOwnPropertyNames(chart._componentsMap) ;

/* 获取图表中 magicType 模拟line 点击 */
option.map(item => {
item.includes('toolbox') &&
chart._componentsMap[item]._features['magicType'].model.iconPaths.line.trigger('click');
});

可以实现效果

All 10 comments

这个 toolbox 中的 magicType 可以在渲染完成默认激活其中一个吗?

likethis

@cuijian-dexter 这个应该怎么使用 我看这个是切换触发事件用的,我希望的效果是手动触发点击事件。

this.chart.dispatchAction({
type: 'magictypechanged',
currentType: 'line'
});
这样用吗?

@kenghuo 是的,但是貌似不起作用了

@cuijian-dexter 大佬,还有没有其他办法?

let option = Object.getOwnPropertyNames(chart._componentsMap) ;

/* 获取图表中 magicType 模拟line 点击 */
option.map(item => {
item.includes('toolbox') &&
chart._componentsMap[item]._features['magicType'].model.iconPaths.line.trigger('click');
});

可以实现效果

let option = Object.getOwnPropertyNames(chart._componentsMap) ;

/* 获取图表中 magicType 模拟line 点击 */
option.map(item => {
item.includes('toolbox') &&
chart._componentsMap[item]._features['magicType'].model.iconPaths.line.trigger('click');
});

可以实现效果

大佬,试了图标倒是亮了,但是图表还是没切换过来呀呜呜呜

Was this page helpful?
0 / 5 - 0 ratings