I want to include a PieChart subplot over a JFree BarChart. The idea is represent how many items are included in the chart vs the total number of items to see how long is the Long Tail.
Here you can a sample image. How can I build something similar with JFreeChart?
You can create a BufferedImage from any chart using createBufferedImage() and add it to a chart as an XYImageAnnotation.
Related
I am using DynamicReports, whose chart based on JFreeChart. I want to draw chart like image link:
I have Created Pie Chart using PhilJay MPAndroidChart but i do not want Text and figure written on pie chart it should be beside of pie chart with color an description with figure. now it display at downside without figure.
To remove x-Values use pieChart.setDrawSliceText(false).
To remove y-Values use pieChart.getData().setDrawValues(false).
pieChart.setDrawSliceText(false) has been deprecated so use pieChart.setDrawEntryLabels(false) instead
I created a line chart:
But I want it to make it looks like this. I also don't know what kind of chart is this.
I want to make also have a shadow and circle nodes in it. Just like this:
How can I do this? By the way I'm displaying the chart in the webpage as PNG image format if it is relevant to my question. Thanks in advance.
For info, the sample chart you are trying to replicate is included in the JFreeChart demo collection. The complete source code for the demos is included with the JFreeChart Developer Guide. You could save yourself some time and your company some money by asking them to buy the JFreeChart Developer Guide, it's not so expensive. On to the answer...
The shadow effect you are looking for can be added to any CategoryPlot or XYPlot by setting the shadow generator:
plot.setShadowGenerator(new DefaultShadowGenerator());
It looks nice, but be aware that it requires rendering the chart as a bitmap so it won't play so nicely if you are exporting your charts to SVG or PDF or other vector formats.
The shapes on the lines can be added by changing attributes on the renderer you are using (LineAndShapeRenderer in this case).
LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setBaseShapesVisible(true);
The setBaseShapesVisible() method sets the default (or 'base') flag value for all series. You can override that default on a per-series basis if you want to. You may also want to tweak the colors being used...by default all the shapes are drawn and filled using the series color, but there are flags that can be set to make the renderer use the series fill and series outline colors (which is done in the example to get the white fill in the shapes).
The JFreeChart renderers are very configurable, so I suggest you spend some time looking through the API documentation to see what is possible.
Here's your solution:
LineAndShapeRenderer renderer
= (LineAndShapeRenderer) plot.getRenderer();
renderer.setBaseShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setUseFillPaint(true);
renderer.setBaseFillPaint(Color.white);
renderer.setSeriesStroke(0, new BasicStroke(3.0f));
renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
renderer.setSeriesShape(0, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
Is it possible to draw scatter chart with horizontal and vertical line on the specific data-point in iReport or any other reporting tool except Excel?
Sure, as iReport Charts are based on the JFreeChart Library and you can bind a ChartCustomizer to your chart in iReport, that should not be a big problem.
Search google for these catchwords and you'll get ahead.
I am using JFreeChart to create pie charts. Values are displayed outside pie chart sectors as labels. I want to display the values within the pie sectors. How can I achieve this. Please can any one help me?
Use setSimpleLabels(), as shown below; org.jfree.chart.demo.PieChartDemo1 is a good starting point.
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSimpleLabels(true);
If you are using createPieChart3D to create Pie chart, following URL will be helpful to you.
http://www.java2s.com/Code/Java/Chart/JFreeChartPieChart3DDemo1.htm
What I know is, showing values inside is default feature of the chart. If you're unable to do so it seems that you have changed the default way.