Jquery Flot pie charts show data value instead of percentage

前端 未结 4 1789
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 05:09

I can\'t figure out how to get flot.pie to change the data shown in the labels from a percentage of the \"raw data\" to the actual data. In my example i\'ve created a pie chart

4条回答
  •  独厮守ぢ
    2021-02-05 05:46

    I found the answer to the question. The data object is a multi-dimensional array. To get the acual data use the following code:

        $(function () {
        $.plot($("#placeholder"), data,
           {
            series: {
                pie: {
                    show: true,
                    radius: 1,
                    label: {
                        show: true,
                        radius: 2 / 3,
                        formatter: function (label, series) {
                            return '
    ' + label + '
    ' + series.data[0][1] + '
    '; }, threshold: 0.1 } } }, legend: { show: false } }); });

    Notice the code " series.data[0][1] " to extract the data.

提交回复
热议问题