php - Creating dynamic Highcharts based on an array -


to sort off cap i'm doing.. have loop creates table information pulled database. i've setup superglobal variable inside loop assigns 1 of table field values variable; part works no problem.

the problem when try call variable inside highcharts function, doesn't work. charts don't show up.

$(document).ready(function() {      var $container = $('$global_var');         highcharts.setoptions({             chart: {                 backgroundcolor: {                     lineargradient: [0, 0, 500, 500],                     stops: [                         [0, 'rgb(255, 255, 255)'],                         [1, 'rgb(240, 240, 255)']                         ]                 },                 borderwidth: 2,                 plotbackgroundcolor: 'rgba(255, 255, 255, .9)',                 plotshadow: true,                 plotborderwidth: 1             }         });           var chart1  = new highcharts.chart({             chart: {                 renderto: $container,             },              xaxis: {                 type: 'datetime'             },              series: [{                 data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],                 pointstart: date.utc(2010, 0, 1),                 pointinterval: 3600 * 1000 // 1 hour             }]         });      });     </script> 

in table that's created, have <div> inserted dynamic id (same values array i'm attempting use highcharts function), works. issue can't seem pass variable renderto part of highcharts function.

here's how i'm declaring superglobal variable inside table loop (again, works fine):

$globals['a'] = $row['name'] . $temp_array; 

tl;dr.. if knows how pass variable renderto in highcharts function i'd love know how it. enough info, if not i'll gladly provide requested. thanks!

in renderto need add string not object return.

so should

 var $container = 'global_var', //id of container, string 

and in chart

 chart: {             renderto: $container,         }, 

if combine js variable string php variable should like:

var $container = '<?php echo $variable ?>', 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -