Echarts : Uncaught Error: Component series.force not exists. Load it first

Echarts : Uncaught Error: Component series.force not exists. Load it first

我想用echarts做一个Data Visualization Force布局,当我按照步骤设置所有选项时,出现错误,说

Uncaught Error: Component series.force not exists. Load it first

我想可能是javascript出错了,所以我换了另一个版本的echarts.js,但是错误仍然存​​在,有人帮我吗?

顺便说一句,这是我在 Whosebug 上的第二个 post,仍在学习如何使用这个平台,所以如果您认为我可以更好地描述问题,请告诉我,谢谢。

这是我的 javascript cdn

    <script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0-release/echarts.js"></script>

这是我的主要代码

<div id="main" style="width: 1280px;height:800px;"></div>
<script>
    // init
    var myChart = echarts.init(document.getElementById('main'));

    // if the website is still loading, show the animation
    // myChart.showLoading(); 

    var data = data_format(jdata);

    var option = {
        title : {
            text : 'test',  // this field will connect to the book name
        }, 
        tooltip : {}, 
        toolbox : {
            show : true, 
            feature : {
                saveAsImage : {
                    title : 'save as image',
                    show : true, 
                    type : 'png'
                }
            }
        }, 
        legend : {}, 
        series : [
            {
                type : 'force', 
                name : 'test', 
                ribbonType : false, 
                categories : [
                    {
                        name : 'person'
                    }
                ], 
                itemStyle : {
                    normal : {
                        label : {
                            show : true, 
                            textStyle : {
                                color : 'black'
                            }
                        }, 
                        nodeStyle : {

                        }
                    }
                }, 
                minRadius : 15, 
                maxRadius : 25, 
                gravity : 1, 
                scaling : 1, 
                linkSymbol : 'arrow', 
                steps : 10, 
                coolDown : 1, 
                nodes : data.nodes,
                links : data.links
            }
        ]
    }

    // setup all option
    myChart.setOption(option);
</script>

根据docs(点击左侧菜单的系列节点打开可以看到所有类型)series没有force类型
有效类型是:例如bargraph

也许这个 example will help you. It uses a series of type graph which has a force 对象。

例如来自示例:

series : [
    {
        type: 'graph',
        layout: 'force',
        force: {
            repulsion: 100
        }
        ...