Every time I use Google Charts' Table the google loader loads a http://ajax.googleapis.com/ajax/static/modules/gviz/1.0/table/table.css
which always and almost kills my bootstrap css, and i't pretty annoying at 2AM. :)
Note: I can't modify the table.css file.
Do you know any method that can prevent the loading of the CSS file?
Thanks for the help.
PS: Yep, I've tried with JS, but the table recompiles on switching page, so i should replace the table
's classname every time on paged.
As seen in the Google Chart Table API Docs, you can override the CSS classes used by setting the
cssClassNames
option :Check the doc via the above link to see a full description of each property supported by
cssClassNames
.Very simply, based on the Google Playground Table example, if you override all the properties, the table will be (almost) free of Google CSS.
You can try it by copying the following code in the playground example :
This should let the Twitter Bootstrap CSS alone.
The CSS loaded still changes a few things, but seems to go away if you simply remove the class
google-visualization-table-table
. You should do that after each.draw()
call.Update : if you are using the page option, you can use this snippet to remove the class when paging :
Don't forget to call the
.removeClass()
on initialization too (you should make a function, like there : http://pastebin.com/zgJ7uftZ )This should solve your problem I believe: Link
Taken from the link:
Add a prefix to your css class names
and then change your css decelerations like this:
I only see two possibilities there. Either change all of your CSS-Selectors to something with a higher specifity or use Javascript to remove the Stylesheets you don't want to load.
Changing the CSS-Selectors is no problem if you use a CSS-Preprocessor. You could even just use it this one time to change alle the selectors.
With Javascript you would need a point where you can hang an event listener which removes the stylesheet. This point has to be right after the stylesheet is added.
If you have no such point you would have to overwrite document.createElement (which is a bad practice in general).
This worked for me. Due to IE<9s lack of addEventListener and indexOf for arrays it doesn't work there. But after you fix that it should work there as well:
Of course this won't prevent any stylesheets from being @imported inside a style element. So it really is more a dirty hack than a solution …
It is a shame that Googles API offers a "nocss" option but doesn't support it in the visualization module.
EDIT: If the browser supports defineSetter it no longer even loads the stylesheet.
Give your
body
a class. Then scope your CSS leveraging that class.What if you just get a copy of the js of what google api loads and place it inside in your server, as in the table.js in below example, and comment the google api call.
Inside it find the string '/table/table.css' and replace it with '/table/../core/tooltip.css'
This way, the table.css is never loaded.
I'm not really sure if this violates anything and it's a very hacky solution. Obviously, there are consequences to this.
Easy since you have jQuery installed: