TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Charts.css

935 pointsby pspeter3about 4 years ago

40 comments

lucb1eabout 4 years ago
Creating a chart about charts.css with charts.css from the command line:<p><pre><code> ( echo &quot;&lt;table class=&#x27;charts-css bar show-labels show-heading&#x27;&gt;&quot; echo &quot;&lt;caption&gt;Size of Charts.css releases&lt;&#x2F;caption&gt;&quot; for version in $(curl -sS https:&#x2F;&#x2F;github.com&#x2F;ChartsCSS&#x2F;charts.css&#x2F;releases | grep -o releases&#x2F;tag&#x2F;[0-9.]* | cut -d&#x2F; -f3 | tac); do url=https:&#x2F;&#x2F;cdn.jsdelivr.net&#x2F;npm&#x2F;charts.css@$version&#x2F;dist&#x2F;charts.min.css size=$(($(curl -sS &quot;$url&quot; | wc -c)&#x2F;1024)) echo &quot;&lt;tr&gt;&lt;th&gt;v$version&lt;&#x2F;th&gt;&lt;td style=&#x27;--size: calc($size&#x2F;100)&#x27;&gt;${size}KiB&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&quot; done echo &quot;&lt;&#x2F;table&gt;&lt;link rel=stylesheet href=&#x27;$url&#x27;&gt;&quot; ) &gt; size-chart.html </code></pre> Result: <a href="https:&#x2F;&#x2F;jsfiddle.net&#x2F;wcfez6oq&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jsfiddle.net&#x2F;wcfez6oq&#x2F;</a><p>Since I couldn&#x27;t easily find how large it was and wanted to try it out at the same time.
评论 #26497591 未加载
评论 #26498299 未加载
评论 #26496850 未加载
gervwykabout 4 years ago
Well done! This looks impressive and really useful. I’ve been looking for a lightweight sprite &#x2F; spark lib for a while. Clients always, for some reason, are very impressed by little charts in a table row, doing this witha normal size chart lib kills page performance. I was literally including very basic html indicators in a presentation today and client where really impressed! This really solves that issue!<p>And even more. Really great that you van manipulate the elements as css. Most chart libs I’ve dealt with makes non-trivial customization impossible.<p>I’ll probably be building this in as Lowdefy blocks[1].<p>Just curious, did you consider just branding it as sparks.css &#x2F; sprites.css or something? Going the spark &#x2F; sprite route just sets the expectations a lot lower imo. Although congrats, you are really close to fully functional charts here! Really interested to see how far this can go.<p>[1] - <a href="https:&#x2F;&#x2F;lowdefy.com" rel="nofollow">https:&#x2F;&#x2F;lowdefy.com</a>
评论 #26496704 未加载
评论 #26496742 未加载
andy99about 4 years ago
Cool! I&#x27;ll have to take the opportunity to mention my own charts.css[0]. It got some interest on HN last year [1] and I unfortunately dropped the ball and didn&#x27;t make any revisions based on the good feedback I got. As people pointed out, I tried to give it a &quot;cute&quot; name using unicode which unfortunately makes it harder to search for.<p>This version (OP&#x27;s) is way more polished and almost certainly more widely useful. But mine had the features of (a) being generated from markdown and (b) defaulting to a list presentation of the data under different styles so the data remained accessible.<p>Having more charting options that don&#x27;t require javascript to do simple things is a good thing.<p>[0] <a href="https:&#x2F;&#x2F;rbitr.github.io&#x2F;ChartS.css&#x2F;" rel="nofollow">https:&#x2F;&#x2F;rbitr.github.io&#x2F;ChartS.css&#x2F;</a> [1] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23270581" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23270581</a>
评论 #26496485 未加载
tiffanyhabout 4 years ago
This is interesting.<p>I really wish this super small library named Chartist was more actively developed. It&#x27;s only 10kb in size and generates SVG charts.<p>The huge benefit of SVG is that it&#x27;s natively responsive and also prints extremely well. Wheres CSS doesn&#x27;t<p><a href="https:&#x2F;&#x2F;gionkunz.github.io&#x2F;chartist-js&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gionkunz.github.io&#x2F;chartist-js&#x2F;</a>
评论 #26496112 未加载
ad404b8a372f2b9about 4 years ago
I&#x27;m intrigued, I love CSS-only solutions. The examples are lacking plots with both x &amp; y axes labels though which is among the minimum required functionalities for plotting.
评论 #26496309 未加载
activatedgeekabout 4 years ago
Somehow, I don&#x27;t see the mention of the Vega visualization grammar [1] as a potential charting library. I think it is incredibly well-done, and is generally intuitive in its API. I&#x27;ve mostly used it through the Python bindings called Altair [2]. The good part is that that general grammar carries over to the browser as a full JSON spec that can be used directly in any language that supports JSON and has a Vega binding (which is pretty much all popular languages).<p>Having said that, I had to unfortunately abandon it because the ad-hoc control with Matplotlib [3] in Python is just infectious. Visual manipulations are far less easy to do in Vega. Being in JSON is also a restrictive though, because it is less interpretable by unstructured bots, where charts.css probably excels by design.<p>[1]: <a href="https:&#x2F;&#x2F;vega.github.io" rel="nofollow">https:&#x2F;&#x2F;vega.github.io</a> [2]: <a href="https:&#x2F;&#x2F;altair-viz.github.io" rel="nofollow">https:&#x2F;&#x2F;altair-viz.github.io</a> [3]: <a href="https:&#x2F;&#x2F;matplotlib.org" rel="nofollow">https:&#x2F;&#x2F;matplotlib.org</a>
评论 #26500461 未加载
tambourine_manabout 4 years ago
This is brilliant. It&#x27;s all done with clip-path and CSS variables.<p>That said, it&#x27;s a bit of a hack. The best kind of hack, the crazy smart kind, but still a hack. And as such, there are some visualization glitches here and there you wouldn&#x27;t get with Canvas or SVG.<p>Still, such a cool idea. I love stretching technologies way beyond their original intent.
评论 #26498905 未加载
open-source-uxabout 4 years ago
Related: If you are interested in understanding when to use a particular type of chart and the best practice for labelling charts, the following is an excellent introduction to the topic:<p><i>Introduction to data visualisation:</i><p><a href="https:&#x2F;&#x2F;gss.civilservice.gov.uk&#x2F;policy-store&#x2F;introduction-to-data-visualisation&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gss.civilservice.gov.uk&#x2F;policy-store&#x2F;introduction-to...</a>
评论 #26496286 未加载
TrueDualityabout 4 years ago
On the Usage page it shows everything but the result of applying the Chart styling which is one of the first things I want to see in a project like this.<p>Are there any sample graphs using more than 5 data points? I&#x27;d also want to see how this scales to reasonable blog-post level graphs which will probably be in the 30+ point range (a data point every five minutes covering a 3 hour range, or hourly for a week, both seem like reasonable minimum data sizes to be able to render well).<p>I love the potential accessibility benefits of using data tables directly styled like this.
privatemonkeyabout 4 years ago
Awesome. With a build step to do some data conversion I can see this being a more accessible option than rendering with canvas or SVG. Not that tables are that accessible but still, a better option. I think you could make that into the main selling point for your apporoach as it&#x27;s an overlooked and difficult area of visualisation.<p>Apart from different chart types, examples on how to rig data&#x2F;image export will make this even more usefull.<p>I currently work on accessibility guidelines for visualisations at a national bureau of statistics. This came just at the right time for me as I&#x27;m exploring options to improve accessibility beyond the capabilities of libraries like highcharts, vega, charts.js etc. Don&#x27;t hesitate to contact me. I&#x27;m very interested in the possibilities in this approach.
评论 #26503538 未加载
brundolfabout 4 years ago
I love a good CSS-only solution because of its statelessness; makes things much easier to reason about IMO. Of course in this case you&#x27;ll probably have to generate your HTML in some procedural way anyway, but it&#x27;s still a neat option to have, especially if you&#x27;re statically-rendering your pages (you can avoid using JS entirely)
评论 #26496218 未加载
评论 #26496335 未加载
soperjabout 4 years ago
I don&#x27;t feel like they&#x27;re far off here. The legend piece looks promising, they just need to be able to label both the axes, and I think you&#x27;ve got everything you need.
评论 #26501019 未加载
评论 #26495904 未加载
sandstromabout 4 years ago
My favorite chart library is MetricsGraphics.<p>Originally developed by Mozilla, its focus is on beautiful and accurate charts, and displaying data in a good way.<p><a href="https:&#x2F;&#x2F;metricsgraphicsjs.org&#x2F;examples.htm" rel="nofollow">https:&#x2F;&#x2F;metricsgraphicsjs.org&#x2F;examples.htm</a>
评论 #26498448 未加载
评论 #26502523 未加载
评论 #26502923 未加载
neologabout 4 years ago
What is the advantage of using CSS over SVG?
评论 #26496281 未加载
评论 #26496344 未加载
评论 #26497930 未加载
评论 #26502840 未加载
numlock86about 4 years ago
What&#x27;s a bit weird is that the front page has a pie chart as animated logo, yet that chart type isn&#x27;t supported by the lib yet ...
Waterluvianabout 4 years ago
Nothing makes me happier than a UI library with a billion examples.
评论 #26502953 未加载
johnsonapabout 4 years ago
Seems like it could be a good option for super simple visualizations without having to rely on something heavier like D3.js (which I personally love using)
nt2h9uh238habout 4 years ago
1. Is this substantially faster than JS? (canvas &#x2F; .svg). Please test this exhaustively. Render time and script evaluation for JS charts is still a huge JS problem.<p>2. Can this be made interactive, e.g. on mouse-over show exact numbers? Without interactivity, it is still kinda lame
评论 #26496296 未加载
评论 #26501041 未加载
评论 #26496230 未加载
sakopovabout 4 years ago
This is beautiful work! I would love to see more interactive charts though (albeit it might already be possible with some tweaks). For example hovering over data points on line chart could pop a data point label or something similar. Amazing stuff, nevertheless.
crazypythonabout 4 years ago
Markup should be semantic data and semantic state; CSS should be styling; and JavaScript should be interactivity.<p>Make your CSS fit your HTML. Don&#x27;t make HTML fit your CSS. This framework uses semantic native tables properly.
评论 #26496228 未加载
motheproabout 4 years ago
Last year I also released a barebones chart maker using only web components [0]. Meaning you can add a chart to your webpage with just an HTML tag. [1]<p>The functionality behind this and others are simple and allow the user to fully stylize however they&#x27;d like.<p>0: <a href="https:&#x2F;&#x2F;github.com&#x2F;mothepro&#x2F;lit-chart" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mothepro&#x2F;lit-chart</a> 1: <a href="https:&#x2F;&#x2F;mothepro.github.io&#x2F;lit-chart&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mothepro.github.io&#x2F;lit-chart&#x2F;</a>
评论 #26502944 未加载
scepticallyabout 4 years ago
Amazing project! This will be very practical for my Blazor application. It&#x27;s a nice way to prevent ugly JavaScript interop wrapper for charting libraries :-)<p>I will definitely keep an eye on it!
评论 #26496154 未加载
nooyurrsdeyabout 4 years ago
Looks impressive. Documentation is clean, simple, and easy to read.<p>Library looks small (not sure how many KB) and full features for a basic charts library.
cacheskingabout 4 years ago
I really like this approach and wanted it as a react component: <a href="https:&#x2F;&#x2F;github.com&#x2F;hollanddd&#x2F;charts-css-react" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hollanddd&#x2F;charts-css-react</a><p>still a wip: &#x2F;&#x2F;TODO: docs, tests and data.
bennettfeelyabout 4 years ago
I made something similar a few months ago, a CSS pie chart generator<p><a href="https:&#x2F;&#x2F;bennettfeely.com&#x2F;csspiechart&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bennettfeely.com&#x2F;csspiechart&#x2F;</a>
larodiabout 4 years ago
Intriguing that the HN community is (every time) so excited about CSS.
评论 #26497786 未加载
videogreg93about 4 years ago
This is just what I needed. Currently using echarts-vue for a personal project but it&#x27;s just too hard to use for what I need it for. Too bad this doesn&#x27;t have pie charts yet.
zuhayeerabout 4 years ago
This is awesome for sparklines and lighter weight visualizations. The animated donuts had me hoping there would be a pie &#x2F; donut chart too! Would love to see that.
评论 #26496120 未加载
nightcrackerabout 4 years ago
It&#x27;s hard to take a &quot;data visualization framework&quot; seriously if virtually all examples have unlabeled unmarked axes.
taconeabout 4 years ago
Worth noticing that the cited minified size (71 kb) does not take on account gzipping. Gzip would further reduce the payload size.
评论 #26496009 未加载
评论 #26496338 未加载
edoceoabout 4 years ago
This is un-f-believable! Sometimes I see some so rad things here that are immediately applicable.<p>I regret that I have but one upvote to give
wilsonfiifiabout 4 years ago
This looks nice. I don’t see mentioned anywhere in the docs if it supports multiline labels.
nick_urbanabout 4 years ago
This seems like it could be a great approach to charting in a Phoenix LiveView application.
jordacheabout 4 years ago
none of the charts are responsive? WOuld be hard to do with purely css?
AnonHPabout 4 years ago
Tangential comment: I’m on a phone and can’t look deeper into this site for sometime. I’m impressed with how fast the pages load from different links within this site. Anyone know or can describe the internals? Thank you, kind person.
owens99about 4 years ago
Is this more performant than JS or SVG?
savanpatelabout 4 years ago
Looks good but not practical to use. I would love to see some JS support through which I can feed in data. Looking at documentation, I did not find how can I feed data. Looks like I have to calculate it manually or hardcode it.<p>If I missed something, can you point me to the right place in documentation? That&#x27;s something that would make this useful.
评论 #26496010 未加载
评论 #26496004 未加载
chovybizzassabout 4 years ago
This looks clever but probably not practical.
评论 #26495955 未加载
评论 #26496169 未加载
评论 #26495940 未加载
评论 #26496388 未加载
评论 #26495963 未加载
d33lioabout 4 years ago
Cool, but IMO the chart style sort of looks like garbage?
评论 #26496429 未加载
Someone1234about 4 years ago
These don&#x27;t display at all in Internet Explorer 11. You either get a white square or a series of unreadable numbers.<p>That&#x27;s a non-starter for my usage unfortunately, as even degraded IE11 support is swing-able, but completely broken means we cannot use it. We&#x27;re still seeing corporations and government agencies using IE11 on a regular basis.<p>Wikimedia claims 3.9% of their users are still IE11, we&#x27;re closer to 10%, but we&#x27;re also majority desktop rather than mobile users which is also really rare in 2020.
评论 #26517266 未加载