Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chart Table Remove the selection

I am currently working with the Google chart tables. I have a problem with the selections. I want to turn the selections off, but it seems to be impossible. I even tried (an real ugly way) like an event listener on the select part that uses the method clearChart() to remove this.

Here is the test sourche code. Note that i cant use this in jsfiddle

<script type="text/javascript" src="https://www.google.com/jsapi" ></script>
<script type="text/javascript">
google.load("jquery", "1");

google.load('visualization', '1', {packages:['table']});

     function drawVisualization()
     {
          var data = google.visualization.arrayToDataTable([
          ['', 'Name', 'E-mail', 'Activated', 'Last login'],
          ['<input type="checkbox">', 'name1', 'name1@company.xxx', true, '20-07-2012'],
          ['<input type="checkbox">', 'name2', 'name2@company.xxx', true, '21-07-2012']

               ]);

               var options = {};
               options['showRowNumber'] = false;
               options['page'] = 'enable';
               options['allowHtml'] = true;
               options['pageSize'] = 18;
               options['pagingButtonsConfiguration'] = 'auto';

               var visualization = new google.visualization.Table(document.getElementById('table'));
               visualization.draw(data, options);
          }

          google.setOnLoadCallback(drawVisualization);

</script>
<div id="table"></div>

The problem is that if I use these checkboxes the (blue) selection is anoying and confusing.

Thanks.

like image 928
Ron van der Heijden Avatar asked Aug 02 '12 10:08

Ron van der Heijden


People also ask

How do you exclude data from a chart in Google Sheets?

Click the filter icon in cell A1 and uncheck the student names 'a' and 'b' and hit the “OK” button. This will exclude the relevant rows from the Sheet and also from your chart.

How do I get rid of the border on a Google chart?

Double click on any chart to open the Chart editor and select the Customize tab. Under Chart style, you can select a border color or select “None” to remove the border.

How do I remove a percentage from a Google chart?

Percentage is being automatically added to Google Pie charts tooltips, and there is no built-in option to remove it. However, you can use wpDataChart callbacks to tweak this. Charts usually support custom options appropriate to that visualization. You can use it for adding options that are available in Google Api.


2 Answers

Another option is to reset the selection when the "select" event is fired:

google.visualization.events.addListener(visualization, 'select', selectHandler);

function selectHandler() {  
    visualization.setSelection([])
}

Here's an example: http://jsfiddle.net/Rxnty/

This immediately removes the selection without requiring a redraw.

like image 149
Greg Ross Avatar answered Oct 05 '22 01:10

Greg Ross


One way to achieve what the effect you desire is to tell the API what class should be applied when the row is selected, allowing you to keep specify the background-color of the row.

JS:

options['cssClassNames'] = {}
options['cssClassNames']['selectedTableRow'] = 'selected';

CSS:

.selected { background-color: white; }

You can see it working on jsfiddle.

like image 38
cchana Avatar answered Oct 05 '22 00:10

cchana