<commit_before><% charts = chart.is_a?(Array) ? chart : [chart]
   stacked = charts.size > 1 %>
<% charts.each do |c| %>
  <% chart_name = c[:name] %>
  <div id="<%= chart_name %>_chart_container" class="chart_container">
    <% if stacked %>
      <strong><%= chart_name %></strong>
    <% end %>
    <div id="<%= chart_name %>_yaxis" class="y_axis"></div>
    <div id="<%= chart_name %>_chart" class="chart"></div>
    <div id="<%= chart_name %>_zoom" class="zoom"></div>
    <div id="<%= chart_name %>_legend" class="legend"></div>
  </div>
<% end %>

<script>
  var fn = function() {
    var palette = new Rickshaw.Color.Palette();
    var graphs = [];
    var graph, chart_div, data, startTime, endTime, timeStep, timeRange, metrics, currentTime;
    <% charts.each do |c| %>
      <% chart_name = c[:name] %>
      chart_div = document.getElementById("<%= chart_name %>_chart");
      <% c[:data] = c[:data].sort_by {|m| m['header']['metric']} %>
      data = JSON.parse('<%= sanitize(c[:data].to_json) -%>');
      if (data) {
        startTime = <%= c[:start_time] %>;
        endTime = <%= c[:end_time] %>;
        timeStep = <%= c[:step] %>;

        timeRange = [];
        currentTime = startTime;
        while (currentTime <= endTime) {
          timeRange.push(currentTime);
          currentTime = currentTime + timeStep;
        }

        metrics = data.map(function (metric) {
          var dataPoints = metric['data'];
          return {
            name: metric['header']['metric'],
            data: dataPoints.length ? timeRange.map(function (time, i) {
              return { x: time, y: dataPoints[i] };
            }) : [{x: timeRange[0], y: null}],
            color: palette.color()
          };
        });

        graph = new Rickshaw.Graph({
          element:     chart_div,
          renderer:    'line',
          interpolate: 'basis',
          series:      metrics
        });

        new Rickshaw.Graph.Axis.Time({graph: graph});

        new Rickshaw.Graph.Axis.Y({
          graph:       graph,
          orientation: 'left',
          tickFormat:  Rickshaw.Fixtures.Number.formatKMBT,
          element:     document.getElementById('<%= chart_name %>_yaxis')
        });

        new Rickshaw.Graph.Behavior.Series.Toggle({
          graph:  graph,
          legend: new Rickshaw.Graph.Legend({
            graph:   graph,
            element: document.getElementById('<%= chart_name %>_legend'),
            naturalOrder: true
          })
        });

        new Rickshaw.Graph.HoverDetail({
          graph:     graph,
          formatter: function (series, x, y) {
            var date = '<span class="date">' + new Date(x * 1000).toUTCString() + '</span>';
            var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
            return swatch + series.name + ": " + parseInt(y) + '<br>' + date;
          }<commit_msg>Fixed hover formatting for non-integer y-values.<commit_after><% charts = chart.is_a?(Array) ? chart : [chart]
   stacked = charts.size > 1 %>
<% charts.each do |c| %>
  <% chart_name = c[:name] %>
  <div id="<%= chart_name %>_chart_container" class="chart_container">
    <% if stacked %>
      <strong><%= chart_name %></strong>
    <% end %>
    <div id="<%= chart_name %>_yaxis" class="y_axis"></div>
    <div id="<%= chart_name %>_chart" class="chart"></div>
    <div id="<%= chart_name %>_zoom" class="zoom"></div>
    <div id="<%= chart_name %>_legend" class="legend"></div>
  </div>
<% end %>

<script>
  var fn = function() {
    var palette = new Rickshaw.Color.Palette();
    var graphs = [];
    var graph, chart_div, data, startTime, endTime, timeStep, timeRange, metrics, currentTime;
    <% charts.each do |c| %>
      <% chart_name = c[:name] %>
      chart_div = document.getElementById("<%= chart_name %>_chart");
      <% c[:data] = c[:data].sort_by {|m| m['header']['metric']} %>
      data = JSON.parse('<%= sanitize(c[:data].to_json) -%>');
      if (data) {
        startTime = <%= c[:start_time] %>;
        endTime = <%= c[:end_time] %>;
        timeStep = <%= c[:step] %>;

        timeRange = [];
        currentTime = startTime;
        while (currentTime <= endTime) {
          timeRange.push(currentTime);
          currentTime = currentTime + timeStep;
        }

        metrics = data.map(function (metric) {
          var dataPoints = metric['data'];
          return {
            name: metric['header']['metric'],
            data: dataPoints.length ? timeRange.map(function (time, i) {
              return { x: time, y: dataPoints[i] };
            }) : [{x: timeRange[0], y: null}],
            color: palette.color()
          };
        });

        graph = new Rickshaw.Graph({
          element:     chart_div,
          renderer:    'line',
          interpolate: 'basis',
          series:      metrics
        });

        new Rickshaw.Graph.Axis.Time({graph: graph});

        new Rickshaw.Graph.Axis.Y({
          graph:       graph,
          orientation: 'left',
          tickFormat:  Rickshaw.Fixtures.Number.formatKMBT,
          element:     document.getElementById('<%= chart_name %>_yaxis')
        });

        new Rickshaw.Graph.Behavior.Series.Toggle({
          graph:  graph,
          legend: new Rickshaw.Graph.Legend({
            graph:   graph,
            element: document.getElementById('<%= chart_name %>_legend'),
            naturalOrder: true
          })
        });

        new Rickshaw.Graph.HoverDetail({
          graph:     graph,
          formatter: function (series, x, y) {
            return '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>' +
                series.name + ": " + y + "<br>" +
                '<span class="date">' + new Date(x * 1000).toTimeString() + '</span>';
          }
{'fraction_non_alphanumeric': 0.17375643224699827, 'fraction_numerical': 0.002058319039451115, 'mean_word_length': 2.177656675749319, 'pattern_counts': {'":': 2, '<': 85, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '805573', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1754, 'n_words': 391}