setting up the same length of ValueAxis with jfreechart - java

I am plotting several jfree charts in one window and want to align all chart.
All graph have the same range for x-axis and y-axis is displaying in the left.
However, when I am trying to set up fixed length for valuesAxis ,each graph still having different length of valueAxis.
There is extract of my code;
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setFixedDimension(40);
rangeAxis.setFixedAutoRange(40);
For time being I solved it by not displaying it at all
rangeAxis.setVisible(false);
Is these same way to set up the same length for all charts?

Consider using either a CombinedDomainXYPlot or a CombinedRangeXYPlot to display your data; both will ensure the data area is the same size for all their subplots (AFAIK).

Related

JFreeChart 's DateAxis Particular TickUnit

I create TimeSeriesChart using TimeSeriesCollection dataset. I use DateAxis for my x-axis and ValueAxis for y-axis.The problem is DateAxis.Check image
According to this image, the x-axis has so many values.I want x-axis DateTickUnit with particular value.Now my chart has 8 values. I only want that 8 values' dates. No need all dates points to display.Any suggestion for this?
Note: I don't want to switch from a Bar Rendered to a LineAndShapeRenderer looks like an XYChart.Don't want this way In jfreechart TimeSeriesCollection how to show dates which has only values?

Set number of angular grid lines to a fixed value for a PolarPlot with jfreechart

I'm facing an issue using PolarPlot with jFreeChart. My code plots a single dot with an arbitrary angle and a radius of maximum 1. Everytime I redraw the plot, the number of radial grid lines changes. This makes the program very ugly.
How can I constrain the number of lines to a predefined number?
So I found a satisfying solution:
final JFreeChart chart = ChartFactory.createPolarChart("", dataset, true, true, false);
final PolarPlot plot = (PolarPlot) chart.getPlot();
((NumberAxis)plot.getAxis()).setTickUnit(new NumberTickUnit(0.25));
plot.getAxis().setRange(-1, 1);
Important is the last line, where you set the Range, else if you only plot one single dot the spacing is correct, but the plot will be scaled and the plotted dot lies on the border.

Set "auto" Range for an XYAreaChart

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.

How to set max label lines for Date Ticks in JFreeChart Timeseries plots

I know how to create a CategoryPlot and then set the DomainAxis labels to use two lines. This is the idea:
CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
categoryAxis.setMaximumCategoryLabelLines(2); // Mmmm... nice labels
But I'm having trouble doing "the same thing" for a Timeseries chart. The problem is that the DateAxis is a ValueAxis rather than a CategoryAxis. That makes sense because the dates are values. But I don't like the look of the chart when it uses only a single line for the date. You can see a sample chart in my answer in this thread. I want to format my dates to use 2 lines. But I cannot do it like this:
DateAxis dateAxis = (DateAxis)xyPlot.getDomainAxis();
dateAxis.setMaximumCategoryLabelLines(2); // method does not exist
How can I get those Date labels onto 2 lines?
Using setVerticalTickLabels(), shown here, may alleviate the horizontal crowding; using setDateFormatOverride() may mitigate the resulting vertical space cost.

JFreeChart XYPlot with labels

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);

Categories

Resources