Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在圆环渲染器jqplot中添加自定义标签?_Javascript_Jquery_Charts_Jqplot - Fatal编程技术网

Javascript 如何在圆环渲染器jqplot中添加自定义标签?

Javascript 如何在圆环渲染器jqplot中添加自定义标签?,javascript,jquery,charts,jqplot,Javascript,Jquery,Charts,Jqplot,我想为s1甜甜圈添加dataLabels标签,为s2添加dataLabels百分比,或者不添加标签。我该怎么做 function drawDonut(chartId){ var s1 = [['a',6], ['b',8], ['c',14], ['d',20]]; var s2 = [['e', 6], ['f', 8], ['g', 14], ['h', 20]]; var plot = $.jqpl

我想为s1甜甜圈添加dataLabels标签,为s2添加dataLabels百分比,或者不添加标签。我该怎么做

     function drawDonut(chartId){
             var s1 = [['a',6], ['b',8], ['c',14], ['d',20]];
             var s2 = [['e', 6], ['f', 8], ['g', 14], ['h', 20]];

              var plot = $.jqplot(chartId,[s1,s2], {
                seriesDefaults: {
                  // make this a donut chart.
                  renderer:$.jqplot.DonutRenderer,
                  rendererOptions:{
                    // Donut's can be cut into slices like pies.
                    sliceMargin: 0,
                    dataLabelThreshold: 0,
                    // Pies and donuts can start at any arbitrary angle.
                    startAngle: -90,
                    showDataLabels: true,
                    // By default, data labels show the percentage of the donut/pie.
                    // You can show the data 'value' or data 'label' instead.
                    dataLabels: 'label'
                  }
                }
              }


这是因为您正在设置序列默认值中的showDataLabels。查看如何设置每个系列的选项。

似乎没有人回答这个问题……您尝试了什么?你看过文档了吗,特别是我编写的代码?@AmosM.Carpenter,问题是无论我采用什么标签格式,它都会应用到两个甜甜圈上。你发布的示例代码与jqplot主页上的代码几乎相同(包括用撇号作复数杀死小狗的评论)。除了更改
数据标签
值之外,您是否尝试过其他方法?您意识到您可以自己计算百分比,并将其用作第二个系列的数据标签,对吗?如果您愿意弄脏双手,此库很容易修改。