Google Visualization API for Table has an interesting property "Paging". When enabled , ( by setting the "page" property to "enable") it brings up nice little arrows at the bottom of the table for navigation. This is very handy and I like this feature very much, as this does not make your table grow vertically and can fit into the space you are providing on your web page. The control buttons for Paging is shown below
Google Visualization API - Table - Standard Paging Symbols |
In this post, we will see how to customize the Paging buttons to make them read like 'Previous', 'Next' instead of the standard arrow styles. To do this, we will make use of a configuration property called "pagingSymbols". With Paging Symbols, you can define the text for "Previous" and "Next" buttons on the table as shown below when invoking the "draw" method;
visualization.draw(data,{allowHtml: true,page : 'enable',pageSize :'5',sortAscending: 'True',width: '728',pagingSymbols: {prev: 'Prev', next: 'Next'}});
The one highlighted in green are the properties and the one in yellow are equivalent text that needs to be replaced. The control buttons in the table will now read 'Prev' and 'Next' instead of the standard "arrows". This is shown below
Google Visualization API - Paging Symbols - Customized Text |
Previous Button for Visualization API |
Next Button for Visualization API |
var img1='<img height="30" width="60" src="Previous.jpg">';
var img2='<img height="30" width="60" src="Next.jpg">';
In the draw method , we can now substitute these variables inside pagingSymbols and use them instead of regular text. As an example
visualization.draw(data,{allowHtml: true,page : 'enable',pageSize :'5',sortAscending: 'True',width: '728',pagingSymbols: {prev: img1, next: img2}});
When the table is rendered using this setup, the Previous and Next button will appear as images. This is shown in the screenshot below
Is there also a way to style the legend pagination in interactive charts?
ReplyDeleteIs there also a way to style the legend paging in interactive charts?
ReplyDelete