开发者

How to style jQuery sparklines outside of javascript

开发者 https://www.devze.com 2023-02-22 09:37 出处:网络
I\'ve been trying the jQuery sparklines plugin and the style is applied in javascript e.g. $(\'#barchart\').sparkline(\'html\', { type:\'bar\', barColor:\'green\' });

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

精彩评论

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