CSS-only plotting
github.com
github.com
<div class="bar-chart">
<ul>
<li style="height:99%">99%</li>
<li style="height:50%">50%</li>
<li style="height:30%">30%</li>
<li style="height:90%">90%</li>
<li style="height:10%">10%</li>
<li style="height:70%">70%</li>
<li style="height:30%">30%</li>
<li style="height:90%">90%</li>
</ul>
</div>GP is saying that there is next to no benefit to the approach proposed in this project compared to just using [the ugly and terrible] inline CSS.
<div class="bar-chart">
<ul class="container">
<li data-cp-size="99">99%</li>
<li data-cp-size="50">50%</li>
<li data-cp-size="30">30%</li>
<li data-cp-size="90">90%</li>
<li data-cp-size="10">10%</li>
<li data-cp-size="70">70%</li>
<li data-cp-size="30">30%</li>
<li data-cp-size="90">90%</li>
</ul>
</div>Why use inline CSS? Because it's simpler and obvious. The proposed hack has no upsides: it isn't any more accessible, isn't any more maintainable, and it isn't any more performant (quite the opposite).
To me it's in the same category as replacing `<font color=red>` with `<span class=red>`, because "font is bad".
The CSS is ugly because of the many redundant rules. But if you have x bar charts on y pages, then one ugly CSS file is better than x repeated ugly spots spread out in y HTML files.
Also it's very unlikely you'd have many charts with markup written by hand. I'd expect charts to be generated from a template from a proper data source, so change in markup of all charts would still be done in one place.
At least with inline style you can have the precision you want and are not forced to round your value.
Sooo, yeah it's an interesting exercise but I'm not convinced about the usefulness of that project.
https://github.com/asciimoo/cssplot/blob/master/cssplot.css
.bar-chart ul li[data-cp-size="0"] {
height: 0%;
}
.bar-chart ul li[data-cp-size="1"] {
height: 1%;
}
.bar-chart ul li[data-cp-size="2"] {
height: 2%;
}
...
Still find it cool, but a 1200 line CSS may be a bit too much for a practical application..scatterplot ul li[data-cp-y] { bottom: attr(data-cp-y %); }
height: attr(sata-cp-size px);
Considering attribute selectors have been around for a while, I fail to see a decent use case. Any progress bar or 2-dimensional chart of this kind needs to be generated dynamically, either through the backend or frontend, same thing. In this case, they're inserted as data attribute values. What's the difference with using inline style attributes (left: 10%; width: 90%)? They're generated automatically, so verbosity is not an issue. And you'd save yourself 1200 lines of CSS.
What about flexibility? CSS provides the ability to style each of the 400 options differently, right? Well using a "x24 y78" CSS class would be as simple. But in the end, you only want to give different height/width bottom/left values. The styling remains unchanged.
Writing every possible option of a dynamically generated chart into a static CSS file, just for the sake of "Simplicity" and "No javascript required" seems like an overkill.
On a side note, anything dealing with percentages instead of pixel values is automatically granted the keyword "Responsive".
[data-cp-size]:after { content: attr(data-cp-size) "%"; }