简体   繁体   English

jQuery Flot库标签格式和调整

[英]jQuery Flot library label formatting and adjustment

I would like to align the labels to right side of the pie chart. 我想将标签对准饼图的右侧。 Currently it is on top of that. 目前最重要的是。 How do I change that? 我该如何改变?

Here is my code: 这是我的代码:

$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>";

It is producing the following output : 它产生以下输出:

enter image description here 在此处输入图片说明

Also, how do I change the color of label from black to white? 另外,如何将标签的颜色从黑色更改为白色?

Just increase the width of the container. 只需增加容器的宽度即可。

Default position of legend marker is right.. so no need to worry.. 图例标记的默认位置是正确的..因此不必担心..

在此处输入图片说明

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

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