添加图例到圆环图 – jqPlot
好的,这应该相对简单:
- 我正在添加一个圆环图,它确实有效
- 但是,“图例”(如
Head (+)
以及相应的颜色)不会显示。
代码:
$(document).ready(function(){ var s1 = [['Head (+)',], ['Head (-)',]]; var s2 = [['Body (+)',], ['Body (-)',]]; 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' } } }); });
我究竟做错了什么?
KAMELEON,
看起来你犯了一个愚蠢的错误。 🙂
首先结束seriesDefaults属性,然后定义图例。
您已将图例放在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' } }); });
我没有测试过。 但我认为它应该有效。
谢谢。