Asad Rana
Asad Rana

Reputation: 1

Axis values from database in highchart

I am using following code to plot values of X and Y axis in series

chart.SetSeries(new []{ new Series {name ="first", Data=new Data(new object[,] {{0,0},{10,20},{30,40}})}});

now what i want is to use the values from database instead of predefining like above. Following is the code i am using to get axis values from database.

cmd=new sqlcommand("Select * from points",sc);
reader=cmd.ExecuteReader();
while(reader.Read())
{
   x_axis=reader["x_axis"].ToString();
   y_axis=reader["y_axis"].ToString();
}

Upvotes: 0

Views: 259

Answers (1)

Alexander Stepchkov
Alexander Stepchkov

Reputation: 755

You need to prepare an array of objects with named values and pass it to highcharts (e.g. as a String) Here goes an example of data:

data: [{
    x: 1,
    y: 9,
    name: "Point2",
    color: "#00FF00"
}, {
    x: 1,
    y: 1,
    name: "Point1",
    color: "#FF00FF"
}]

For more info check documentation

Upvotes: 1

Related Questions