Квадрат, когда пирог JQPlot составляет 100% - PullRequest
1 голос
/ 12 декабря 2011

Я использую jqplot для рисования круговой диаграммы. Но когда я рисую круговую диаграмму с данными, которые представляют 100% переменной, она показывает очень странную круговую диаграмму.

enter image description here

Это мой код

<script type="text/javascript">
$(document).ready(function()
{

    $('#chart1').bind('jqplotDataHighlight', 
        function (ev, seriesIndex, pointIndex, data) 
        {
            $('#info1').html('' + data[0] + " - " + data[1] );
        }
    );

    $('#chart1').bind('jqplotDataUnhighlight', 
        function (ev) {
            $('#info1').html('&nbsp;');
        }
    ); 


    var plot1 = jQuery.jqplot ('chart1', [data],
    { 
        title: {
            text: '',   // title for the plot,
            show: true,
        },
        seriesDefaults: {
            renderer: jQuery.jqplot.PieRenderer,
            padding: 0,
            color:"#FFFFFF",    
            shadow: false,
            rendererOptions: {
              dataLabelFormatString: "<font color=white>%d%</font>",
              diameter: 135,
              showDataLabels: true, 
              sliceMargin: 1, 
              textColor: "#ABBBBB",
              lineWidth: 5
            },

        }, 
        legend: {
            show:true, location: 'e'
        },

        grid: {
            background: '#ffffff',
            shadow: false,
            borderWidth: 0
        }
    }

  );
});
</script>   

Ответы [ 2 ]

0 голосов
/ 12 декабря 2011

проблема

sliceMargin: 1,

без этого все работает нормально.

0 голосов
/ 12 декабря 2011

У вас есть две дополнительные запятые в

title: {
            text: '',   // title for the plot,
            show: true,
        },

и

        rendererOptions: {
          dataLabelFormatString: "<font color=white>%d%</font>",
          diameter: 135,
          showDataLabels: true, 
          sliceMargin: 1, 
          textColor: "#ABBBBB",
          lineWidth: 5
        },

Это недопустимо в JavaScript. Поэтому причина этой проблемы может быть следующей.

...