Advertisement
gersonab

hig1

Sep 14th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.76 KB | None | 0 0
  1. <script type="text/javascript">
  2.             Highcharts.visualize = function(table, options) {
  3.                
  4.                 // the categories
  5.                 options.xAxis.categories = [];
  6.                 $('tbody th', table).each( function(i) {
  7.                     options.xAxis.categories.push(this.innerHTML);
  8.                 });
  9.                
  10.                 // the data series
  11.                 options.series = [];
  12.                 $('tr', table).each( function(i) {
  13.                     var tr = this;
  14.                     $('th, td', tr).each( function(j) {
  15.                         if (j > 0) { // skip first column
  16.                             if (i == 0) { // get the name and init the series
  17.                                 options.series[j - 1] = {
  18.                                     name: this.innerHTML,
  19.                                     data: []
  20.                                 };
  21.                             } else { // add values
  22.                                 options.series[j - 1].data.push(parseFloat(this.innerHTML));
  23.                             }
  24.                         }
  25.                     });
  26.                 });
  27.                
  28.                 var chart = new Highcharts.Chart(options);
  29.             }
  30.                
  31.             // On document ready, call visualize on the datatable.
  32.             $(document).ready(function() {         
  33.                 var table = document.getElementById('datatable'),
  34.                 options = {
  35.                        chart: {
  36.                           renderTo: 'container',
  37.                           defaultSeriesType: 'column'
  38.                        },
  39.                        title: {
  40.                           text: 'Grafico de acompanhamento'
  41.                        },
  42.                        xAxis: {
  43.                        
  44.                        labels: {
  45.                         rotation: -55,
  46.                         align: 'right',
  47.                         style: {
  48.                          font: 'normal 9px Verdana, sans-serif'
  49.                             }
  50.                         }
  51.                         },
  52.                        yAxis: {
  53.                           title: {
  54.                              text: 'Notas'
  55.                           }
  56.                        },
  57.                        tooltip: {
  58.                           formatter: function() {
  59.                              return '<b>'+ this.series.name +'</b><br/>'+
  60.                                 this.y +' '+ this.x.toLowerCase();
  61.                           }
  62.                        }
  63.                     };
  64.                
  65.                                    
  66.                 Highcharts.visualize(table, options);
  67.             });
  68.                
  69.         </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement