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?
Related
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.
I have an XYLineChart, where the labels on the X axis are written horizontally. I would like to be able to write them vertically (descending).
I can already do this for BarCharts:
CategoryPlot plot = (CategoryPlot) chart.getPlot();
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
but an XYChart returns an XYPlot, rather than a CategoryPlot, and the getDomainAxis() of an XYPlot returns a ValueAxis, not a CategoryAxis. ValueAxis lets me call
setVerticalTickLabels(true);
which is almost there! But it draws them ascending, rather than descending. Any way around this?
Thanks,
Edit: I need the domain axis to stay at the bottom of the chart. Hadn't considered it being any other way when making the original post.
ValueAxis does this automatically in drawTickMarksAndLabels() for an axis on the RectangleEdge.TOP edge:
xyPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
Example based on a variation of ScatterAdd.
Answering my own question, this didn't seem to be possible, so I had to add the functionality to the jfreechart source myself.
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).
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.
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);