Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
675
Composite Chart (Column and Line), Line Chart never appears
posted

Hi,

I'm currently working on a project that uses Composite Charts. I've seen a couple of examples on the forum and I tried to reproduce a Composite chart composed of a Column Chart and a Line chart. When I excute the code, I can see the Colums, the X and Y Axis of the column chart. I also obtain the X and Y2 axis for my Line chart, but I never see the line on my chart. The line never appear but the data is good and I don't really understand why it doesn't work. Can someone help me with this?

Here's the code 
 

The object chtMainGraph is my Infragistics.Win.UltraWinChart.UltraChart object

The oCurrentGraph.GetData() returns this data

 Mois    CoutVoulu

 janvier       12
 février        15
 mars         18
 avril           21
 mai           24
 juin           27
 juillet         30
 août          33
 septembre 36
 octobre      39

The oCurrentGraph.GetSecondaryData() returns

  Mois2    CoutVoulu2

 janvier        16
 février         20
 mars          24
 avril            28
 mai            32
 juin            36
 juillet          40
 août           44
 septembre  48
 octobre       52

I checked the data and everything is valid

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

Dim area1 As New Infragistics.UltraChart.Resources.Appearance.ChartArea()

chtMainGraph.CompositeChart.ChartAreas.Add(area1)

Dim xaxis As New Infragistics.UltraChart.Resources.Appearance.AxisItem(chtMainGraph, UltraChart.Shared.Styles.AxisNumber.X_Axis)

xaxis.OrientationType = UltraChart.Shared.Styles.AxisNumber.X_Axis

xaxis.DataType = UltraChart.Shared.Styles.AxisDataType.String

xaxis.Labels.ItemFormat = UltraChart.Shared.Styles.AxisItemLabelFormat.ItemLabel

xaxis.SetLabelAxisType = UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries

xaxis.Labels.Layout.Behavior = UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.Auto

xaxis.Labels.Orientation = UltraChart.Shared.Styles.TextOrientation.Horizontal

Dim yaxis As New Infragistics.UltraChart.Resources.Appearance.AxisItem(chtMainGraph, UltraChart.Shared.Styles.AxisNumber.Y_Axis)

yaxis.OrientationType = UltraChart.Shared.Styles.AxisNumber.Y_Axis

yaxis.DataType = UltraChart.Shared.Styles.AxisDataType.Numeric

yaxis.Labels.ItemFormat = UltraChart.Shared.Styles.AxisItemLabelFormat.DataValue

yaxis.SetLabelAxisType = UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries

yaxis.Labels.Layout.Behavior = UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.Auto

yaxis.Labels.Orientation = UltraChart.Shared.Styles.TextOrientation.Horizontal

yaxis.RangeType = UltraChart.Shared.Styles.AxisRangeType.Custom

yaxis.RangeMin = 0

yaxis.RangeMax = 75

 

Dim xaxis2 As New Infragistics.UltraChart.Resources.Appearance.AxisItem(chtMainGraph, UltraChart.Shared.Styles.AxisNumber.X_Axis)

xaxis2.OrientationType = UltraChart.Shared.Styles.AxisNumber.X_Axis

xaxis2.DataType = UltraChart.Shared.Styles.AxisDataType.String

xaxis2.SetLabelAxisType = UltraChart.Core.Layers.SetLabelAxisType.ContinuousData

 

Dim yaxis2 As New Infragistics.UltraChart.Resources.Appearance.AxisItem(chtMainGraph, UltraChart.Shared.Styles.AxisNumber.Y2_Axis)

yaxis2.OrientationType = UltraChart.Shared.Styles.AxisNumber.Y2_Axis

yaxis2.DataType = UltraChart.Shared.Styles.AxisDataType.Numeric

yaxis2.Labels.ItemFormat = UltraChart.Shared.Styles.AxisItemLabelFormat.DataValue

yaxis2.SetLabelAxisType = UltraChart.Core.Layers.SetLabelAxisType.ContinuousData

yaxis2.RangeType = UltraChart.Shared.Styles.AxisRangeType.Custom

yaxis2.RangeMin = 0

yaxis2.RangeMax = 150

 

chtMainGraph.ChartType = UltraChart.Shared.Styles.ChartType.Composite

Dim seriesColumn As New UltraChart.Resources.Appearance.NumericSeriesDim seriesLine As New UltraChart.Resources.Appearance.NumericSeries

 

Dim appearenceColumn As New UltraChart.Resources.Appearance.ChartLayerAppearance()

Dim appearenceLine As New UltraChart.Resources.Appearance.ChartLayerAppearance()

seriesColumn.Data.DataSource = oCurrentGraph.GetData()

seriesColumn.Data.LabelColumn = "Mois"

seriesColumn.Data.ValueColumn = "CoutVoulu"

seriesLine.Data.DataSource = oCurrentGraph.GetSecondaryData()

seriesLine.Data.LabelColumn = "Mois2"

seriesLine.Data.ValueColumn = "CoutVoulu2"

appearenceColumn.ChartType = UltraChart.Shared.Styles.ChartType.ColumnChart

appearenceColumn.ChartArea = area1

appearenceColumn.Series.Add(seriesColumn)

appearenceColumn.AxisX = xaxis

appearenceColumn.AxisY = yaxis

appearenceLine.ChartType = UltraChart.Shared.Styles.ChartType.ColumnChart

appearenceLine.ChartArea = area1

appearenceLine.Series.Add(seriesLine)

appearenceLine.AxisX = xaxis2

appearenceLine.AxisY2 = yaxis2

chtMainGraph.CompositeChart.ChartLayers.Add(appearenceColumn)

chtMainGraph.CompositeChart.ChartLayers.Add(appearenceLine)

area1.Axes.Add(xaxis)

area1.Axes.Add(yaxis)

area1.Axes.Add(xaxis2)

area1.Axes.Add(yaxis2)

chtMainGraph.Series.AddRange(New Infragistics.UltraChart.Data.Series.ISeries() {seriesLine, seriesColumn})

chtMainGraph.Series.DataBind()

 

The result I get is the image attached to this post

Thanks for your answer.

 

Parents
  • 5389
    Verified Answer
    posted

    yannh,

     You are setting appearanceLine.axisX and axisY2 instead of axisY.  Change the one line of code to the following:

    appearenceLine.AxisY = yaxis2

    and you will see your second layer.  The second layer will be using the Y2 axis on the right as its Y axis.  On a side note, you have also set appearenceLine's ChartType to ColumnChart.  If you want to see a LineChart, change the ChartType to LineChart.

Reply Children