【发布时间】:2016-02-15 15:39:42
【问题描述】:
由于某种原因,我的 chart.js 折线图不会出现在我的引导模式中:
HTML:
此链接调用我的引导模式
<a class="button" id="popup1link" href="#modal" data-toggle="modal">
<div class="col-xs-6 col-sm-4 hvr-grow placeholder">
<div id="chart">
<div><img class="img-responsive" src="/images/cumulativeline.png" alt=""/></div>
</div>
<h4 class="bold">Velocity</h4>
<span class="text-muted">User Velocity</span>
</div>
</a>
我的模态 HTML:
<div class="modal fade" id="modal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h>Modal Header</h>
<div class="modal-body">
<p>
<h3>Velocity</h3>
<br>
<canvas id="canvas" width="400" height="400"></canvas>
<p>This text shows up but the chart doesn't...</p>
</p>
</div>
<div class="modal-footer">
<p>footer</p>
</div>
</div>
</div>
</div>
</div>
我的 JS 文件:
$("#modal").on('show.bs.modal', function() {
console.log('create modal line in progress'); //this console logs out properly
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
};
var ctx = $("#canvas").get(0).getContext("2d");
var myLineChart = new Chart(ctx).Line(data);
});
有人可以帮忙吗?
【问题讨论】:
-
尝试将
show.bs.modal更改为shown.bs.modal -
有效!!你能告诉我引导文档在哪里引用吗?
标签: twitter-bootstrap modal-dialog bootstrap-modal chart.js