fnando / sparkline

Generate SVG sparklines with JavaScript without any external dependency.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: configurable class names

arothuis opened this issue · comments

Currently, the class names of the spot and the circle are hardcoded. The line and the fill do not have a class name.

In order to give clients easy and full control over styling their graphs, it might be an idea to make all these elements' class names configurable (with sensible defaults, i.e. BEM?).

I don't think making class names configurable would be useful at all. Also, the reason line/fill elements don't have class name is that they can be styled via the svg element. How are you planning to style line/fill elements directly via class names? Or do you want to script them somehow?

Thanks for your reply!

The reason one might think about making it configurable is to be friendly towards client users and allow them to have their own naming scheme (i.e. namespaced classes like BEM or pure, utility classes like Atomic CSS or Functional CSS).

Giving clients more control over styling is also the reason why I would like a class name for the line and fill elements. Instead of relying on the unspecific svg element, one can specify a namespaced, specific element instead (or use utility classes to style them accordingly).

All in all, I think the library should not enforce these rules upon its users but client users should be able to embed this library in their code without sacrificing their naming schemes or styling strategies.

I added class names to both line and fill area, but I'm still not convinced that making them configurable is useful. I may revisit this in the future.