Hi,
I am new to Jfreechart library I am using AreaChart it working fine but I want shapes(triangle, squares, circles) on areachart to point the data. Like shapes in line chart. Is there anyway to implement for area chart?
In my project to paint chart binding the data dynamically. If data contains huge information then on X-axis scale is not rending properly. It is looking as a line. How to solve this problem.
Shapes on Area Chart
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Shapes on Area Chart
- Looking the annotations, e.g. XYShapeAnnotation or XYPointerAnnotation.
- Use the zoom and pan features mentioned here as needed.
Re: Shapes on Area Chart
Hi,
1. Thank you! John Matthews for your answer. I am using category plot not XY plot. In XY plots we can add dataseries only number type but my requirement is number, String type. Is there any way to give shapes for category area chart?
2. My requirement is to save the plot as image so zoom and pan will not work in the image. Can we set the range on X-axis for Category plots?
1. Thank you! John Matthews for your answer. I am using category plot not XY plot. In XY plots we can add dataseries only number type but my requirement is number, String type. Is there any way to give shapes for category area chart?
2. My requirement is to save the plot as image so zoom and pan will not work in the image. Can we set the range on X-axis for Category plots?
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Shapes on Area Chart
[[/list]
- For a CategoryPlot, you should use a CategoryAnnotation implementation.
- This example illustrates a number of zoom functions; see the ChartPanel source for the corresponding implementations.
Re: Shapes on Area Chart
Hi,
Thank you, John! I have implemented using time series in XYAreaChart as per my requirement.
Now my requirement is I have only one series in XYAreaChart but I need to differentiate datapoints with shapes. I want to add squares in green and triangles in red color. Is it possible to add different shapes in the same series?
Here is my code:
Thank you, John! I have implemented using time series in XYAreaChart as per my requirement.
Now my requirement is I have only one series in XYAreaChart but I need to differentiate datapoints with shapes. I want to add squares in green and triangles in red color. Is it possible to add different shapes in the same series?
Here is my code:
Code: Select all
JFreeChart areaChart= ChartFactory.createXYAreaChart(
"Heap Usage (after GC)","Time "+data.get(GraphDataBuilder.ZONE_OFFSET),
"Heap size ("+data.get(GraphDataBuilder.Y_AXIS_SCALE)+")",
line_chart_dataset,PlotOrientation.VERTICAL,
true,true,false);
XYPlot plot = areaChart.getXYPlot();
XYAreaRenderer renderer = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES);
DateAxis domain = new DateAxis("Time");
domain.setAutoRange(true);
if(rawJVMDuration > 84000000) {
domain.setDateFormatOverride(new SimpleDateFormat("MMM-dd hh:mm"));
} else {
domain.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss a"));
}
plot.setDomainAxis(domain);
Shape shape = new Ellipse2D.Double(-4, -4, 10, 10);
//renderer.setSeriesShape(0, ShapeUtilities.createUpTriangle(5.5f));
plot.setRenderer(renderer);
plot.getRenderer().setSeriesPaint(0, Color.decode("#1fb5ab"));
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Shapes on Area Chart
The API suggests that you override getItemShape().