开发者

How to style jQuery sparklines outside of javascript

I've been trying the jQuery sparklines plugin and the style is applied in javascript e.g.

$('#barchart').sparkline('html', { type:'bar', barColor:'green' });

Is there a solution to apply and change style in a circumstance like this without editing the scripts. For example in a css stylesheet or custom file with something like

.sparkline {
    typ开发者_开发百科e: bar;
    barColor: green;
}

Perhaps the javascript would look similar to this?

$('#barchart').sparkline('html', $.getStyle('sparkline'));


No, it's not possbile, since this specific plugin is based on canvas and is completely drawn inside JavaScript. If it would use SVG, you could style the single SVG elements.

However, you can of course copy styles from other elements in the page:

var color = $('.brightgreen').css('background-color');
... barColor: color ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜