-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminate external CSS #23
Comments
Maybe have a look at https://github.com/css-modules... |
Thank you for the link. It seems like CSS modules require an ES6 build step (with JSPM, WebPack, or Browserify) based on what I see in https://github.com/css-modules/css-modules . Reading through this led me to discover this interesting post CSS Modules - Welcome to the Future - 2015-08-19, which points back to Christopher Chedeau’s “CSS in JS” talk from NationJS in November, 2014. This is basically the same idea I had, which is to have JS/D3 set inline styles based on parameters from the Chiasm configuration. Here's an example I made to test out the idea - Axis Styles via JavaScript. |
One benefit of inlining styles is that the svg is complete. I had to go though pains in in https://github.com/Hypercubed/angular-downloadsvg-directive to make sure css styles are copied to the svg before download. You might also consider name spacing your css classes so that they don't interfere with other page elements (or otherwise limiting your |
👍 |
In my opinion (which does have a tendency to change) is that styles should be inline (explicitly stated in the plugin/d3 code) only when the style depends (or may depend) on the data. For example if the points on a scatter plot can vary their fill color by data value, that should be inline (even then maybe should default to css if no style is give). Otherwise CSS is much more powerful. My list of drawbacks to inline styles:
The advantage of using inline styles:
|
Currently Chiasm visualization plugins require that some CSS be loaded on the containing page. Ideally, the entire visualization appearance should be configurable from within the Chiasm configuration, and not depend on external CSS. As an example, see this dashboard demo http://bl.ocks.org/curran/4ce2ee825811f1c32125#axes.css
The required CSS relates mostly to axes. Resolving this issue involves moving that static CSS into dynamically added CSS that is configured from the Chiasm JSON configuration. This would enable any page to include Chiasm visualizations via JavaScript only, and not require the addition of any CSS link to the containing HTML source.
The text was updated successfully, but these errors were encountered: