如何使用echarts和导入文件中的数据一起使用

时间:2021-10-22 23:15:13

http://echarts.baidu.com/doc/example/line2.html

http://echarts.baidu.com/doc/example/line2.html

The above example is a multiple line chart, but in the series part:

上面的例子是一个多线形图,但是在系列部分:

series : [

    {
        name:'邮件营销',
        type:'line',
        stack: '总量',
        data:[120, 132, 101, 134, 90, 230, 210]
    },
    {
        name:'联盟广告',
        type:'line',
        stack: '总量',
        data:[220, 182, 191, 234, 290, 330, 310]
    },
    {
        name:'视频广告',
        type:'line',
        stack: '总量',
        data:[150, 232, 201, 154, 190, 330, 410]
    },
    {
        name:'直接访问',
        type:'line',
        stack: '总量',
        data:[320, 332, 301, 334, 390, 330, 320]
    },
    {
        name:'搜索引擎',
        type:'line',
        stack: '总量',
        data:[820, 932, 901, 934, 1290, 1330, 1320]
    }
]

It already knows how many lines it has and the data is listed. I want to know if I use the data from an imported file, how can I draw a multiple line chart?

它已经知道它有多少行,并且列出了数据。我想知道如果我使用一个导入文件中的数据,我如何绘制一个多线形图?

1 个解决方案

#1


0  

Actually the "series" is a json object. You need to parse a valid json object by using HTTP request into your current page (you may want to use jQuery getJson method to communicate with your Java functions).

实际上,“系列”是一个json对象。您需要使用HTTP请求来解析有效的json对象(您可能希望使用jQuery getJson方法与Java函数通信)。

Next if your object is valid, the chart js engine will automatically draw lines and you dont need to worry about it.

接下来,如果您的对象是有效的,那么chart js引擎将自动绘制线条,您不需要担心它。

#1


0  

Actually the "series" is a json object. You need to parse a valid json object by using HTTP request into your current page (you may want to use jQuery getJson method to communicate with your Java functions).

实际上,“系列”是一个json对象。您需要使用HTTP请求来解析有效的json对象(您可能希望使用jQuery getJson方法与Java函数通信)。

Next if your object is valid, the chart js engine will automatically draw lines and you dont need to worry about it.

接下来,如果您的对象是有效的,那么chart js引擎将自动绘制线条,您不需要担心它。