Formatting jqplot Pie Chart to drop trailing zeros from percentage labels.

It also shows how to make legend text correspond to the swatch color (the square in front of the series' text).

HTML

<script language="javascript" type="text/javascript" src="https://bitbucket.org/cleonello/jqplot/raw/b5a7796a9ebf/src/jquery.jqplot.js"></script>

<script language="javascript" type="text/javascript" src="https://bitbucket.org/cleonello/jqplot/raw/b5a7796a9ebf/src/plugins/jqplot.pieRenderer.js"></script>


<div id="pieChart"></div>

CSS

#pieChart{
    width: 400px;
    height: 400px;
    color:#ffffff;
}

JavaScript

var data = [['US',33], ['IE',30], ['GB',23], ['AU',7], ['CA',4], ['RoW',7]];
        var plot1 = jQuery.jqplot('pieChart', [data],
        {
           
            seriesDefaults: {
                // Make this a pie chart.
                renderer: jQuery.jqplot.PieRenderer,
                rendererOptions: {
                    // Put data labels on the pie slices.
                    // By default, labels show the percentage of the slice.
                    sliceMargin: 5,
                    showDataLabels: true,
                }
            },
            legend: { show: true, border: false, /*placement: 'outsideGrid', location: 'w'*/location: 'e', border: 'none' },
            grid: {borderWidth:0, shadow:false, background: '#FFFFFF'}

        }
      );