[英]HighCharts to 2 or more identical divs
我有以下代码,仅填充div中的1个:
$(function () {
var $container = $('.portlet_content_18');
var chart = new Highcharts.Chart({
chart: {
renderTo: $container[0],
height: 400
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
});
HTML看起来有些链接的地方:
<div class="portlet_content_18">
<div class="portlet_content_18">
如何获得它填充两个div? 还是所有div,如果有10个,20个,100个或更多个相同的div具有相同的类?
这是一个jsfiddle: http : //jsfiddle.net/Chmts/
使用$ .each:
$('.portlet_content_18').each(function(){
var chart = new Highcharts.Chart({
chart: {
renderTo: this,
height: 400
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
}));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.