Sha256: 468479077d77896b5f80d2d8561a35fb7610a0a0e9503115b87b59222a5fb529

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

function create_chart(chart_id, chart_table, chart_type){
  options = chart_options(chart_id, chart_table, chart_type);
  return(new Highcharts.Chart(options));
};

function chart_options(chart_id, chart_table, chart_type){
  options = {
      chart: {
          renderTo: 'container-' + chart_id,
          type: chart_type
      },
      title: {
          text: chart_id
      },
      tooltip: {
          enable: true 
      },
      xAxis: {
          categories: []
      },
      yAxis: {
          title: {
              text: '' //chart_id
          }
      },
      series: []
  };

  $.each(chart_table, function(lineNo, line) {
      // header line containes categories
      if (lineNo == 0) {
          $.each(line, function(itemNo, item) {
              if (itemNo > 0) options.xAxis.categories.push(item);
          });
      }
      // the rest of the lines contain data with their name in the first position
      else {
          var series = {
              data: []
          };
          $.each(line, function(itemNo, item) {
              if (itemNo == 0) {
                  series.name = item;
                  //series.type = chart_type;
              } else {
                  series.data.push(parseFloat(item));
              }
          });
          options.series.push(series);
      }
  });
  return(options);
};

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
locat-0.2.4 lib/locat/template/javascript.js
locat-0.2.3 lib/locat/template/javascript.js
locat-0.2.0 lib/locat/template/javascript.js
locat-0.1.2 lib/locat/template/javascript.js
locat-0.1.1 lib/locat/template/javascript.js
locat-0.1.0 lib/locat/template/javascript.js