Javascript Sparklines Library


This is an unobtrusive implementation of Sparklines, done in Javascript using the new Canvas element. It has been confirmed to work in the new Firefox betas, at the very least. Until the Canvas element becomes more widely accepted, this is more of a 'fun demo' at best.

How To Use:

To use, place your data points within your HTML, like so:

<span class="sparkline">10,8,20,5...</span>

(Note: Any HTML element with a class of 'sparkline' is checked)

Then, in your CSS, you might want to have the rule:

.sparkline { display: none; }

so that non-compatible browsers don't see a huge pile of numbers.

Finally, include the library in your header, like so:

<script language="javascript" src="jspark.js"></script>

Demo

An example of this code, in action, can be found here: Demo.

Download

The JSpark library: jspark.js

This work is licensed under a Creative Commons Attribution 2.5 License.

Posted: November 12th, 2005 · Tags: canvas, javascript, firefox, cool

8 Comments (Show Comments)



Comments are closed.
Comments are automatically turned off two weeks after the original post. If you have a question concerning the content of this post, please feel free to contact me.


Current Projects

jQuery JavaScript Library

jQuery

Comprehensive DOM, Event, Animation, and Ajax JavaScript Library.

Recent Projects

Pro JavaScript Techniques

JavaScript Book

The best techniques for professional JavaScript. Published by Apress.


Hosting provided by the cool dudes at Engine Yard.