gwatts / jquery.sparkline

A plugin for the jQuery javascript library to generate small sparkline charts directly in the browser
http://omnipotent.net/jquery.sparkline/
1.24k stars 278 forks source link

about tooltipFormat conflict with django view template language #78

Closed xchuan closed 11 years ago

xchuan commented 11 years ago

tooltipFormat: '{{value:levels}} - {{value}}',is there any another way to change the style of this format tooltip.

gwatts commented 11 years ago

If you want to change the CSS style associated with it, you can supply a CSS class name to the format as per the docs:

tooltipFormat: $.spformat('{{value}}', 'tooltip-class')

gwatts commented 11 years ago

Mis-read the question.. No, there's no way to use anything other than "{{...}}" currently.

You could do it in javascript though with a bit of hackery (i'm sure you can think of a neater solution for this)...

tooltipFormat: '[[value]]'.replace('[[', '\{\{').replace(']]', '\}\}')

Or if you're feeling adventurous

String.prototype.sparkCode = function() { return this.replace(/[\[\]]/g, function(m) { return String.fromCharCode(m.charCodeAt(0)+32); }) }

tooltipFormat: '[[value]]'.sparkCode()

You get the point ;-)