Highcharts returning error 14

后端 未结 1 1103
猫巷女王i
猫巷女王i 2020-12-02 02:09

Am trying to draw a pie chart with highcharts, after spending hours trying to figure out how process a JSON string into a javascript array. This is what i have



        
相关标签:
1条回答
  • 2020-12-02 02:23

    Highcharts Error #14 clearly says

    String value sent to series.data, expected Number his happens if you pass in a string as a data point

    data point is the yValue, if your serie.data is of the form

    [y1,y2,y2] 
    

    or

    [[x1,y1],[x2,y2],[x3,y3]]
    

    or

    [
    { x : x1 ,y : y1 },
    { x : x2 ,y : y2 },
    { x : x3 ,y : y3 }
    ]
    

    In any of the above forms the type of data stored in y1,y2 & y3 should be numeric. You can achieve this my simply using the parseFloat() or parseInt() in javascript

    var serie1 = usage_data.map( function(e) {
                return [e.gateway, parseFloat(e.val)];
    });
    

    or do it in the server technology that you are using
    In (PHP 4 >= 4.2.0, PHP 5) floatval() can be used

    $float_value_of_var = floatval("123.456");
    
    0 讨论(0)
提交回复
热议问题