I have seen this example of jfreechart to plot a moving graph using DynamicTimeSeriesCollection class. I need the same with custom X-Axis values. The values would be in the range of milliseconds, so I can't use Second class' constructor.
Please explain in a bit detail, I have just started with JFreeChart today
Use Millisecond in DynamicTimeSeriesCollection
Related
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 in my java application.
Problem
I want to plot a XYAreaChart whose domain axis (x-axis) should scroll horizontally automatically when we start plotting the data.
I saw the same thing in TimeSeriesCharts but I don't want any timeSeriesChart. I just want the scrolling x-axis.
You'll need to create your own SlidingXYDataset that implements XYDataset in a manner similar to how SlidingCategoryDataset implements CategoryDataset.
Addendum: As noted in a comment, a typical implementation can be found here.
I'm using a combined plot composed of 2 graph which share the same X axis (by sharing, I mean, the timeframe is the same for the two graph). The upper graph is a regular timeseries while the lower chart is a barchart. I would like to display a crosshair on the combined chart as a whole... Right now I can display crosshair only on each graph separately even thought I have specify on the combined plot that I wanted to display the crosshair. To be more explicit, I can't synchronise both crosshair... Any idea on how to achieve that ?
thanks
It would appear to work if you use a shared domain axis, as discussed here and as shown in CrosshairDemo2? In addition, an sscce might help clarify your usage.
I'd like to be able to set a colour of every point (addressed by x&y, where x is a DateTime (of joda-time, actually) and y is a double) on a chart to represent a z=f(x,y) value. Is it possible with JFreeChart?
If I understood your needs correctly I think you want to use an XYPlot with an XYBlockRenderer.
Quoting the docs:
A renderer that represents data from an XYZDataset by drawing a color block at each (x, y) point, where the color is a function of the z-value from the dataset
Check the sample image in the docs for XYBlockRenderer: http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/xy/XYBlockRenderer.html
I recommend http://www.jzy3d.org
Here are some example charts: http://www.jzy3d.org/gallery.php
And example code to plot a surface: https://github.com/jzy3d/jzy3d-api/tree/master/jzy3d-tutorials
As far as I remember that's not possible by default. You can set only one color for every plotted series. However, I think it's possible to extend AbstractRenderer and achieve what you need.
Of course there is possibility that I'm mistaking. Dont remember for sure. :P
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);