Search code examples
jsonajaxparsingexternalflot

Json data parsing error for flot graph


datapie = [
{"label": "Running",  "data": [19.5], "color":"#e1ab0b"},
{"label": "Stopped",  "data": [4.5], "color":"#fe0000"},
{"label": "Terminated",  "data": [36.6], "color":'#93b40f"}
];

Getting an error TypeError: d is undefined

Please help!!

data is called using ajax


Solution

  • The data doesn't look to be in the correct format. It should look like this:

    datapie = [
    {label: "Running",  data: 19.5, color: '#e1ab0b'},
    {label: "Stopped",  data: 4.5, color: '#fe0000'},
    {label: "Terminated",  data: 36.6, color: '#93b40f'}
    ];
    

    Tutorial - http://digitalunion.osu.edu/2011/12/21/make-graphs-and-charts-with-jquery-using-flot-js-%E2%80%94-a-brief-tutorial/

    Fiddle - http://jsfiddle.net/Rnusy/5/