Jfreechart - can we set a datapoint form to a StackedAreaChart?
I am using Jfreechart to create an area chart. I am using StackedXYAreaChart class.
I wanted to know if we can draw shapes on data points for a StackedAreaChart (this is a line chart that we can label with each data point by setting SetSeriesShapes ()).
SetSeriesShape () method doesn't work. Anyone have an idea?
Here is what I have tried so far (please do not comment that I have an empty dataset. I am drawing a dynamic graph and the series will be filled in later):
incomingData = new TimeTableXYDataset();
final JFreeChart incomingDataChart = ChartFactory.createStackedXYAreaChart(
"Chart", "Time", "Payload (In Bytes)", incomingData, PlotOrientation.VERTICAL, true, true, false);
final StackedXYAreaRenderer renderChart = new StackedXYAreaRenderer();
renderChart.setSeriesPaint(0, Color.decode("#339900"));
renderChart.setSeriesPaint(1, Color.decode("#CC9933"));
renderChart.setSeriesPaint(2, Color.decode("#33CCFF"));
renderChart.setSeriesPaint(3, Color.decode("#FF6600"));
renderChart.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 10, 10));
renderChart.setSeriesShape(1, new Ellipse2D.Double(-3, -3, 10, 10));
renderChart.setSeriesShape(2, new Ellipse2D.Double(-3, -3, 10, 10));
renderChart.setSeriesShape(3, new Ellipse2D.Double(-3, -3, 10, 10));
incomingDatachart.getPlot().setRenderer(renderChart);
+1
chrisrhyno2003
source
to share
2 answers
You need to set the StackedXYAreaRenderer type to "shapes and lines". This renderer does not show forms by default.
StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(StackedXYAreaRenderer.SHAPES_AND_LINES);
+2
Phill treddenick
source
to share
Figure out the solution: use Statement
StackedXYAreaRenderer renderChart = new StackedXYAreaRenderer(StackedXYAreaRenderer.AREA_AND_SHAPES);
Then use
renderChart.setSeriesShape(index, Shape);
+1
chrisrhyno2003
source
to share