使用Bootstrap每10秒在2个图表之间切换

时间:2014-11-13 01:48:55

标签: html twitter-bootstrap charts carousel

我有2个图表(线条和条形图),我想每10秒左右更换一次。我尝试了Bootstrap carousel但是当我用图表的id替换图像src时,它似乎不起作用。这两个图表的ID是:

<div id="SummaryChart"></div>
<div id="DailyBarChart"></div>

有没有办法让它发挥作用?谢谢!

编辑:

<!DOCTYPE html>
<html>

<head>

<?php include 'linechart.php'; ?>
    <link href="assets/plugins/bootstrap/bootstrap.css" rel="stylesheet" />


    </head>

<body>


<div class="cycle-slideshow">
   <div id="PieChart"></div>
   <div id="DailyBarChart"></div>
</div>

        <!-- end page-wrapper -->

    <!-- end wrapper -->

    <!-- Core Scripts - Include with every page -->
    <script src="assets/plugins/bootstrap/bootstrap.min.js"></script>

    <script src="assets/scripts/zingchart-html5-min.js"></script>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://malsup.github.com/jquery.cycle2.js"></script>
</body>

</html>

似乎它只适用于图像。

1 个答案:

答案 0 :(得分:2)

使用jQuery.Cycle2,你可以这样做:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://malsup.github.io/min/jquery.cycle2.min.js"></script>

<div class="cycle-slideshow" data-cycle-timeout="10000" data-cycle-slides="> div">
    <div id="SummaryChart"></div>
    <div id="DailyBarChart"></div>
</div>