Pie chart looks weird
See original GitHub issueThis is what I get when trying to get a pie chart. The code:
var chartJsOptions = {
type: 'pie',
data: {
datasets: [
{
data: [10, 10, 20, 30, 40],
backgroundColor: ['red', 'orange', 'yellow', 'green', 'blue'],
label: 'Dataset 1'
}
],
labels: ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
},
options: {}
};
var chartNode = new ChartjsNode(800, 600);
return chartNode
.drawChart(chartJsOptions)
.then(() => {
// chart is created
// get image as png buffer
return chartNode.getImageBuffer('image/png');
})
.then(buffer => {
Array.isArray(buffer); // => true
// as a stream
return chartNode.getImageStream('image/png');
})
.then(streamResult => {
// using the length property you can do things like
// directly upload the image to s3 by using the
// stream and length properties
streamResult.stream; // => Stream object
streamResult.length; // => Integer length of stream
// write to a file
return chartNode.writeImageToFile('image/png', './testimage.png');
});```
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
The issue with pie chart - From data to Viz
Bad by definition ... A pie chart is a circle divided into sectors that each represent a proportion of the whole. It is...
Read more >38 Hilarious Pie Charts That Are Absolutely True - Bored Panda
But take a look at this list, compiled by Bored Panda, for a totally different type of pie chart. Whether exposing the truth...
Read more >My pie chart does not reflect the correct percentage (excel)
A pie chart shows (when % is chosen) sections whose total area is 100%, and each section's area is a relative portion of...
Read more >A Complete Guide to Pie Charts | Tutorial by Chartio
Pie charts are a common but often misused visualization to show division of a whole into parts. Learn how to get the most...
Read more >Weird pie charts on R using ggplot - Stack Overflow
I am struggling to represent some of my data as a pie chart. The pie chart is not circular, but rather comprised of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve found a temporary workaround.
It seems the problem has to do with the math relating to chart.js finding the inner circumference of the pie chart arcs. You can see in the example at the start of this thread that it’s giving up on rendering the arc origin.
What you can do, is set a really tiny number for the cutout percentage to trick the math into doing something. Tested under Windows 10 and Server 2016
Can confirm, Windows 10 results in the same issue. My chart config works on the test website.