Plot multiple lines against two Y axes

M

michael.o'connor

I am using OWC11 and VB.NET to plot two lines against the left Y axis,
then adding a right axis with a different scale and plotting two
columns. This works fine.

On a button click from the user, I would like to add a similar set of
data series to the same chart - i.e. two more lines scaled against the
left Y axis, and two more columns scaled against the right axis, on top
of the first columns. The problem is that I cannot seem to plot the
second set of columns on top of the first. Attached is a code extract.


Dim SeriesIndex1 As Integer
Dim SeriesIndex2 As Integer
Dim s As OWC11.ChSeries

chtModel.Charts.Add()
chtModel.Charts(0).Type =
OWC11.ChartChartTypeEnum.chChartTypeColumnClustered
chtModel.Charts(0).SetData(OWC11.ChartDimensionsEnum.chDimCategories, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "1, 2, 3, 4")


'First time around
s = chtModel.Charts(0).SeriesCollection.Add
s.SetData(OWC11.ChartDimensionsEnum.chDimValues, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "130, 330, 530,
730")
s.Type = OWC11.ChartChartTypeEnum.chChartTypeLine
s.Line.Color = "Red"
SeriesIndex1 = s.Index


s = chtModel.Charts(0).SeriesCollection.Add
s.SetData(OWC11.ChartDimensionsEnum.chDimValues, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "550, 550, 550,
550")
s.Type = OWC11.ChartChartTypeEnum.chChartTypeLine
s.Line.Color = "Blue"


s = chtModel.Charts(0).SeriesCollection.Add
s.SetData(OWC11.ChartDimensionsEnum.chDimValues, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "42, 44, 46, 48")
s.Interior.Color = "Cyan"
s.Ungroup(True)
SeriesIndex2 = s.Index
Dim RAxis As OWC11.ChAxis = chtModel.Charts(0).Axes.Add( _
s.Scalings(OWC11.ChartDimensionsEnum.chDimValues))
RAxis.Scaling.Minimum = 0
RAxis.Scaling.Maximum = 100
RAxis.Position = OWC11.ChartAxisPositionEnum.chAxisPositionRight


s = chtModel.Charts(0).SeriesCollection.Add
s.SetData(OWC11.ChartDimensionsEnum.chDimValues, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "52, 54, 56, 58")
s.Interior.Color = "YellowGreen"
s.Ungroup(True)
s.Group(chtModel.Charts(0).SeriesCollection(SeriesIndex2))



'Second time around
s = chtModel.Charts(0).SeriesCollection.Add
s.SetData(OWC11.ChartDimensionsEnum.chDimValues, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "100, 300, 500,
700")
s.Type = OWC11.ChartChartTypeEnum.chChartTypeLine
s.Line.Color = "Tomato"
s.Group(chtModel.Charts(0).SeriesCollection(SeriesIndex1))


s = chtModel.Charts(0).SeriesCollection.Add
s.SetData(OWC11.ChartDimensionsEnum.chDimValues, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "650, 650, 650,
650")
s.Type = OWC11.ChartChartTypeEnum.chChartTypeLine
s.Line.Color = "SteelBlue"
s.Group(chtModel.Charts(0).SeriesCollection(SeriesIndex1))


'Plot these column against the right axis, on top of previous columns
s = chtModel.Charts(0).SeriesCollection.Add
s.SetData(OWC11.ChartDimensionsEnum.chDimValues, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "62, 64, 66, 68")
s.Interior.Color = "DarkCyan"


s = chtModel.Charts(0).SeriesCollection.Add
s.SetData(OWC11.ChartDimensionsEnum.chDimValues, _
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "32, 34, 36, 38")
s.Interior.Color = "GreenYellow"


Mike O'Connor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top