Selecting a curve in jFreechart - java

I have several time series plotted with jfreechart. The graph also contains multiple annotations. I want the user to be able to select the time series or the annotations.
So far I have tried: entityCollection.getEntity(x,y) which returns me the PlotEntity and panel.getComponentAt(x,y) which gives me the chart panel.
so my question is: can jFreechart provide me with this information?

You can add a ChartMouseListener, as shown here. The ChartMouseEvent will indicate which ChartEntity subclass was found.

Related

JavaFX AreaChart Clear Data

i create a Object of a extended Area Chart. In this Area Chart is a dataSerie if the object is created. Later i will add 3 New Data Series to the Area Chart and the first dataSerie musst be deleted.
How can i delete the first dataSerie?
areachart.getData().addAll(s1, s2, s3);
Here you can see how i add the new Series into the areachart, but first i want to delete the old ones...
Thanks for your help
So now I know it! I can use the following Statement:
areachart.getData.remove(....)
But this makes another Question open! How can i get the total added Series of the Area Chart.
How can I get the information of how many series in the Area Chart are?
I fixed the problem by myself.
You can do something like this:
areachart.getData().removeAll(m_histogram.getData());
It will remove all kind of data inside the area chart!!

Does JFreeChart support this type of bar chart?

I need to render a chart like this:
NOTE: I don't need the average lines, just the basic layout.
I need to specify a few key groups ("Bill Clinton", "Ronald Reagan" etc. in this example) and then assign any number of sub-keys to each group (years in the example provided). Can it be done in JFreeChart? Thanks.
You can't do the subgrouping on the axis without writing a custom subclass of CategoryAxis. Everything else can be handled with the existing API.
As per the examples on the site, I'd say yes. By combining a labelled line chart (as with Line Chart Demo 5 on their online demo) and a bar (any bar chart demo) chart plot into a dual axis plot (dual axis demo 1 below).
In fact, Overlaid Bar Chart Demo 1 and Overlaid Bar Chart Demo 2 combined are pretty much exactly what you want.
http://www.jfree.org/jfreechart/samples.html
If you go to this link:
JFreeChart showcase jar
you can download a jar file which will launch via JNLP (Java network launcher protocol) This will showcase a large range of charts that can be created with JFree, including bar charts. I believe it contains proof that charts similar to what you desire can be made.
NOTE: You may need to tweak your security settings to run the jar file
Good luck!
I think it should work see this image is created with JFreeChart

linePlusBarChart in NVD3, rCharts and shiny

There exists an NVD3 chart for combining a line and bar chart, linePlusBarChart. This would suit my data very well. However, it does not seem to be supported natively with rCharts. As far as I can see, the NVD3 charts which are implemented in rCharts are (from examples):
scatterChart
multiBarChart
multiBarHorizontalChart
pieChart
lineChart
lineWithFocusChart
stackedAreaChart
Is it possible to get other ones to work? It may be that I have misunderstood the structure of rCharts+NVD3! I'm quite new to Java, so I would be very grateful for good references, documentation, and general help!
But my basic and immediate question is: How to get a linePlusBarChart from rCharts? Or a way to layer a lineChart onto a bar chart?
Thanks!

Creating a datatable in JavaFx

i want to create a table that is connected with my chart the idea is that it display the information on the chart in details.
here is a picture i found to give you an idea of how it should be builded (however i want the graph to be made in JavaFx and therefore the graph and table it self should be more smooth and with better graphics):
As you can see on the picture the information under for day (D1,D2,D3) is displayed right under the bars. how would i create a similar thing in JavaFx?

show the value of the graph when cursor is placed on the graph

I am using jfreechart to draw the graphs. I need to show the value when the cursor is placed on the graph.
Use the ToolTipManager. If you can register the graph as a component, you can assign a specific tooltip to it which will be displayed automatically.
If you cant use the default version it's also possible to write a custom ToolTipManager, which displays the tooltip when the cursor is over certain areas on the screen.
I've never used jfreechart tooltips before, but that maybe what you're looking for.
There a series of chart specific tooltip interface/classes in the org.jfreechart.labels package. For example, using a XyToolTipGenerator with an XYItemRenderer may do what your looking for.

Categories

Resources