How can change the background color of a cliked region in GeoChart

619 views
Skip to first unread message

KUTTIKRISHNAN P

unread,
Mar 21, 2013, 5:33:57 AM3/21/13
to google-visua...@googlegroups.com
Hai,

I have created  geoChart of US by using below code . While clicking on any region I would like to change the backgroud color of the clicked region. I am able to trigger the region click event . Please help to change the background color of the clicked region .

<html>
  <head>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
     google.load('visualization', '1', {'packages': ['geochart']});
     google.setOnLoadCallback(drawRegionsMap);
      function drawRegionsMap() {
        var data = google.visualization.arrayToDataTable([['State']]);
        var options = {
            region: 'US',
            displayMode: 'region',
            colorAxis: {colors: ['orange', 'blue']},
            datalessRegionColor:'F5F5F5',
            enableRegionInteractivity:true,
            resolution:'provinces'
        };
        var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
        chart.draw(data, options);
        google.visualization.events.addListener(chart, 'regionClick', function(res){
            //var country_data = chart.getSelection();
            //chart.setSelection();
                });
    };
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>





Thanks in Advance



Regards,
Kutti

asgallant

unread,
Mar 21, 2013, 10:16:23 AM3/21/13
to google-visua...@googlegroups.com
You have to change the value of the selected region's color cell in the DataTable and then redraw the chart.
Reply all
Reply to author
Forward
0 new messages