morrisjs donut drawn away from center point

时光总嘲笑我的痴心妄想 提交于 2019-12-12 05:29:50

问题


Chart is drawn from start each time an option is clicked (on-click event). On first couple of times the donut is drawn correctly ie with label at center, but very often donut draws away from the center. Images are shown for both correct and faulty charts. I have hi lighted border of the div to show the position of donut.

This is how it displays in view:

 <div id="donut_div" style="width:425px;height:325px;border:1px solid red;padding:8px;"></div>

Javascript code:

var neg_pts=91, pos_pts =10;
Morris.Donut({
             element: 'donut_div',
             colors: ["#9CC4E4", "#3A89C9"],
             data: [{ label: "- ive Points", value: neg_pts },{ label: "+ ive Points", value: pos_pts }],
             resize: true
            });

 $('#selected-option').on('click', 'a', function () {
    neg_pts=196;
    pos_pts =30;
    $("#donut_div").empty();

    Morris.Donut({ 
             element: 'donut_div',
             colors: ["#9CC4E4", "#3A89C9"],
             data: [{ label: "- ive Points", value: neg_pts },{ label: "+ ive Points", value: pos_pts }],
             resize: true
    });
 });//on-click

来源:https://stackoverflow.com/questions/45095815/morrisjs-donut-drawn-away-from-center-point

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!