我在画布上画了一张图表。当我加载到由链接触发的引导模式时,模态显示为空。所以它不会加载图表。
<head>
<meta http-equiv="content-type" content="text/html"; charset="UTF-8" />
</head>
<body>
<div id="postChart" class="container text-muted" style="width:230px; padding-left:10px;">
<p>This post chart will show the number of posts of you and your friends.</p>
<canvas id="chart" style="" id="myChart" width="200" height="200"></canvas>
</div>
</body>';
的jQuery
$myId = $GLOBALS['app.user']->Id;
$currentUserNumberPost = Notification::getNumberOfPost($myId);
$currentUserName = Userfacebook::getFullname($myId);
$currentUserColor = Color::getuserColor($myId);
$friendsData_json = json_encode($friendsData);
var ctx = document.getElementById("myChart").getContext("2d");
var currentUserData = {
value:$currentUserNumberPost,
label:"$currentUserName",
color:"$currentUserColor"
};
var doughnutData = [];
doughnutData.push(currentUserData);
var friendData = $friendsData_json;
var i;
console.log(friendData);
for( i = 0; i < $numberOfFriends; i++){
var friendsData = {value:friendData[i]['Total'], color:friendData[i]['color_code'], label:friendData[i]['full_name']};
doughnutData.push( friendsData );
}
var myDoughnutchart = new Chart(ctx).Doughnut(doughnutData);
$("#postChartId").click(function(e){
$("#postChart").load("home.php?module=facebook&action=my_post_chart #postChart");
});
答案 0 :(得分:0)
jQuery-Code何时执行?准备好了? 当模态已经打开时尝试执行它。