Sparklines are a new graphical concept championed by Edward Tufte, author of a number of very cool books that you have probably already heard about. Sparklines are an idea from his forthcoming book, and he explains them in a draft chapter from that forthcoming book at sparklines.org.
If you're using a browser that understands the data: URL, here's an example of a sparkline:
Server load:
16.
Note, that this particular sparkline is hard-coded in this blog entry. The demos below show how they are dynamically generated.
As part of my newfound obsession with client-side drawing techniques (I really think it could change the web) I've created a way to generate sparkline images using client-side Java and JavaScript. This is proof-of-concept stage, but if you're running Firefox and have the Java plugin installed, click on these links to try out the demos:
- spark.html: this demo uses LiveConnect to script Java directly. It does not use an applet at all. This means it will not work in IE. I don't know about other browsers' support for this kind of direct scripting of Java classes. This demo returns a PNG image encoded in a data: URL. This also means it won't work in IE, since IE does not support the data: scheme.
- spark2.html: this demo uses a SparklineGenerator applet to create the PNG image, which it returns as a javascript: URL. This is supposed to be for compatibility with IE, but it still doesn't work in that browser for me. It could probably be made to work somehow... This demo also moves toward an unobtrusive JavaScript technique in which sparklines are coded with a new <sparkline> tag, which gets replaced by the image after document load by JavaScript and the applet.
You'll need to understand both Java and JavaScript to make use of this stuff. But if it interests you, you can use my code for any purpose as long as you attribute it to me.




Have you seen TiddlyWiki's javascript only implementation of spark lines?
splintor: the sparkline does not appear in my IE6, which is version 6.0.2900+some other numbers and words... I wonder if this is something that broke in SP2 for Windows XP? Thanks for the reminder about replaceChild().
Dion: I think I did see TiddlyWiki's sparklines. If I remember right, they are drawn using CSS and elements to create boxes and horizontal and vertical lines, right?