Sha256: c44254dd1add7153ef9d628aeb82960952ac882ac4ffe06a848a334d9289c842

Contents?: true

Size: 1.04 KB

Versions: 94

Compression:

Stored size: 1.04 KB

Contents

initializeCharts = ->
  $charts = $('.effective-datatables-chart:not(.initialized)')
  return if $charts.length == 0

  if typeof(google) == 'undefined' || typeof(google.charts) == 'undefined'
    $.getScript 'https://www.gstatic.com/charts/loader.js', -> loadCharts()
  else
    loadCharts()

  $charts.addClass('initialized')

loadCharts = ->
  google.charts.load('current', { packages: ['corechart'] })
  google.charts.setOnLoadCallback(renderCharts)

renderCharts = ->
  return if (typeof(google) == 'undefined' || typeof(google.visualization) == 'undefined')

  $('.effective-datatables-chart').each ->
    $chart = $(this)

    data = $chart.data('data') || []
    type = $chart.data('as') || $chart.data('type') || 'BarChart'
    options = $chart.data('options') || {}

    chart = new google.visualization[type](document.getElementById($chart.attr('id')))
    chart.draw(google.visualization.arrayToDataTable(data), options)

$ -> initializeCharts()
$(document).on 'page:change', -> initializeCharts()
$(document).on 'turbolinks:load', -> initializeCharts()

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
effective_datatables-4.31.3 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.31.2 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.31.1 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.31.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.30.2 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.30.1 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.30.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.29.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.26.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.25.3 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.25.2 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.25.1 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.25.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.24.2 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.24.1 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.24.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.23.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.22.3 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.22.2 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.22.1 app/assets/javascripts/effective_datatables/charts.js.coffee