Support

Account

Home Forums ACF PRO Google Graph

Solving

Google Graph

    • naomivd

    • December 28, 2017 at 12:46 am

    Is there a way to implement Google Graph in a ACF field?
    https://google-developers.appspot.com/chart/interactive/docs/gallery/piechart
    This is the code I need to use.

  • You would need to get the values of the ACF fields and set those values in the script. Here is a simple example using part of the snippet from the link you provided

    
    function drawChart() {
    
      var data = google.visualization.arrayToDataTable([
        ['Task', '<?php the_field('hours_per_day); ?>'],
        ['Work', <?php the_field('work')],
        // etc....
      ]);
    
      var options = {
        title: '<?php the_field('title'); ?>'
      };
    
      var chart = new google.visualization.PieChart(document.getElementById('piechart'));
    
      chart.draw(data, options);
    }
    
    
    • naomivd

    • December 29, 2017 at 3:19 am

    Forgive me, I see that my question is unclear.

    I need to show a Google Graph using ACF. So if I have a Google Graph code, what custom field do I need to select so that someone can place the code in there and have it show up?

  • I would use a textarea field and set it to “No Formatting”.

  • Hi, this topic is quite interesting. But do you have any idea on how to retrieve all infos sharing the same meta-key to generate a pie chart?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.