score:1

Accepted answer

this correct answer for above question , i am using this and get above format

<php
    $sql = "select x_axis,y_axis from licence_chart ";
    $result9 = mysql_query($sql);
    $data9 = array();
    while ($row = mysql_fetch_array($result9)) 
        {
            $data9 = "'".$row['x_axis']."'".",".$row['y_axis'];
            $data[] = $data9;
        }   
    for($ii=0;$ii<count($data);$ii++)
        {
            echo "[".$data[$ii]."]," ;  
        }   
?> 

score:0

like the error says: http://www.highcharts.com/errors/14

highcharts error #14 string value sent to series.data, expected number

this happens if you pass in a string as a data point, for example in a setup like this:

series: [{ data: ["3", "5", "1", "6"] }]

highcharts expects the data values to be numbers. the most common reason for this is that data is parsed from csv or from a xml source, and the implementer forgot to run parsefloat on the parsed value.

for performance reasons internal type casting is not performed, and only the first value is checked (since 2.3).

your problem is your echo join($data1, "','");. the yaxis values cannot be a string. and it looks like you are just getting one giant string:

'safari','opera','firefox','ie','chrome','others10','6','40.5','20','10.6','0.5

by doing this join operation you are adding single quotes around your yaxis numbers. simply make it:

echo join($data1, ",");

this should fix part of your issue. if you had read the error page you would have seen this - not a knock on you, but highcharts has pretty great documentation and error reports.

to get this in the correct form you are also going to need to make distinct series elements with [name, yvalue]. what you have is just a string of [name, name, name,...., yval, yval, yval..].

how to parse that? up to you really. but why not just do a select '[''' + x_axis + '',' + convert(varchar(10), y_axis) + ']' from licence_chart then do a join like this:

echo join($data1, ",");

this should give you (not sure on mysql syntax on doing text concatenation with numbers so i leave that to you. this is in ms sql):

['safari', 6], ['opera', 40.5], ['firefox', 20], ['ie', 10.6], ['chrome', 0.5], ['others10', <some number...looks like it got cut off in your question>]

score:0

<?php

// set the json header header("content-type: text/json"); // the x value is the current javascript time, which is the unix time multiplied by 1000. $x = time() * 1000; // the y value is a random number $y = rand(0, 100); // create a php array and echo it as json $ret = array($x, $y); echo json_encode($ret); ?>

this is answer from highcharts install instructions


Related Query

More Query from same tag