apache / echarts

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

Echarts5 heatmap use dataset doesn't work #14904

Closed hujinbo closed 1 year ago

hujinbo commented 3 years ago

Version

5.1.1

Reproduction link

https://www.makeapie.com/editor.html?c=x7vS-g2fEU

Steps to reproduce

Use the following option to render the chart.

$.get('https://hujinbo.oss-cn-shenzhen.aliyuncs.com/tmp/china.json', function (geoJson) {
    echarts.registerMap('china', geoJson);

    myChart.setOption({
        mapSelect: {
            areaCode: [],
            granularity: 'country',
        },
        geo: [
            {
                map: 'china',
                roam: true,
                label: {
                    show: true,
                    color: '#555555',
                },
                itemStyle: {
                    areaColor: '#e6e8ea',
                    borderColor: '#fff',
                },
                emphasis: {
                    label: {
                        show: true,
                        color: '#555555',
                    },
                    itemStyle: {
                        areaColor: '#e6e8ea',
                        borderColor: '#fff',
                    },
                },
            },
        ],
        visualMap: {
            min: 58,
            max: 6300,
            calculable: true,
            splitNumber: 5,
            show: true,
            inRange: {
                color: ['#0099cc', '#0099ff'],
            },
            type: 'continuous',
            text: null,
        },
        series: {
            map: 'china',
            type: 'heatmap',
            coordinateSystem: 'geo',
            encode: {
                lng: 1,
                lat: 2,
                x: 0,
                y: 3,
            },
            pointSize: 20,
            blurSize: 20,
        },
        dataset: [
            {
                dimensions: ['province', 'lng', 'lat', 'l_tmp'],
                source: [
                    ['province', 'lng', 'lat', 'l_tmp'],
                    ['浙江', 120.153576, 30.287459, 2703],
                    ['西藏', 91.132212, 29.660361, 320],
                    ['北京', 116.405285, 39.904989, 167],
                    ['广西', 108.320004, 22.82402, 4249],
                    ['广东', 113.280637, 23.125178, 6036],
                    ['山西', 112.549248, 37.857014, 1714],
                    ['台湾', 121.509062, 25.044332, 898],
                    ['黑龙江', 126.642464, 45.756967, 501],
                    ['福建', 119.306239, 26.075302, 3033],
                    ['香港', 114.173355, 22.320048, 293],
                    ['河南', 113.665412, 34.757975, 3231],
                    ['青海', 101.778916, 36.623178, 58],
                    ['内蒙古', 111.670801, 40.818311, 594],
                    ['河北', 114.502461, 38.045474, 1757],
                    ['海南', 110.33119, 20.031971, 6204],
                    ['重庆', 106.504962, 29.533155, 212],
                    ['安徽', 117.283042, 31.86119, 3464],
                    ['新疆', 87.617733, 43.792818, 1632],
                    ['澳门', 113.54909, 22.198951, 258],
                    ['湖南', 112.982279, 28.19409, 3044],
                    ['吉林', 125.3245, 43.886841, 507],
                    ['四川', 104.065735, 30.659462, 4338],
                    ['宁夏', 106.278179, 38.46637, 550],
                    ['天津', 117.190182, 39.125596, 280],
                    ['江西', 115.892151, 28.676493, 3110],
                    ['贵州', 106.713478, 26.578343, 955],
                    ['辽宁', 123.429096, 41.796767, 1680],
                    ['江苏', 118.767413, 32.041544, 2834],
                    ['陕西', 108.948024, 34.263161, 1785],
                    ['上海', 121.472644, 31.231706, 220],
                    ['湖北', 114.298572, 30.584355, 2911],
                    ['山东', 117.000923, 36.675807, 3234],
                    ['甘肃', 103.823557, 36.058039, 1444],
                    ['云南', 102.712251, 25.040609, 3352],
                ],
            },
        ],
    });
});

Animation

What is expected?

Use dataset to render normally.

What is actually happening?

Heatmap cannot be displayed normally, and the console reports an error:

Uncaught TypeError: Cannot read property 'index' of undefined
    at VM429 echarts.min.js:45
    at Array.map (<anonymous>)
    at O (VM429 echarts.min.js:35)
    at t.each (VM429 echarts.min.js:45)
    at t.mapArray (VM429 echarts.min.js:45)
    at e._renderOnGeo (VM429 echarts.min.js:45)
    at e.render (VM429 echarts.min.js:45)
    at t.progress (VM429 echarts.min.js:45)
    at t._doProgress (VM429 echarts.min.js:45)
    at t.perform (VM429 echarts.min.js:45)

Normal use in ecarts4.

echarts-bot[bot] commented 3 years ago

Hi! We've received your issue and please be patient to get responded. 🎉 The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that it contains a minimum reproducible demo and necessary images to illustrate. Otherwise, our committers will ask you to do so.

A minimum reproducible demo should contain as little data and components as possible but can still illustrate your problem. This is the best way for us to reproduce it and solve the problem faster.

You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical question.

If you are interested in the project, you may also subscribe our mailing list.

Have a nice day! 🍵

plainheart commented 3 years ago

It seems to be working if we only set as follows,

encode: {
    lng: 1,
    lat: 2,
    value: 3
}
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] commented 1 year ago

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!