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.10.4 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.10.3 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.10.2 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.10.1 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.10.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.9.4 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.9.3 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.9.2 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.9.1 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.9.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.16 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.15 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.14 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.13 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.12 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.11 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.10 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.9 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.8 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.8.7 app/assets/javascripts/effective_datatables/charts.js.coffee