Sha256: fbe2653f79c26b0c7a74e356088a3693e46364b402610ce5f549574a82f6bf96

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

<!doctype html>
<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = <%= @chart.data %>;
        var formatter = new google.visualization.DateFormat({formatType:'medium'});
        var formattedData = [];
        for(var key in data) {
          if (data.hasOwnProperty(key)) {
            var arr = [new Date(parseInt(key * 1000))];
            var values = data[key];
            for(var i = 0; i < values.length; i++) {
              arr.push(values[i]);
            }
            formattedData.push(arr);
          }
        }
        var dataTable = new google.visualization.DataTable();
        <% @chart.column_types.each do |column| %>
            dataTable.addColumn("<%= column[0] %>", "<%= column[1] %>");
        <% end %>
        dataTable.addRows(formattedData);

        var options = {
          width: <%= @chart.width %>, height: <%= @chart.height %>,
          title: "<%= @chart.title %>"
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(dataTable, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div"></div>
  </body>
</html>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rstatsd-0.3 templates/google_chart.erb
rstatsd-0.2 templates/google_chart.erb