本文介绍了jqPlot EnhancedLegendRenderer插件不会切换饼图的系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为jqPlot图表使用了EnhancedLegendRenderer插件,但是无法使它适用于饼图。



如果我单击图例标签,它们将不会显示或隐藏系列。这是


I use EnhancedLegendRenderer plugin for my jqPlot charts, however I am unable to get it working for Pie charts.

If I click on the legend labels, they don't show or hide series. Here is jsFiddle example.

legend: {
    renderer: $.jqplot.EnhancedLegendRenderer,
    rendererOptions: {
        numberColumns: 3,
        seriesToggle: true
    },
    show: true
}

Has anybody came across and found a solution?

解决方案

The answer of Merrily somehow correct, ZingChart looks good and have such functionality out of the box, but jqPlot is free and open source.

I rewrote jqPlot Pie Chart plugins and now the Pie chart from your example will work. Here is my blog post with explanation what I changed.

Download these 2 files:

  1. extendedPieRenderer.js (it replaces jqplot.pieRenderer.js)

  2. enhancedPieLegendRenderer.js (it replacesjqplot.enhancedLegendRenderer.js)

And use them like this code:

<script type="text/javascript" src="jquery.jqplot.js"></script>
<script type="text/javascript" src="extendedPieRenderer.js"></script>
<script type="text/javascript" src="enhancedPieLegendRenderer.js"></script>
<script type="text/javascript">
...
var plot = $.jqplot('chart', data, {
    seriesDefaults: {
      renderer: $.jqplot.PieRenderer
    },
    legend: {
        renderer: $.jqplot.EnhancedPieLegendRenderer
    }
});
...
</script>

I also created this jsFiddle which you can open and verify that showing and hiding works: http://jsfiddle.net/19vzL5h2/1/

这篇关于jqPlot EnhancedLegendRenderer插件不会切换饼图的系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 00:37