function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Puneet_MishraPuneet_Mishra 

Visualforce with Google Charts

Hi All,
I working on my visualforce page where I would like to some google charts. I am working on BarChart right now and I am using google.visualization.arrayToDataTable();

I tried passing 'JSON' as parameter to DataTable from my controller and even custom data format which is mentioned in examples on internet but niether I get any error nor any message. Please help where I am doing wrong but please don't give an example of hardcoded values.

function drawGoogleBarChart() {
                     // Define the chart to be drawn.
                       var data = google.visualization.arrayToDataTable(                        
                        '{!bestperformer}'                                                  
                    );
                    console.log('11'+{!bestSeller});
                       var options = {
                        title: 'Bestsellers',
                          isStacked:true,
                          series: {
                            0: { color: '#5B9BD4' },
                            1: { color: '#EC7C30' }
                          },
                        animation:{
                            duration: 2000,
                            easing: 'out',
                            "startup": true
                          },
                        legend:{position: 'bottom'}
                       };  
                
                       // Instantiate and draw the chart.
                       var chart = new google.visualization.BarChart(document.getElementById('bestsellers_chart'));
                       chart.draw(data, options);
                }
Controller logic returns a JSON response 
[ {
  "user1" : "SOME USER 1",
  "won" : 1,
  "lost" : 0
}, {
  "user1" : "SOME USER 3",
  "won" : 5,
  "lost" : 1
}, {
  "user1" : "SOME USER 4",
  "won" : 10,
  "lost" : 4
} ]

I tried creating custom string which was mentioned in examples 

[ "Users", "Won", "Lost"],
[ "SOME USER 1", 1, 0], 
[ "SOME USER 3", 5, 1], 
[ "SOME USER 4", 10, 4] 
]

but above values didn't work for me.

Please help me know where I am doing wrong.

THanks, In Advance