A font to make sparklines in seconds
aftertheflood.co
aftertheflood.co
Neat idea, and I do like the OTF hacking, but why not use simple SVG?
<svg viewBox='0 -20 85 40' style="height: 1.5em">
<!-- data in d parameter below as x,y pairs -->
<path d='m 0,0 L 10,5 20,8 30,6 40,3 50,-2 60,-8 70,4 80,6'
fill='none' stroke='black'/>
<circle cx='80' cy='6' r='2'/>
</svg>
It has the advantage of using actual data, it is trivial to generate, is embedded into HTML without an extra fetch, won't confuse screen readers, doesn't require the normal web-font alternative file format dance, and isn't quantised to a set of precreated values.Poor old SVG, it is constantly being reinvented.
{2,3,4,6,5,4,8,8}
It doesn't look like the thing you copied, and the numbers make no sense (our stock price is 8? since when?). You're back to trying to get people to install the correct fonts, not use it in emails, etc.Maybe the set notation curly brackets isn't enough of a signal to think of them as percentages if the font is unavailable, but adding that as a note when copying/pasting isn't entirely strange.
An example: our company uses redash for sharing ad hoc data sets internally. It'd be easy to generate a SQL expression with array_agg that could be wrapped in a span w/this font. I currently cruft up a call to a google charts replacement to do just that, which sucks because it adds a bunch of image requests.
I _could_ do it with SVG, too, but the expression to create it would be a lot more complex.
I can imagine submitting a PR to redash to autoformat any SQL column named "sparkline" with this font, actually.
(Valid criticism: maybe I should use a richer tool than redash for this...but I love it when a general tool can do a lot just because of composable primitives, AtF Spark fits the bill perfectly here.)
> it would be a lot more complex
I don't use redash, but isn't the 'complexity' just the boiler plate literal text? The query is rather simple.
'<svg ...etc... d="L' +
SELECT ROW_NUMBER() OVER (ORDER BY Date DESC), Value FROM Data GROUP BY Date +
'" ...etc... /></svg>'
No more complex than the google chart call, surely?To fit in the redash model, you need a single expression that returns a string of HTML. So the example you cite isn't quite there, as I don't think it's valid SQL (or is it? I'm mainly familiar with Postgres--perhaps that example is valid in some other DB?)
So you need something like:
SELECT 'preamble' || (SELECT string_agg(ROW_NUMBER() OVER (ORDER BY Date Desc), ...) || 'postamble'
Except aggregate functions can't contain window functions, so something like:
WITH windowed as (SELECT ROW_NUMBER(), ...) SELECT 'preamble' || (SELECT string_agg(row_number || ',' value, ',') FROM windowed) || 'postamble'
is needed. Which isn't a big deal, but since you don't really care about the row number, it's nice to be able to skip the CTE and just directly smash the values into a string_agg.
It's a minor thing, but I'm lazy.
Mind sharing what you're doing today with me (the Google Charts approach)? My email is arik at redash.io.
Thanks!
I don't disagree SVG isn't difficult and a lot more flexible, but I think in this case, the font has the advantage that it is accessible to screen readers. 345, A screen reader is going to see an SVG element and I imagine at best it will use some alt-text or other "description" of the graphic. Versus if the data is literally `123{123,234,435}424` then a person without vision can get much more information about what's actually being conveyed.
It's an interesting problem, to be sure.
Alibaba: 93.89{40,27,69,58,44,42,52,39,27,8,40,45,33,37,24,20,30,36,36,29,40,60,50,40,50,63,87,100}152.11
Brexit: 5562{4,27,48,37,60,40,56,54,59,62,37,63,30,59,75,68,50,40,47,30,5,9,50,74,59,75,100,92}7501
It only accepts numbers in the range 0-10 (for a sparkline) or 0-100 (for the bar or dot plot), and because it performs no vertical normalisation, you have to remap to that. Making either your data gibberish, or your sparkline oddly offset and scaled (e.g. if you put in the brexit FTSE data / 100).
Sounds like a job for aQuery! ;)
Because author's goal was to create charts "without using code". And SVG is much more "code" than simple "{}" markup.
[1]: https://typographica.org/typeface-reviews/chartwell/
Just as a warning, though; over the years I’ve gotten 3-4 requests by media companies to write a book on Apache Spark, so, um, watch out for that one. (Regardless of whether you know Apache Spark or not, you should go for it. I believe in you.)
Spark is awesome - makes it dead easy to parallelize work.
But it's also easy to write bad Spark code that doesn't parallelize well.
So I wrote a report to let us view key stats broken out by Spark job, including a sparkline of avg load on the machines running the job for its duration.
This provides an easy way to see whether a job uses the cluster efficiently, and if it doesn't, where the key points in the job are that it's sitting idle.
It also lets us eyeball the repeatability -- if a given batch job's sparklines are wildly varying from run to run, it usually suggests that something funky is going on in the code.
Also, it lets us have "Spark" lines. Worth it for the pun alone, IMO.
Any new HR product should have a hero page with:
- a couple of sparklines
- a mugshot of user/candidate
- some important looking numbers in a giant-assed sans serif font
Throw in a social media-like feed down the side of the page for added oomph.
Things have moved on from the days when a pie chart was table stakes.
Maybe we can just relabel everything in terms of "features discovered".
Let's say you have X buckets, with Y slots each. Each tick, you put the current value in the current slot of the first bucket, and advance the index by one. When the index reaches the number of slots, reset the index to 0, and put the average of all slots of the first bucket into the current slot of the second bucket. When the second bucket overflows, put the average into the current slot of the third bucket, and so on. This way you can fit both current and very old values into the same tiny graph, to give a rough impression of "level of activity" (e.g. for tray icons).
If that doesn't have a name yet because I invented it (I doubt that), I call it syrup buckets (syrup is how it can look like depending on the amount of buckets, slots and the tick speed).
I'm not versed on screen readers, would wrapping that text in an HTML element (like a span) with a title attribute that read: stock price for last 5 years - solve accessibility issues? How do screen readers generally handle charts?
I haven't tried it, but perhaps aria-label would do the trick.
My point is, people create these fairly novel approaches all the time, but never think about the structure of the markup, and if the semantic meaning is at least usable for screen readers. Turning on screen reading functionality in Chrome, the first example in the article read as follows:
"1 2 3 left brace 10,20,30,40,50,60,70,80,90,100 right brace 7 8 9"
The semantic meaning is lost.
The "how it works" section doesn't really explain anything, it's more of a "how to use it".
$ printf '\e]50;%s\a' '-your-x11-font-spec'
# for example:
$ printf '\e]50;%s\a' '-misc-dejavu serif-*'First, my eye gravitates towards the figures. This forced me to look at the sparkline to get the shape, go back to the left to see the y-axes min-limits, then scan to the right to see the other limit. Then, I had to read around the line in the text to understand the x-axis, then look back at the sparkline again to understand the trend line in context. It caused more confusion for me than enlightenment.
https://github.com/aftertheflood/spark#using-atf-spark-in-ms...