向圆环图添加图例 - jqPlot [英] Add Legend to Donut Chart - jqPlot

查看:535
本文介绍了向圆环图添加图例 - jqPlot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这应该比较简单:






  • 我添加了一个圆环图,可以工作

  • 但是,'legend'(如 Head(+)以及相应的颜色)不会显示。



代码:

  $(document).ready(function(){
var s1 = [['Head(+)',<?php echo $ headScore;?>],['Head( - )',<?php echo 6- $ headScore;?& b $ b var s2 = [['Body(+)',<?php echo $ totalScore- $ headScore;?>],['Body( - )',<?php echo 7 $ totalScore + $ headScore ; $>]];

var plot3 = $ .jqplot('linkchart',[s1,s2],{
title:Score Profile,
seriesDefaults: {
// make this a donut chart。
renderer:$。jqplot.DonutRenderer,
rendererOptions:{
//甜甜圈可以切成片状b sliceMargin:3,
//饼和甜甜圈可以从任意角度开始。
startAngle:-90,
showDataLabels:false
},
legend:{show:true,location:'e'}
}
} ;
});

我做错了什么?

解决方案

Kameleon,



看起来你犯了一个愚蠢的错误。 :)



首先结束seriesDefaults属性,然后定义图例。



系列默认值。

  var plot3 = $ .jqplot('linkchart',[s1,s2],{
title: Score Profile,
seriesDefaults:{
// make this a donut chart。
renderer:$。jqplot.DonutRenderer,
rendererOptions:{
// Donut's
sliceMargin:3,
//饼和甜甜圈可以从任意角度开始
startAngle:-90,
showDataLabels:false
} //不在这里...
},
//将图例放在这里....
legend:{show:true,location:'e'}
});
});

我没有测试它。但我认为它应该工作。



谢谢。


OK, this should be relatively simple :

  • I'm adding a donut chart, which does work
  • However, the 'legend' (like Head (+) along with the corresponding colour) does NOT show up.

Code :

$(document).ready(function(){
  var s1 = [['Head (+)',<?php echo $headScore; ?>], ['Head (-)',<?php echo 6-$headScore; ?>]];
  var s2 = [['Body (+)',<?php echo $totalScore-$headScore; ?>], ['Body (-)',<?php echo 7-$totalScore+$headScore; ?>]];

  var plot3 = $.jqplot('linkchart', [s1,s2], {
      title:"Score Profile",
    seriesDefaults: {
      // make this a donut chart.
      renderer:$.jqplot.DonutRenderer,
      rendererOptions:{
        // Donut's can be cut into slices like pies.
        sliceMargin: 3,
        // Pies and donuts can start at any arbitrary angle.
        startAngle: -90,
        showDataLabels: false
      },
      legend: { show:true, location: 'e' }
    }
  });
});

What am I doing wrong?

解决方案

Kameleon,

It looks like you have done a silly mistake. : )

First end the seriesDefaults property and then define the legend.

You have placed the legend inside the seriesDefaults.

var plot3 = $.jqplot('linkchart', [s1,s2], {
    title:"Score Profile",
        seriesDefaults: {
            // make this a donut chart.
            renderer:$.jqplot.DonutRenderer,
            rendererOptions:{
                // Donut's can be cut into slices like pies.
                sliceMargin: 3,
                // Pies and donuts can start at any arbitrary angle.
                startAngle: -90,
                showDataLabels: false
            } // Not here...
        },
        //Place the legend here....
        legend: { show:true, location: 'e' }
    });
});

I have not tested it. But I think it should work.

Thank you.

这篇关于向圆环图添加图例 - jqPlot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆