JFreechart ChartPanel not getting Transparenent
java, jfreechart, swing
Solution
I found that I have to use a transparent color both for chart and plot:
val trans = new Color(0xFF, 0xFF, 0xFF, 0)
chart.setBackgroundPaint(trans)
plot .setBackgroundPaint(trans)
Problem
I want to give the chart background a transparent look (not fully transparent but a little bit). Here is my code. I have added few code lines to add transparency, but I guess the `ChartPanel` is not getting transparent. After writing those code lines, the chart backgound is appearing gray. ``` JFreeChart chart = ChartFactory.createPieChart3D( "Full traffic view", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); PieRenderer renderer = new PieRenderer(sampleColors); renderer.setColor(p, pieDataset); p.setDepthFactor(0.07); p.setCircular(true); p.setLabelOutlinePaint(null); p.setLabelBackgroundPaint(null); p.setLabelShadowPaint(null); p.setBackgroundPaint(new Color(127, 127, 127, 64)); // tranparency code p.setBackgroundImageAlpha(0.0f); p.setSimpleLabels(true); p.setLabelGenerator(null); p.setBackgroundPaint( new GradientPaint(0, 0, Color.white, 0, 100, Color.white)); p.setDarkerSides(true); ChartPanel frame1 = new ChartPanel(chart); ChartPanel.setVisible(true); ChartPanel.add(frame1); ChartPanel.setSize(640, 400); ```