Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/10/2013, 12:27
Derley
 
Fecha de Ingreso: agosto-2013
Ubicación: Asturias
Mensajes: 11
Antigüedad: 10 años, 8 meses
Puntos: 0
Respuesta: Pasar datos obtenidos en PHP a JavaScript

Gracias,

Entonces, si tengo este código (que es el que trae la página)

HTML
Código HTML:
Ver original
  1. <script src="http://code.highcharts.com/highcharts.js"></script>
  2. <script src="http://code.highcharts.com/modules/exporting.js"></script>
  3.  
  4. <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

JAVASCRIPT
Código Javascript:
Ver original
  1. $(function () {
  2.         $('#container').highcharts({
  3.             chart: {
  4.                 type: 'line'
  5.             },
  6.             title: {
  7.                 text: 'Monthly Average Temperature'
  8.             },
  9.             subtitle: {
  10.                 text: 'Source: WorldClimate.com'
  11.             },
  12.             xAxis: {
  13.                 categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  14.             },
  15.             yAxis: {
  16.                 title: {
  17.                     text: 'Temperature (°C)'
  18.                 }
  19.             },
  20.             tooltip: {
  21.                 enabled: false,
  22.                 formatter: function() {
  23.                     return '<b>'+ this.series.name +'</b><br/>'+
  24.                         this.x +': '+ this.y +'°C';
  25.                 }
  26.             },
  27.             plotOptions: {
  28.                 line: {
  29.                     dataLabels: {
  30.                         enabled: true
  31.                     },
  32.                     enableMouseTracking: false
  33.                 }
  34.             },
  35.             series: [{
  36.                 name: 'Tokyo',
  37.                 data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
  38.             }, {
  39.                 name: 'London',
  40.                 data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
  41.             }]
  42.         });
  43.     });

E imaginemos que en vez de los datos prefijados que tiene Tokyo,se los paso. ¿Sería así?

Código Javascript:
Ver original
  1. name: 'Tokyo',
  2. data: <?$Vble_array_php?>

Gracias