javascript - Google chart disappears when changing page in rails app -
I first worked with Google charts and now I'm using in App Rail, but when I change the page and Return to the chart page
Code:
application.html.erb:
Code> & Lt;% = javascript_include_tag "//www.google.com/jsapi"% & gt;
_administrator_navbar.html. ARB:
& lt;% = link_to 'caboom', root_path ,: class = & gt; 'Navbar-brand header-title'% & gt;
_user.html. ARB:
& lt; Script type = "text / javascript" & gt; Google.load ("Visualization", "1", {packages: ["corechart"]}); Google.setOnLoadCallback (drawChart); Function drawChart () {var data = google.visualization.arrayToDataTable ([['Status', 'Quantidad'], ['Paagas', 3], ['Ventidas', 2], ['A Venera', 4]] ); Var PaymentData = google.visualization.arrayToDataTable ([['Label', 'Heroism'], ['Despace', 1000], ['Acquisition', 3000]]); Var chart = new google.visualization.PieChart (document.getElementById ('piechart')); Var paymentchart = new google.visualization.PieChart (document.getElementById ('paymentchart')); Chart.draw (data, {title: 'Relação de Mensalidades'}); Paymentchart.draw (paymentdata, {title: 'fluxo de casa'}); } & Lt; / Script & gt; & Lt; Div class = "col-md-6" & gt; & Lt; Div id = "piechart" style = "width: 600px; height: 500px;" & Gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "col-md-6" & gt; & Lt; Div id = "paymentchart" style = "width: 600px; height: 500px;" & Gt; & Lt; / Div & gt; & Lt; / Div & gt;
Any ideas how to solve it?
You might be using this, you have to change your chart to something like this in JS :
function createChart () {// Create chart} $ (document) .ready (createChart); $ (Document) .on ('page: change', createChart)
Comments
Post a Comment