apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.44k stars 19.61k forks source link

使用lines时,coords中出现Cannot read property 'dataToPoint' of undefined #6983

Closed EarlEcho closed 5 years ago

EarlEcho commented 6 years ago

One-line summary [问题简述]

在使用map和lines完成数据迁移功能时,lines中的data[i].coords熟悉出现Cannot read property 'dataToPoint' of undefined"的报错

Version & Environment [版本及环境]

Expected behaviour [期望结果]:期望解决这个问题,并使程序正常显示。

ECharts option [ECharts配置项]

option = {
tooltip: {
                        show: true,
                        padding: 0

                    },
                    legend: {
                        show: false,
                        orient: 'vertical',
                        top: 'auto',
                        left: 'right',
                        data: ['中国', '线路'],
                        textStyle: {
                            color: '#fff'
                        }
                    },
                    series: [
                        {
                            name: "中国",
                            type: "map",
                            mapType: "china",
                            zoom: 1.25,
                            selectedMode: false,
                            itemStyle: {
                                normal: {
                                    areaColor: "#103a65",
                                    borderWidth: 1,
                                    borderColor: "#1B1F23",
                                    label: {
                                        show: true
                                    }
                                },
                                emphasis: {
                                    areaColor: "#2A333D",
                                    label: {
                                        show: true
                                    }
                                }
                            },
                            label: {
                                normal: {
                                    show: true,
                                    color: '#fff'
                                },
                                emphasis: {
                                    show: true,
                                    color: '#fff'
                                }
                            },
                            data: [
                                {name: '北京', value: this.randomData()},
                                {name: '天津', value: this.randomData()},
                                {name: '上海', value: this.randomData()},
                                {name: '重庆', value: this.randomData()},
                                {name: '河北', value: this.randomData()},
                                {name: '河南', value: this.randomData()},
                                {name: '云南', value: this.randomData()},
                                {name: '辽宁', value: this.randomData()},
                                {name: '黑龙江', value: this.randomData()},
                                {name: '湖南', value: this.randomData()},
                                {name: '安徽', value: this.randomData()},
                                {name: '山东', value: this.randomData()},
                                {name: '新疆', value: this.randomData()},
                                {name: '江苏', value: this.randomData()},
                                {name: '浙江', value: this.randomData()},
                                {name: '江西', value: this.randomData()},
                                {name: '湖北', value: this.randomData()},
                                {name: '广西', value: this.randomData()},
                                {name: '甘肃', value: this.randomData()},
                                {name: '山西', value: this.randomData()},
                                {name: '内蒙古', value: this.randomData()},
                                {name: '陕西', value: this.randomData()},
                                {name: '吉林', value: this.randomData()},
                                {name: '福建', value: this.randomData()},
                                {name: '贵州', value: this.randomData()},
                                {name: '广东', value: this.randomData()},
                                {name: '青海', value: this.randomData()},
                                {name: '西藏', value: this.randomData()},
                                {name: '四川', value: this.randomData()},
                                {name: '宁夏', value: this.randomData()},
                                {name: '海南', value: this.randomData()},
                                {name: '台湾', value: this.randomData()},
                                {name: '香港', value: this.randomData()},
                                {name: '澳门', value: this.randomData()}
                            ],
                            markPoint: {
                                symbol: 'circle',
                                symbolSize: 8,
                                label: {
                                    normal: {
                                        show: false
                                    }
                                },
                                data: [
                                    {
                                        name: '广东',
                                        coord: [113.23, 23.16]
                                    }, {
                                        name: '深圳',
                                        coord: [114.07, 22.62]
                                    }, {
                                        name: '成都',
                                        coord: [102.56, 30.92]
                                    }, {
                                        name: '南京',
                                        coord: [118.78, 32.04]
                                    }, {
                                        name: '兰州',
                                        coord: [103.73, 35.03]
                                    }, {
                                        name: '武汉',
                                        coord: [114.31, 30.5]
                                    }, {
                                        name: '义乌',
                                        coord: [120.06, 29.32]
                                    }, {
                                        name: '抚顺',
                                        coord: [123.97, 41.97]
                                    }, {
                                        name: '拉萨',
                                        coord: [91.11, 30.97]
                                    }, {
                                        name: '曲靖',
                                        coord: [103.79, 25.51]
                                    }, {
                                        name: '嘉峪关',
                                        coord: [98.289152, 39.77313]
                                    }, {
                                        name: '张家口',
                                        coord: [114.87, 40.82]
                                    }, {
                                        name: '铜川',
                                        coord: [109.11, 35.09]
                                    }
                                ]
                            }
                        }, {
                            name: '线路',
                            type: 'lines',
                            zlevel: 2,
                            large: true,
                            effect: {
                                show: true,
                                constantSpeed: 50,
                                symbol: 'arrow',//ECharts 提供的标记类型包括 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
                                symbolSize: 10,
                                trailLength: 0,
                            },
                            lineStyle: {
                                normal: {
                                    color: '#F58158',
                                    width: 2,
                                    opacity: 0.6,
                                    curveness: 0.2
                                }
                            },
                            data: [
                                {
                                    coords: [
                                        [102.56, 30.92],
                                        [114.87, 40.82]
                                    ]
                                },
                                /* {fromName: "成都", toName: "铜川", coords: [[102.56, 30.92], [109.11, 35.09]]},
                                 {fromName: "成都", toName: "嘉峪关", coords: [[102.56, 30.92], [98.289152, 39.77313]]},
                                 {fromName: "成都", toName: "广东", coords: [[102.56, 30.92], [113.23, 23.16]]}*/
                            ]
                        }
                    ]
}

randomData: function () {
       return Math.round(Math.random() * 1000);
}

Other comments [其他信息]

我是在vue项目中使用的echarts, image image

报错如下: image

Dida1209 commented 6 years ago

我也出现了一样的问题,解决了吗?怎么解决的?

songlinn commented 6 years ago

我也遇到了这个问题.我的是在react 项目中出现的.代码如下


const chart = Echarts.init(container);
  Echarts.GLMap = map; // map = new mapboxgl.Map();
  chart.setOption({
    series: [{
      type: 'lines',
      coordinateSystem: 'GlMap',
      data: [
        [103.8414, 30.7312],
        [103.9636, 30.5031]
      ],
      lineStyle: {
        normal: {
          opacity: 0.05,
          width: 0.5,
          curveness: 0.5
        }
      },
      blendMode: 'lighter'
    }],
  });
`
断点调试发现在 linesLayout.js中 第七行 var coordSys = seriesModel.coordinateSystem; 
seriesModel没有coordinateSystem,而seriesModel.option中有coordinateSystem.
请问是我使用方式不对还是其他原因?
sdyk-jym commented 6 years ago

type: lines 改为 type: line 试试

baggiomygod commented 6 years ago

我也遇到这个问题,请问解决了吗? 我是用vue-charts是在linesLayout.js里coorSys.dataToPoint报错,其中coorSyS是null 不知道为何,

series:[{
    type:'lines',
    coordinateSystem:'bmap',
    data:[...],
    // ....
}]
zhang6685979 commented 6 years ago

@baggiomygod 你好 问题解决了么?

BL-Lac149597870 commented 6 years ago

@EarlEcho 请问问题解决了吗?

CccZss commented 6 years ago

我引入这个组件后可以了 require('echarts/lib/component/geo')

DorisOu commented 5 years ago

@all 大家解决了么?我在vue使用中也遇到这个报错

Ovilia commented 5 years ago

Please follow this example: http://gallery.echartsjs.com/editor.html?c=xBkrP1lbqG Tell me if it doesn't work.

hafrans commented 5 years ago

用bmap,我感觉缺少了bmap的插件,于是我尝试 import 'echarts/extension/bmap/bmap.js' 之后OK了,剩下的问题就是缺少BMap的API了

315133494 commented 5 years ago

刚了下,你的情况和我的一样,我刚刚解决了,可以参考下,若有不正确,欢迎指正 https://www.cnblogs.com/limn/p/10614926.html

woohaoshu commented 5 years ago

我也是lines在geo地图上可以显示飞线图,后来把geo换成bmap出了这个问题。 仔细研究了一下文档:https://echarts.baidu.com/option.html#series-lines.coordinateSystem 发现lines坐标系统默认选的geo,手动设置成bmap就ok了~

wjl-dev commented 4 years ago

确保引入了bmap.min.js,然后配置 coordinateSystem: 'bmap'就可以了,如果用的是bmap的话

sadofriod commented 3 years ago

使用require('echarts/lib/component/geo'),还需要再配置里面option加入 geo:{ ... }的相关配置。这样才能再echart渲染的时候使用geo组件,例如:

{"geo":{"map":"insideMap","label":{"emphasis":{"show":true,"color":"#fff"}},"roam":true,"itemStyle":{"normal":{"areaColor":"#323c48","borderColor":"#404a59"},"emphasis":{"areaColor":"#2a333d"}}},"series":[{"name":"map","type":"map","map":"insideMap"},{"type":"lines","name":"flyLine"}]}
chj-damon commented 3 years ago

为什么一定要用bmap。。。

chj-damon commented 3 years ago

Please follow this example: http://gallery.echartsjs.com/editor.html?c=xBkrP1lbqG Tell me if it doesn't work.

为什么现在echarts的demo里面关于地图和飞线图的例子全都是基于百度地图?没有纯地图的demo啊

HibernatingBear commented 3 years ago

我的理解是,要在地图上通过经纬度来绘制lines,必须要有坐标类型的地图,我添加了一个 geo 就不会报这个错了 楼上很多人用bmap的应该也是这个原因吧