Sha256: 143b61b82c76461f9e6dc7b1d307d14869daf36534b873c2b14947e83299b19e

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

<canvas id="<%=prefix.to_s.camelize %>LineChart"></canvas>
<% content_for :script do %>
  
// uses JQuery
$(function(){
  "use strict";

  var data = {
    labels : <%=raw labels_from_rows(rows, x).to_json %>,
    datasets : [
    <% y = [y] if !y.is_a?(Array) %>
    <% lines = y.map do |k| 
      "{
        fillColor : '#{color}',
        strokeColor : '#{color}',
        pointColor : '#{color}',
        pointStrokeColor : '#fff',
        data : #{raw decimals_from_rows(rows, x, k).to_json}
      }"
    end.join(',') %>
    <%=raw lines %>
    ]
  };

  var ctx = document.getElementById("<%=prefix.to_s.camelize %>LineChart").getContext("2d");
  
  // uses Chartjs
  var chart = new Chart(ctx).Line(data, {responsive: true});
  <%= yield :chartjs_script %>  
});

<% end %>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reporta-modules-0.0.3 lib/generators/templates/reports/_chartjs_line.html.erb
reporta-modules-0.0.2 lib/generators/templates/reports/_chartjs_line.html.erb
reporta-modules-0.0.1 lib/generators/templates/reports/_chartjs_line.html.erb