Jump to content
Software FX Community

Combing 2 charts into 1 chart with 2 panes?


User (Legacy)

Recommended Posts

I have a line chart and a gantt chart, but need them in a single chart with two panes ... so I am trying to get a chart to look like this:

Attached is the code that will create the two different charts and my current attempt at getting this single chart to work (which is sort of close but not quite there). Seems I am missing something to do with the axis but don't know. I have been trying the old trial and error method of coming up with this solution since all double pane examples seem to be pretty standard numeric and category charting ...

Can anyone help me on this?

post-2106-13922379645451_thumb.png

Link to comment
Share on other sites

Is this even possible with ChartFX?

"Jason" <jason@cheshire.com> wrote in message news:Gl36VrSvFHA.280@webserver3.softwarefx.com...

I have a line chart and a gantt chart, but need them in a single chart with two panes ... so I am trying to get a chart to look like this:

Attached is the code that will create the two different charts and my current attempt at getting this single chart to work (which is sort of close but not quite there). Seems I am missing something to do with the axis but don't know. I have been trying the old trial and error method of coming up with this solution since all double pane examples seem to be pretty standard numeric and category charting ...

Can anyone help me on this?

Link to comment
Share on other sites

Thanks for the reply.

I have 1 table of data that looks something like this:

Name StartYear EndYear Amount

------------------------------------------------

Job A 1/1/2000 1/1/2002 100

Job B 1/1/2002 1/1/2004 200

Job C 1/1/2004 1/1/2006 300

Job D 1/1/2006 1/1/2008 400

Like the image shows in the first post (which is a paint edited image combining two existing charts), I need to show the income as a line chart - or bar chart (will need to add additional series' of data in future to the line chart - so more lines) and the bottom chart needs to show a gantt chart of where the person was employed for the time periods that are charted above in the line chart or bar chart.

All I need to show in the labels is the year, so if the value being a date is a problem - year will work fine for the application.

Here is the code I have to create the line chart:

------------------------------------------------------------------------------------------------------------------------

With m_chartMain

.ClearData(ClearDataFlag.AllData)

.OpenData(COD.Values, 1, 4)

.OpenData(COD.XValues, 1, 4)

.XValue(0, 0) = 100

.Value(0, 0) = DateTime.Parse("1/1/2002").ToOADate

.XValue(0, 1) = 200

.Value(0, 1) = DateTime.Parse("1/1/2004").ToOADate

.XValue(0, 2) = 300

.Value(0, 2) = DateTime.Parse("1/1/2006").ToOADate

.XValue(0, 3) = 400

.Value(0, 3) = DateTime.Parse("1/1/2008").ToOADate

.CloseData(COD.XValues)

.CloseData(COD.Values)

.Gallery = SoftwareFX.ChartFX.Gallery.Lines

With .AxisY

.LabelsFormat.Format = AxisFormat.Date

.LabelsFormat.CustomFormat = "yyyy"

End With

.TypeMask = .TypeMask Or ChartType.Horz

End With

------------------------------------------------------------------------------------------------------------------------

Here is the code I have for the Gantt chart:

With m_chartMain

.ClearData(ClearDataFlag.AllData)

.OpenData(COD.Values, 1, 4)

.OpenData(COD.IniValues, 1, 4)

.IniValue(0, 0) = DateTime.Parse("1/1/2000").ToOADate

.Value(0, 0) = DateTime.Parse("1/1/2002").ToOADate

.Legend(0) = "Job A"

.IniValue(0, 1) = DateTime.Parse("1/1/2002").ToOADate

.Value(0, 1) = DateTime.Parse("1/1/2004").ToOADate

.Legend(1) = "Job B"

.IniValue(0, 2) = DateTime.Parse("1/1/2004").ToOADate

.Value(0, 2) = DateTime.Parse("1/1/2006").ToOADate

.Legend(2) = "Job C"

.IniValue(0, 3) = DateTime.Parse("1/1/2006").ToOADate

.Value(0, 3) = DateTime.Parse("1/1/2008").ToOADate

.Legend(3) = "Job D"

.CloseData(COD.Values)

.CloseData(COD.IniValues)

.Gallery = SoftwareFX.ChartFX.Gallery.Gantt

With .AxisY

.LabelsFormat.Format = AxisFormat.Date

.LabelsFormat.CustomFormat = "yyyy"

.Min = DateTime.Parse("1/1/2000").ToOADate

End With

.TypeMask = .TypeMask Or ChartType.Horz

End With

Currently I can't seem to get a chart to work with both of them in 2 panes. The attached code of the original post has the code that is as close as I can get. I seem to get close to what I want, but can't seem to get it exactly...

Link to comment
Share on other sites

Yes. You will need multiple chart objects to achieve this.

The panes are used to share the X-Axis while having multiple Y-Axis, in your case, you want a single Y-Axis (bottom of Gantt chart) and multiple X-Axis (to the left).

You will need to 1)

1) Create a chart with one series for the Gantt chart.

2) Create another chart for the lines, you have to make it horizontal (Y-Axis at the bottom) by adding the following code:

chart.TypeMask |= ChartType.Horz;

3) You can hide the top chart's Y-Axis to make it look more integrated. To hide the Y-Axis use the following code:

chart.AxisY.Style |= AxisStyle.HideText;

--

Francisco Padron

www.chartfx.com

AxisLableClipped.bmp

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...