Sha256: 0420cb47714283726ae4171b20c53d17a16c8ad61a335db1bf8cc1cb0ea6156e

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

<div class="row column full-height">
  <%= timeline [], id: "participatoryProcessesChart", height: "100%" %>
</div>
<script>
  (function() {
    var rows = [];
    <% timeline_graph.each do |row| %>
    rows.push([
      "<%= row[:name] %>",
      "<%= row[:title] %>",
      new Date("<%= row[:start_date] %>"),
      new Date("<%= row[:end_date] %>")
      ]);
    <% end %>

    var drawChart = function() {
      var dataTable = new google.visualization.DataTable();
      dataTable.addColumn({ type: 'string', id: 'Platform' });
      dataTable.addColumn({ type: 'string', id: 'Process' });
      dataTable.addColumn({ type: 'date', id: 'Start' });
      dataTable.addColumn({ type: 'date', id: 'End' });
      dataTable.addRows(rows);
      var chart = Chartkick.charts["participatoryProcessesChart"];
      chart.getChartObject().draw(dataTable);

      // hack the real height
      var h = parseInt($("#participatoryProcessesChart div:first-child div:first-child div:first-child div svg").attr("height")) + 70;
      chart.getChartObject().draw(dataTable, {
          height: h,
          // hAxis: {
          //   minValue: new Date(2019, 0, 0),
          //   maxValue: new Date(2020, 0, 0)
          // },
          width: "100%",
          timeline: {
            // showRowLabels: false,
            rowLabelStyle: {
              fontSize: 16
            },
            // showBarLabels: false
          }
      });
      // extra svg tweaks
      $('#participatoryProcessesChart div div div svg g:first text').attr({'x': 5, "text-anchor": "start", "font-weight": "bold"})
    };

    google.charts.setOnLoadCallback(drawChart);

    // Rewdraw on tab appearance
    $("[data-tabs]").on("change.zf.tabs", drawChart);
    // redraw graph when window resize is completed
    $(window).on('resizeEnd', drawChart);

  }());
</script>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-comparative_stats-1.1.0 app/cells/decidim/comparative_stats/participatory_processes_timeline/show.erb
decidim-comparative_stats-1.0.1 app/cells/decidim/comparative_stats/participatory_processes_timeline/show.erb