Combined chart (Gantt + Line Chart)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
anush_tv
Posts: 11
Joined: Wed Nov 06, 2013 12:46 am
antibot: No, of course not.

Combined chart (Gantt + Line Chart)

Post by anush_tv » Thu Sep 04, 2014 9:35 pm

I've been trying to display an overlay chart with Gantt chart & another line chart - Both charts shall have the same x-axis (dateaxis).
The Gantt chart is of type GanttCategoryDataset & the line graph is of type XYDataset.
Both charts will share the same xAxis (which is a date/time axis) - but Gantt will use CategoryPlot and line chart will use XYPlot.

How do I create combine these 2 chart types?

I checked out the overlaid charts example in demo, but could not use those classes to combine these 2 charts are they are different types of datasets/plots.

I'm stuck here and I will appreciate any direction to solve this problem.

anush_tv
Posts: 11
Joined: Wed Nov 06, 2013 12:46 am
antibot: No, of course not.

Re: Combined chart (Gantt + Line Chart)

Post by anush_tv » Fri Sep 05, 2014 3:49 pm

Anyone, please help!

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Combined chart (Gantt + Line Chart)

Post by david.gilbert » Sun Sep 07, 2014 4:15 am

You won't be able to do it because the Gantt chart is a CategoryPlot with a "horizontal" orientation (meaning that the y-axis is running horizontally), so the vertical axis is a CategoryAxis...but for your line chart you will require a numerical vertical axis.

With quite a lot of work, you could make something that works by using an XYPlot only, where you could use the XYBarRenderer (with the useYInterval flag set to true) to generate task bars. You would have to create the dataset to represent the tasks (maybe you could use YIntervalSeriesCollection) and use a SymbolAxis to get a numerical axis with text labels. Next, you will be able to overlay a line chart because now the plot is an XYPlot.

I don't think this would be straightforward, but it is certainly possible with enough effort. :-)
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

anush_tv
Posts: 11
Joined: Wed Nov 06, 2013 12:46 am
antibot: No, of course not.

Re: Combined chart (Gantt + Line Chart)

Post by anush_tv » Mon Sep 08, 2014 5:55 pm

Thanks David. I could not merge these charts in the same chart. But I worked around it by placing both charts one below the other, with additional logic to align their xaxis & AxisSpace, looking just like a CombinedChart

Mitanshu
Posts: 1
Joined: Wed Oct 29, 2014 6:57 am
antibot: No, of course not.

Re: Combined chart (Gantt + Line Chart)

Post by Mitanshu » Thu Nov 27, 2014 7:34 am

I want to divide the portion of chart panel in two parts.First part(Bottom part) is used for drawing of jfreechart and second part that is above the y axis line is used for displaying some other information related to graph in the form of labels.Is it possible to do so?

Locked