开发者

What's the correct .csv format to make a pie chart in Highcharts?

I have external data that I'd like to make into a pie chart with Highchart. I want to dump the data into a .csv file, but what is the format?

This documentation only shows how to format .csv files for bar graphs: http://highcharts.com/documentation/how-to-use#preprocessi开发者_开发技巧ng

What if I want to make a pie chart?


Actually, there is no correct csv format for highcharts. Highcharts only accepts data in one of these three formats. The goal of the data-preprocessing is to transform the data into a supported javascript array format.

Quoting the reference:

data : Array An array of data points for the series. The points can be given in three ways:

  1. A list of numerical values. In this case, the numberical values will be interpreted and y values, and x values will be automatically calculated, either starting at 0 and incrementing by 1, or from pointStart and pointInterval given in the plotOptions. If the axis is has categories, these will be used. Example:

    data: [0, 5, 3, 5]
    
  2. A list of arrays with two values. In this case, the first value is the x value and the second is the y value. If the first value is a string, it is applied as the name of the point, and the x value is incremented following the above rules. Example:

    data: [[5, 2], [6, 3], [8, 2]]
    
  3. A list of object with named values. In this case the objects are point configuration objects as seen under options.point. Example:

    data: [{
        name: 'Point 1',
        color: '#00FF00',
        y: 0
    }, {
        name: 'Point 2',
        color: '#FF00FF',
        y: 5
    }]
    

Defaults to "".


Found the answer on Highcharts' forum:

http://highslide.com/forum/viewtopic.php?f=9&t=8614&hilit=pie+chart+.csv

Make sure you don't have an extra new line at the end of your .csv file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜