Google charts



  • Hello,
    Is there way to use google charts? I tried this but its not working, i can't pass data to function

    Script

    google.charts.load('current', {'packages':['corechart']});
    
    function graph(element, data){
        google.charts.setOnLoadCallback(
            function() {
                drawPieChart(element, data);
            });
    }
    
    function drawPieChart(element,rdata) {
       
        console.log('Draw chart')
            var data =  google.visualization.arrayToDataTable(rdata);
    
            var options = {
              pieHole: 0.5,
              pieSliceTextStyle: {
                color: 'black',
              },
              legend: 'none'
            };
    
            var chart = new google.visualization.PieChart(document.getElementById(element));
            chart.draw(data, options);
    }
    

    Template

     <body>
         <script>
             graph('returnRate',{{returnRateGraphData}} );
        </script>
    
     <div id="returnRate" style="width: 900px; height: 500px;"></div>
     </body>
    

  • administrators

    hi! can you please reproduce your example in the playground, save it and then share the link back here? it will help to check the full example, maybe there is something missing here and we can help pointing where should be the fix in your code



  • https://playground.jsreport.net/w/anon/hhVAb~Jm

    if you leave the graph2 function commented, it will work, but i need somehow pass data.



  • @Arcus16 using DOM dataset attribut I did manage to pass data to your chart see this playground, hope this can help

    https://playground.jsreport.net/w/MI53RE/Jz3IsOBm



  • @MI53RE19 Thank You!


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.