ecomfe / echarts-wordcloud

Word Cloud extension based on Apache ECharts and wordcloud2.js
1.68k stars 708 forks source link

echarts 4.0.3不支持该插件吗 #63

Open xuchao008 opened 6 years ago

xuchao008 commented 6 years ago

代码如下(直接黏贴即可用):

<html>
    <head>
        <meta charset="utf-8">
            <script src="https://cdn.bootcss.com/echarts/4.0.3/echarts.simple.js">
            </script>
            <script src="../dist/echarts-wordcloud.js">
            </script>
        </meta>
    </head>
    <body>
        <style>
            html, body, #main {
                width: 100%;
                height: 100%;
                margin: 0;
            }
        </style>
        <div id="main">
        </div>
        <script>
            var chart = echarts.init(document.getElementById('main'));
            var option = {
                tooltip: {},
                series: [ {
                    type: 'wordCloud',
                    gridSize: 2,
                    sizeRange: [12, 50],
                    rotationRange: [-90, 90],
                    shape: 'pentagon',
                    width: 600,
                    height: 400,
                    drawOutOfBound: true,
                    textStyle: {
                        normal: {
                            color: function () {
                                return 'rgb(' + [
                                    Math.round(Math.random() * 160),
                                    Math.round(Math.random() * 160),
                                    Math.round(Math.random() * 160)
                                ].join(',') + ')';
                            }
                        },
                        emphasis: {
                            shadowBlur: 10,
                            shadowColor: '#333'
                        }
                    },
                    data: data
                } ]
            };

            chart.setOption(option);

            window.onresize = chart.resize;
        </script>
    </body>
</html>

报错信息为,应该是 echarts 的 utils 为空值导致。

期望: 能得以解决,或找出问题原因。