jQuery Flot库标签格式化和调整

时间:2016-02-12 06:39:47

标签: javascript php html css flot

我想将标签对齐饼图的右侧。目前它是最重要的。我该如何改变?

这是我的代码:

$json_ar = array(
                    ["label"=> "Management Frames", "data"=> $cnt_mgt, "color"=> "#50D050"],
                    ["label"=> "Control frames", "data"=> $cnt_control, "color"=> "#005CDE" ],
                    [ "label"=> "Data Frames", "data"=> $cnt_data, "color"=> "#A52A2A" ],
                    );

        //Control vs Data vs Management
        $json = encode_to_json($json_ar);
        $pie = "    <script type='text/javascript'>
                        $(function () {    $.plot($('#cdm_pie'),$json,{series: {pie: {radius:120, show: true, label:{show:true, radius:0.5, formatter:function(label,series){var percent = Math.round(series.percent);return('&nbsp;<b>'+percent+ '%</b>');} }}},legend:{show:true,}});    });
                        </script>";
        $tables["cdm"]="<div id='wrapper' style='display: inline-flex'>
                                <div id='cdm_pie' style='float: none;width: 250px;height: 250px;'></div>
                                $pie
                        </div>";

它产生以下输出:

enter image description here

另外,如何将标签的颜色从黑色更改为白色?

1 个答案:

答案 0 :(得分:1)

只需增加容器的宽度。

图例标记的默认位置是正确的..所以不用担心..

enter image description here