使用c3库(JQuery)更新圆环图

时间:2015-05-17 19:17:41

标签: jquery d3.js c3

我需要使用c3库更新圆环图。该图表由以下代码创建:

function (datapie) {   
    var chart = c3.generate({
    bindto: '#idpiechart',
    color: {
        pattern: Colors,
    },
    data: {               
        columns: datapie,
        type: 'pie',
    });
}

现在我只需要从另一个函数更新此图表,我正在使用load方法,但这不起作用:

function(updatedata){
    var pie = $("#idpiechart");            
    pie.load({
        columns: updatedata
    });
}

1 个答案:

答案 0 :(得分:3)

查看此sample code,您需要对$(document).ready(function () { var progressbar = $('#progressbar'), max = progressbar.attr('max'), time = (1000 / max) * 5, value = progressbar.val(); var loading = function () { value += 1; addValue = progressbar.val(value); $('.progress-value').html(value + '%'); if (value == max) { clearInterval(animate); $("#dialog").css('background', 'none').html('<br>Open your <a href="http://gmail.com" target="_blank">Gmail</a> to confirm your account.<br><br>Click the <i>View Account Details</i> button to view your details.').dialog("option", "title", "Your Account Has Been Created!"); } }; var animate = setInterval(function () { loading(); }, time); }); $(function () { $("#dialog").dialog({ resizable: false, width: 1000, height: 500, modal: true, title: "Creating Your Account...", buttons: { Ok: function () { $(this).dialog("close"); }, text: "View Account Details", click: function () { $(this).dialog().html('<some_html>'); } } }); }); 返回的chart对象调用update:

c3.generate