简体   繁体   English

如何在 RGraph Rose 图表中管理画布的高度?

[英]How to manage hight of canvas in RGraph Rose chart?

I am using RGraph library for my assessment site.我正在为我的评估站点使用 RGraph 库。 It is working well but canvas height is creating an issue with the layout of graph.它运行良好,但画布高度在图形布局方面造成了问题。

See the image below, it results in a good output but gets cropped from the bottom and that's why the fourth category name is not being displayed.见下图,它产生了良好的输出,但从底部被裁剪,这就是第四个类别名称没有显示的原因。

在此处输入图片说明

My Rose Chart Script is as below.我的玫瑰图脚本如下。

<script>
var catnames = <?php print json_encode(array_keys($values));?>;
var results = <?php print json_encode(array_values($str_val));?>;
var tooltipval = <?php print json_encode(array_values($values));?>;
window.onload = function ()
{
    var canvas = document.getElementById("cvs");

    RGraph.Reset(canvas);

    canvas.width  = jQuery(window).width() * 0.6;
    canvas.height = jQuery(window).width() * 0.25;
    var text_size = Math.min(12, (jQuery(window).width() / 1000) * 10 );
    var linewidth = jQuery(window).width() > 500 ? 2 : 1;
        linewidth = jQuery(window).width() > 750 ? 3 : linewidth;

        var rose = new RGraph.Rose({
        id: 'cvs',
        data: results,
        options: {
            variant: 'stacked',
            labelsAxes: '',
            margin: 2.5,
            /* anglesStart: -(RGraph.HALFPI/2), */

            key:catnames,
            keyBackground:'#fff',
            keyColorShape: 'circle',
            strokestyle: 'rgba(0,0,0,0)',
             labels: catnames,
              tooltips: tooltipval,
              linewidth:linewidth,
            colorsSequential: true
        }
    }).implode();

};

In the script given above catnames is the array of categories those are displayed as labels in the graph.在上面给出的脚本中,catnames 是在图表中显示为标签的类别数组。

The code itself produces a chart with the label present.代码本身会生成一个带有标签的图表。

You could try reducing the radius using the radius: configuration property and see if the label appears by using the radius configuration property:您可以尝试使用 radius: 配置属性减小半径,并使用 radius 配置属性查看标签是否出现:

... radius: 100, ... ... 半径:100, ...

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

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