Comments (16)
@yangdengxian 这块目前不太能确定是 ol 的问题还是 echarts 的问题,echarts 的事件目前无法响应了:https://codesandbox.io/s/zealous-shape-q32gb
from ol3echarts.
@yangdengxian AppndTo currently does not instantiate echarts, temporarily adding event listeners by delaying, and subsequently considering adding a loaded event to make callbacks.
from ol3echarts.
I'm a little confused, there is a instance about echarts in your native code I see
This is the native code
EChartsLayer.prototype.render = function render() {
if (!this.$container) {
this._createLayerContainer(this.$Map, this.$options);
this._resizeContainer();
}
if (!this.$chart) {
this.$chart = echarts.init(this.$container);
if (this.$chartOptions) {
this._registerMap();
this.$chart.setOption(this.reConverData(this.$chartOptions), false);
}
} else if (this._isVisible()) {
this.$chart.resize();
this.reRender();
}
};
Thank you
from ol3echarts.
@yangdengxian 确实会创建实例,但是在你appendTo的时候不会立即创建echarts 实例,你可以延时一下去添加事件监听。
__this.echartLayer.appendTo(__this.map);
//chart click event
setTimeout(() => {
__this.echartLayer.$chart.on('click', (evt) => {
console.log(evt);
});
}, 2 * 1000)
from ol3echarts.
@yangdengxian 确实会创建实例,但是在你appendTo的时候不会立即创建echarts 实例,你可以延时一下去添加事件监听。
__this.echartLayer.appendTo(__this.map); //chart click event setTimeout(() => { __this.echartLayer.$chart.on('click', (evt) => { console.log(evt); }); }, 2 * 1000)
哈哈,我以为你是国外程序员呢。
应该不是实例化时间差的问题,我调试你的源码,在创建完echarts实例后,绑定click事件,也不生效。
我想咨询一下,EChartsLayer这个类里,可以监听click事件吗,我好像也没找到。
我现在的需求就是点击拿到饼图或者柱状图的数据,能在echarts上点击获取是最合适的。
或者我自己再改造一下,谢谢你了
from ol3echarts.
@yangdengxian 不是类似于这样吗?link,ol-echarts 这个也是类似的,只要拿到 echarts 的实例,就能正常监听 😄
from ol3echarts.
@yangdengxian 不是类似于这样吗?link,ol-echarts 这个也是类似的,只要拿到 echarts 的实例,就能正常监听 😄
ol3Echarts这个echarts点击click事件能正常监听,切换到ol-echarts这个版本监听就不生效😄,我现在openlayers版本5.1.2,只能使用ol-echarts这版本,能麻烦看看吗,万分感谢
from ol3echarts.
@yangdengxian 不是类似于这样吗?link,ol-echarts 这个也是类似的,只要拿到 echarts 的实例,就能正常监听 😄
from ol3echarts.
@yangdengxian 这问题不太好定位,我本地测试没有问题,可以尝试降级一下 echarts 的版本到 4.2.1
from ol3echarts.
@sakitam-fdd 这问题不太好定位,我本地测试没有问题,可以尝试降级一下 echarts 的版本到 4.2.1
好的,太麻烦你了。谢谢了,我试试。
from ol3echarts.
@sakitam-fdd 这块目前不太能确定是 ol 的问题还是 echarts 的问题,echarts 的事件目前无法响应了:https://codesandbox.io/s/zealous-shape-q32gb
应该不是echarts版本问题,单独使用echarts监听click事件,生效的。猜测是不是与ol的事件机制冲突了,或者图层顺序有关,被遮盖无法点中。😄
from ol3echarts.
@yangdengxian 有兴趣可以看下实现原理, 目前的做法是放到 ol 实例化的容器的 ol-overlaycontainer
, 这个里面会进行事件透传,在之前版本 echarts 本身也是可以拦截到事件的,但是新版本不知道为什么不行了,这个可以考虑使用 ol 的事件手动触发。
from ol3echarts.
@sakitam-fdd 有兴趣可以看下实现原理, 目前的做法是放到 ol 实例化的容器的
ol-overlaycontainer
, 这个里面会进行事件透传,在之前版本 echarts 本身也是可以拦截到事件的,但是新版本不知道为什么不行了,这个可以考虑使用 ol 的事件手动触发。
好的,谢谢分享资料。还有讨论一个题外问题,echarts图表内容放在ol实例化容器的ol-overlaycontainer
中,假如其他overlay覆盖物,比如:ol-cesium,也会在同一ol-overlaycontainer
容器中。关闭cesium,设置ol-overlaycontainer
容器不可见,也会影响到ol-overlaycontainer
容器的所有要素。不知道楼主是否遇到这样的问题。总感觉ol将所有overlay要素放在同一个ol-overlaycontainer
容器下面,设计是否合理。不管怎么说,还是非常感谢楼主不辞辛苦,为我解答。还是得多看一下ol源码设计,谢谢楼主
from ol3echarts.
l3Echarts这个echarts点击click事件能正
我这边 ol3Echarts 也不能添加监听啊
from ol3echarts.
l3Echarts这个echarts点击click事件能正
我这边 ol3Echarts 也不能添加监听啊
收到,这块现在还在重构,需要一点时间
from ol3echarts.
@yangdengxian @xuxinkun0591 fixed link, 暂时添加了一个参数控制:
polyfillEvents: true, // 代理echrats图层的 mousedown mouseup click 事件
from ol3echarts.
Related Issues (20)
- echarts导入问题 HOT 2
- 在EchartsLayer上叠加openlayer图层是否可行 HOT 1
- coordinateSystem的问题
- lines飞线投影 HOT 1
- ECharts 5 support
- 大佬,文档是看不了吗,怎么没有参数和api介绍呢 HOT 1
- 请教~ new EChartsLayer 报错怎么回事 HOT 8
- appendTo方法报错 HOT 1
- ol-echarts V4.0.0添加GEO坐标系后,拖动全球地图后,坐标点散点消失 HOT 1
- ol8+ol-echarts4无法显示热力图,有大佬帮忙看下么🤗 HOT 1
- bug - map 销毁问题 HOT 1
- 使用北京地方坐标系,画lines图(航线图),看不见 HOT 1
- 有没有可能把L7封装到ol里面呢? HOT 1
- 似乎不支持 series.map 类型? HOT 1
- 拖动地图后数据没有完全加载 HOT 1
- mapBrowserPointerEvent HOT 1
- Cannot set property 'disposed' of null HOT 2
- Uncaught TypeError: EChartsLayer__default.default is not a constructor HOT 2
- Cannot read properties of undefined (reading 'transform') MapDraw.draw (MapDraw.js:210:32) HOT 5
- echarts geo maps are not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ol3echarts.