简体   繁体   中英

Highstock don't draw any

I have a function called data(), this function write with echo $result."<br>"; this (data obtained from a database):

[20010426000000, 1],
[20010820000000, 1],
[20011201000000, 1],
[20020718000000, 1],

And i have the function to draw the highstock:

$(function() {
        // Create the chart
        $('#lineasAc').highcharts('StockChart', {
          ...
          name: 'Sales',
          data: [ 
            //HERE IS THE PROBLEM
          ],
        ...

If i put manually the result of the function works:

data: [        
  [20010426000000, 1],
  [20010820000000, 1],
  [20011201000000, 1],
  [20020718000000, 1],
],

But if i call the function don't work:

data: [ 
  <? echo data();?>
],

I tried to put the function inside the data without function and do echo $result."<br>"; , also tried put <?data();?> , etc. Definitely i tried all of i know

Any idea?

Thanks!

I think the problem may be with your data() function. If it outputs
tags, then these will be included in your highcharts data, and won't be valid json. You should only echo the data:

echo $result;

i put this in the data:

  <?for ($i=1;$i<=$limit_acept;$i++){?>
       <?=$result[$i];?>
  <?}?>

I make a variable to asign to $result, and now with the bucle i print the data :)

Thanks everyone!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM