Javascript 将图例添加到甜甜圈图表-jqPlot

Javascript 将图例添加到甜甜圈图表-jqPlot,javascript,jquery,charts,jqplot,donut-chart,Javascript,Jquery,Charts,Jqplot,Donut Chart,好的,这应该相对简单: 我正在添加一个甜甜圈图表,它确实有效 但是,“图例”(如头部(+)以及相应的颜色)不会显示 代码: $(document).ready(function(){ var s1 = [['Head (+)',<?php echo $headScore; ?>], ['Head (-)',<?php echo 6-$headScore; ?>]]; var s2 = [['Body (+)',<?php echo $totalScor

好的,这应该相对简单:

  • 我正在添加一个甜甜圈图表,它确实有效
  • 但是,“图例”(如
    头部(+)
    以及相应的颜色)不会显示
代码:

$(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' }
    }
  });
});
$(文档).ready(函数(){
变量s1=['Head(+)',],['Head(-),];
变量s2=['Body(+)',],['Body(-),];
变量plot3=$.jqplot('linkchart',[s1,s2]{
标题:“分数档案”,
系列默认值:{
//把这个做成油炸圈饼图。
渲染器:$.jqplot.DonutRenderer,
渲染器选项:{
//甜甜圈可以像馅饼一样切成片。
利润率:3,
//馅饼和甜甜圈可以从任意角度开始。
startAngle:-90,
showDataLabels:false
},
图例:{show:true,位置:'e'}
}
});
});
我做错了什么?

Kameleon

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

首先结束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' }
    });
});
我还没有测试过。但我认为它应该起作用

谢谢。

Kameleon

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

首先结束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' }
    });
});
我还没有测试过。但我认为它应该起作用


谢谢。

天哪!安妮什,非常感谢你!这真是一个愚蠢的决定,但是。。。一个我实际上无法发现自己的地方!:-)天啊!安妮什,非常感谢你!这真是一个愚蠢的决定,但是。。。一个我实际上无法发现自己的地方!:-)