简体   繁体   中英

Create Highchart (Column chart) and read data from external json file

I have to create a column chart in my project using Highchart.I have JSON file that contain some data look like:

{
    "meta": [
        "rectime",
        "strid",
        "ambt",
        "stri",
        "b1",
        "b2",
        "b3",
        "b4"
    ],
    "data": [
        [
            1377597739,
            1,
            0,
            77,
            816,
            13791,
            13794,
            13945
        ],
        [
            1377597739,
            2,
            0,
            0,
            816,
            13744,
            13725,
            13898
        ]
    ]
}

May anyone can suggest me about what should I do.

ThanKs all helping

after you recieve the response (I mean the JSON) in success call back pass the response.data to a routine which will parse this JSON data as accepted by Highcharts.

series:[{
name: 'series 1'
data: [1,2,4,5,6,74]
},{
name: 'series 2'
data: [1,2,4,5,6,74]
},{
name: 'series 3'
data: [1,2,4,5,6,74]
}]

you can exclude name if you don't want to give a specific name to every series. although highcharts generates unique name for every series.

to get the column chart set the type to column.

chart:{
type: 'column'
}

Try the help files on HighCharts, this link takes you to the json help page

http://www.highcharts.com/docs/working-with-data/preprocessing-data-from-a-file-csv-xml-json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM