Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Flot pie charts show data value instead of percentage
    primarykey
    data
    text
    <p>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 with the numbers of read/unread messages. </p> <p>Number of read messages: 50. Number of unread messages: 150.</p> <p>The created pie shows the percentage of read messages as 25%. On this spot i want to show the actual 50 messages. See image below:</p> <p><img src="https://i.stack.imgur.com/ksJhA.png" alt="enter image description here"></p> <p>The code i used to create the pie:</p> <pre><code>var data = [ { label: "Read", data: 50, color: '#614E43' }, { label: "Unread", data: 150, color: '#F5912D' } ]; </code></pre> <p>And:</p> <pre><code> $(function () { $.plot($("#placeholder"), data, { series: { pie: { show: true, radius: 1, label: { show: true, radius: 2 / 3, formatter: function (label, series) { return '&lt;div style="font-size:8pt;text-align:center;padding:2px;color:white;"&gt;' + label + '&lt;br/&gt;' + Math.round(series.percent) + '%&lt;/div&gt;'; }, threshold: 0.1 } } }, legend: { show: false } }); }); </code></pre> <p>Is this possible?</p> <p>With the answer of @Ryley I came to a dirty solution. When I output the series.data the values "1,150" and "1,50" were returned. I came up with the idea to substract the first 2 characters of the returned value and display the substracted value.</p> <pre><code>String(str).substring(2, str.lenght) </code></pre> <p>This is the pie chart I created with this solution:</p> <p><img src="https://i.stack.imgur.com/u7j7D.png" alt="enter image description here"></p> <p>This is not the best solution, but it works for me. if someone knows a better solution....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload