I am creating pie charts using JFreeChart, and I want to set the value and the label seperately like in iReport. In other words, I want the chart to show different results on the pie than in the legend. Is there any way that I can achieve this?
The MessageFormat ArgumentIndex values correspond to the series name, domain and range. You can set a different generator for each series or for all series in the base.
PiePlot plot = (PiePlot) chart.getPlot();
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {1} {2}"));
Addendum: For PiePlot, the values have a slightly different meaning—series name, value and percentage—as shown here.
Related
Is there a way to plot waterfall charts with JavaFX? If there is no built in functionality, can we use d3.js library with JavaFX?
You could fairly easily implement this yourself using a stacked bar chart with two series:
make the first series transparent.
the value of the first series is the sum of the values added.
the value of the second series is the actual value you're adding
add an additional value with the sum of all the values
So displaying data of 10,15,20,25
Would add: {0,10},{10,15},{25,20},{45,25},{0,70}
I'm using the JFreechat API to draw an XYAreaChart with a TimeSeriesCollection dataset. The values I'm putting in the dataset are variables with no limit: they can go from 0 to more than 1000. The problem here is that I want to make the ValueAxis automatically fit the data.
I have tried to use :
XYPlot plot = mychart.getXYPlot();
ValueAxis axis = plot.getDomainAxis();
axis.setAutoRange(true);
I see that with setAutoRange, it is not so "automatically." It's true that it changes the axis when the plot gets big values, but it doesn't re-size the axis when there is no more big data as shown here:
I want that the axis Range gets back to fit the biggest value shown (~400 in this example) because it becomes hard to read the little values with this range without using zoom.
Is that possible?
I'd examine two approaches:
A dataset that discards old data such as DynamicTimeSeriesCollection, shown here.
A dataset whose series allow a maximum age such as TimeSeriesCollection, shown here.
I have a JFreeChart TimeSeries chart that has 2 data item.
I need to mark points in it.
For example I need it show at a specific time what is the line's value (while there is not actually any value and JFreeChart created line).
Example:
TimeSeries t=new TimeSeries("Test",Second.class);
Dataset.addSeries(t);
Calendar C=Calendar.getInstance();
t.add(new Second(C.getTime()), 100);
C.setTimeInMillis(C.setTimeInMillis+10*60*60*1000);
t.add(new Second(C.getTime()),200);
// Now I want Something like this psudo code
C.setTimeInMillis(C.setTimeInMillis-5*60*60*1000);
t.mark(new Second(C.getTime()));
How Can I mark points on a series by their domain value (So the range value should be calculated automatically)?
Thanks
One convenient way to show interpolated values is to enable the axis trace feature, as shown in this example.
chartPanel.setHorizontalAxisTrace(true);
chartPanel.setVerticalAxisTrace(true);
Addendum: An alternative is to add the interpolated values to the data set and suppress the display of their Shape, as shown here. The (unmarked) value will then be available to a tool tip generator, label generator, chart mouse listener, etc.
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.
I'm using an XYPlot in JFreeChart. All the lines on it are XYSeries objects. Both axes are NumberAxis objects. The Y-Axis range is from 0-1, with ticks every .1. Along with displaying the numbers though, I'd like to display text on the Y-Axis, like High/Medium/Low. High would cover .7-1, etc. What is the best way to go about doing this?
I have some JFreeChart experience, and after a little research I don't have an answer for adding the three labels to the axis.
However, as an alternative approach, you should be able to delineate these three areas on the plot with colors by setting a MarkerAxisBand for the NumberAxis (using this method).
You could then add interval markers to the MarkerAxisBand to highlight the three areas.
try this ... it can give similare result
JFreeChart Text Annotations not Working?
XYTextAnnotation textAnnotaion = new XYTextAnnotation(description, xMid, yMid);
plot.addAnnotation(textAnnotaion);
textAnnotaion.setRotationAngle(90.0);