Sha256: 133b63065d9d6167af631809f2da488a57c0b1cb31e09c314886d876b88806b9

Contents?: true

Size: 1.02 KB

Versions: 140

Compression:

Stored size: 1.02 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('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

140 entries across 140 versions & 1 rubygems

Version Path
effective_datatables-3.7.10 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.9 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.8 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.7 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.6 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.5 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.3 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.2 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.1 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.7.14 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.7.13 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.7.12 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.7.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.6.3 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.6.1 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-3.6.0 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.7.11 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.7.10 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.7.9 app/assets/javascripts/effective_datatables/charts.js.coffee
effective_datatables-4.7.8 app/assets/javascripts/effective_datatables/charts.js.coffee