Is it possible to achieve transparent background in pie chart?
See original GitHub issueHello. I’ve been trying to generate a piechart as an asset to my pdf template.
I need it to be png with transparent background but I’m only getting black solid colour instead.
Maybe I’m missing some property or doing something wrong with my colour settings.
Thanks!
Here is my code :
PieChart chart = new PieChartBuilder()
.width(200)
.height(200)
.theme(Styler.ChartTheme.GGPlot2)
.build();
chart.getStyler().setLegendVisible(false);
Color[] sliceColors = new Color[] {
new Color(238, 88, 88), //red
new Color(213, 122, 212), //purple
new Color(106,230, 182), //mentol
new Color(88,155,238) //baby blue
};
chart.getStyler().setSeriesColors(sliceColors);
chart.getStyler().setChartTitleBoxVisible(false);
chart.getStyler().setHasAnnotations(false);
chart.getStyler().setChartBackgroundColor(
new Color(255,255, 255, 0)
);
chart.getStyler().setPlotBackgroundColor(
new Color(255,255, 255, 0)
);
chart.getStyler().setPlotBorderVisible(false);
chart.addSeries("laptop", 65);
chart.addSeries("pc", 10);
chart.addSeries("tel", 12.5);
chart.addSeries("winda", 12.5);
BitmapEncoder.saveBitmap(chart, "./Sample_Chart", BitmapEncoder.BitmapFormat.PNG);
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Make a Transparent Chart in Excel - TeachExcel.com
How to make a Chart transparent so that it blends in with its background and surroundings in Excel. ... Hit Close at the...
Read more >Center pie chart on its transparent background - Stack Overflow
Is there a way to adjust the code so the circle ends up centered? I've fiddled with making different theme elements blank, to...
Read more >Make background transparent MS .NET CHART - MSDN
You have to set the ChartArea color to transparent and Chart1.BackColor = Color.Transparent. and if you don't want a white square behind the ......
Read more >Transparant background (Interactive Charts) - Google Groups
Dear Google Charts users, I trying to get a transparent background on my Google pie chart. Someone posted a solution for the image...
Read more >How to make a transparent image out of a graph in Excel 2010?
You can select an excel graph and choose color fill > no fill. This will remove the background from it but you can't...
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 thought that the default background had an alpha of 1, which would mean necessitating manually setting to background alpha to 0 to get the desired transparency. If it’s now exporting with no transparency, then that would also be a bug in my opinion. In fact that might be why I set the type to
TYPE_INT_RGB
originally in:@staho @timmolter The code is updated. After the test, the background of the exported image is not black. You do not need to set
alpha
. This is not a color transparency issue, but a background issue for generating images.