我可以使用gridister.js响应c3.js图表​​吗?

时间:2018-04-20 05:52:05

标签: javascript jquery d3.js c3.js

我在gridister.js小部件中有一些c3.js图表​​。在我调整gridister.js小部件的大小时,我也希望调整图表的大小。

我尝试使用以下代码来设置c3.js图表​​的响应,但它无法正常工作

resize: {
enabled: true,
stop: function (event, ui, $widget) {
    var newDimensions = this.serialize($widget)[0];
    var height = newDimensions.size_y;
    var width = newDimensions.size_x;
    chart = d3.select('#chart_donut');

    //change the width of chart start
    d3.select("div#chart_donut")
    .append("div")
    .classed("svg-container", true) //container class to make it responsive
    .append("svg")
    //responsive SVG needs these 2 attributes and no width and height attr
    .attr("preserveAspectRatio", "xMinYMin meet")
    .attr("viewBox", "0 0 600 400")
    //class to make it responsive
    .classed("svg-content-responsive", true);
    //chart.attr("height", targetWidth / aspect);


    var positions = JSON.stringify(gridster.serialize());

    // ajax call to update widget postions in the database
    $.post(
        "doc/ajax_postion_update", {
        products: positions,
        doc_id: doc_id
    },
        function (data) {
        $("#result").html(data);
    });
}

请帮我在gridister.js小部件的大小调整中实现图表。

0 个答案:

没有答案