0

我尝试绘制日期和值,这是我的代码:

function getDaily(vsatid){
$.ajax({
     type: "POST",
     url: "daily_graph.php",
     data: "id=" + vsatid,
     success: function(obj1){
     options.series[0].data = obj1.date;
     options.series[1].data = obj1.ebno;
     }
var chart = new Highcharts.Chart(options);  
});}

谁能告诉我我想如何推动这个系列,这样我就可以得到 x 作为日期时间和 y 作为值。下面是我使用 json_encode 从 mysql 数据库解析到 json 的数据。

[{"date":"1363700566","ebno":8.04},{"date":"1363701638","ebno":8.02},{"date":"1363705226","ebno":7.93},{ "日期":"1363709087","ebno":7.65},{"日期":"1363712661","ebno":7.69},{"日期":"1363716221","ebno":7.44},{"日期":"1363719708","ebno":7.19},{"date":"1363723254","ebno":6.97},{"date":"1363726853","ebno":6.99},{"date": "1363730481","ebno":7.04},{"date":"1363734045","ebno":6.92},{"date":"1363737697","ebno":7.07},{"date":"1363741201 ","ebno":7.27},{"日期":"1363744878","ebno":7.35},{"date":"1363748625","ebno":7.48},{"date":"1363752211","ebno":0},{"date":"1363755741" ,"ebno":7.69},{"date":"1363759347","ebno":7.76},{"date":"1363762894","ebno":7.83},{"date":"1363766640"," ebno":7.82},{"date":"1363770121","ebno":7.82},{"date":"1363773789","ebno":7.69},{"date":"1363777209","ebno" :6.78},{"日期":"1363780874","ebno":8.15}]"1363755741","ebno":7.69},{"date":"1363759347","ebno":7.76},{"date":"1363762894","ebno":7.83},{"date":"1363766640 ","ebno":7.82},{"date":"1363770121","ebno":7.82},{"date":"1363773789","ebno":7.69},{"date":"1363777209", "ebno":6.78},{"日期":"1363780874","ebno":8.15}]"1363755741","ebno":7.69},{"date":"1363759347","ebno":7.76},{"date":"1363762894","ebno":7.83},{"date":"1363766640 ","ebno":7.82},{"date":"1363770121","ebno":7.82},{"date":"1363773789","ebno":7.69},{"date":"1363777209", "ebno":6.78},{"日期":"1363780874","ebno":8.15}]{“日期”:“1363777209”,“ebno”:6.78},{“日期”:“1363780874”,“ebno”:8.15}]{“日期”:“1363777209”,“ebno”:6.78},{“日期”:“1363780874”,“ebno”:8.15}]

所有答案都将不胜感激..关于马鲁斯

4

3 回答 3

0

每个数据点应定义为:

Var mydata = [[1363700566000,8.04], [1363701638,8.02] ]

或者,您可以使用此表单指定更多点选项:

Var my data = [{x:1363700566000,y:8.04}, {x:1363701638,y:8.02} ]

请注意,日期以毫秒为单位,因此您需要将您的日期乘以 1000。

Options.series[0].data = mydata
于 2013-03-20T14:28:53.137 回答
0
try
chart.series[0].addPoint(obj1.date);
chart.series[1].addpoint(obj1.ebno)


//     options.series[0].data = obj1.date;
//     options.series[1].data = obj1.ebno;

by using two series u will get 2 diff x values for two diff series
if u want to get x,y val for same series 

parse the obj1 to json . or 
add

               type:"GET",
                   url: "delete",
            //       dataType:"json",
                       data:chart.series[0].data,

try
 $.each(obj1,function(index,object){
 chart.series[0].addPoint(object);
 });                
  // will iterate all the objects and add it to series

where obj1 should contain
[{"x":"1363700566","y":8.04}
于 2013-03-21T12:17:05.927 回答
0

您的日期应该是时间戳,因此您应该使用 parseFloat() 函数将字符串转换为数字,然后乘以 1000 以实现适当的 JavaScript 时间戳格式。

于 2013-03-20T14:52:22.423 回答