我正在使用 morris.js 绘制图表,我想通过引导轮播显示这些图表,但是如果我这样做,Firefox 会停止响应。它们可以单独工作,但如果放在一起会崩溃。firebug 告诉我与 Raphael 库有关,但我仍然无法弄清楚。那里的任何人都遇到过类似的问题并且知道如何解决这个问题?谢谢。
这是我的代码的一部分。
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item">
<div id="A-lineChart" style="height:250px;"></div>
</div>
<div class="item">
<div id="B-lineChart" style="height:250px;"></div>
</div>
<div class="item">
<div id="C-lineChart" style="height:250px;"></div>
</div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
<script>
$('.carousel').carousel({
interval: 1000
});
$.post('/my/handler.json',{
parameter:value},
function(data){
if(data.hasOwnProperty('error')){
alert('error');
}
else{
var r = data['results']
var AData = new Array();
var BData = new Array();
var CData = new Array();
for(var i = 0; i < r.length; i++){
d = r[i];
col = {'date':date, 'A': A};
AData.push(col);
col = {'date':date, 'B': B};
BData.push(col);
col = {'date':date, 'C': C};
CData.push(col);
}
new Morris.Line({
element: 'A-lineChart',
data: AData,
xkey: 'date',
ykeys: ['A'],
labels: ['A']
});
new Morris.Line({
element: 'B-lineChart',
data:BData,
xkey:'date',
ykeys:['B'],
labels:['B']
});
new Morris.Line({
element: 'C-lineChart',
data:CData,
xkey:'date',
ykeys:['C'],
labels:['C']
});
}
});
</script>