简体   繁体   English

无法将Js Chart加载到引导模式

[英]Can't load Js Chart into bootstrap modal

I drew a chart into the canvas. 我在画布上画了一张图表。 When i load into a bootstrap modal triggered by a link the modal is appearing empty. 当我加载到由链接触发的引导程序模式时,该模式显示为空。 So it does not load the chart. 因此,它不会加载图表。

<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 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");
    });

When is the jQuery-Code executed? 何时执行jQuery代码? On ready? 准备好了吗 Try executing it when the modal is already open. 模态已经打开时,尝试执行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM