OWC11 .NET Bars seem to be out of order with the Legend


M

mcbensch

It seems like the bars, in the chart referenced below, are backwards in
order from the Legend shown, and also how they were entered into the
contol. Is there a reason in my code for this? Or is there a
property/method that will order them in the same order as the legend?

Picture of chart Generated:

http://i91.photobucket.com/albums/k303/mcbensch/Chart1.png

CODE:

Private Sub LoadEmUp()
Dim cAT0() = {"1.F", "1.E", "1.D", "1.C", "1.B", "1.A"}
Dim arV0() = {0.5, 0.3, 0.8, 0.4, 0.9, 0.2}
Dim cAT1() = {"1.F", "1.E", "1.D", "1.C", "1.B", "1.A"}
Dim arV1() = {0.55, 0.33, 0.88, 0.45, 0.95, 0.23}
Dim cAT2() = {"1.F", "1.E", "1.D", "1.C", "1.B", "1.A"}
Dim arV2() = {0.6, 0.4, 0.9, 0.5, 1, 0.3}

Dim sername() = {"Site1", "Site2 ", "Site3 ."}

Dim mChartSpace As New Owc11.ChartSpace
Dim mchart As Owc11.ChChart
Dim mchart_series As Owc11.ChSeries

mchart = mChartSpace.Charts.Add(0)
mchart.Type = Owc11.ChartChartTypeEnum.chChartTypeBarClustered

mchart_series = mchart.SeriesCollection.Add()


mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimSeriesNames,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, sername(0))

mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimCategories,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, cAT0)
mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimValues,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, arV0)

mchart_series = mchart.SeriesCollection.Add()


mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimSeriesNames,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, sername(1))

mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimCategories,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, cAT1)
mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimValues,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, arV1)

mchart_series = mchart.SeriesCollection.Add()


mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimSeriesNames,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, sername(2))

mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimCategories,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, cAT2)
mchart_series.SetData(Owc11.ChartDimensionsEnum.chDimValues,
Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, arV2)

With mchart
.PlotArea.Interior.Color = "White"
.HasLegend = True
.Legend.Position =
Owc11.ChartLegendPositionEnum.chLegendPositionBottom
.HasTitle = True
.Title.Caption = "Chart1"
.Title.Position =
Owc11.ChartTitlePositionEnum.chTitlePositionTop

.Axes(Owc11.ChartAxisTypeEnum.chValueAxis).Position =
Owc11.ChartAxisPositionEnum.chAxisPositionTop

.Axes(0).HasTitle = True
.Axes(0).Title.Caption = "Y axis"

.Axes(1).HasTitle = True
.Axes(1).Title.Caption = "X axis"

.Axes(1).NumberFormat = "0%"
.Axes(1).MajorUnit = 0.05

For Each xSer As Owc11.ChSeries In mchart.SeriesCollection
xSer.DataLabelsCollection.Add()
xSer.DataLabelsCollection(0).HasSeriesName = True
xSer.DataLabelsCollection(0).NumberFormat = "0%"
xSer.DataLabelsCollection(0).Position =
Owc11.ChartDataLabelPositionEnum.chLabelPositionInsideEnd
xSer.DataLabelsCollection(0).Interior.Color = "White"
Next

End With

Response.ContentType = "image/png"
Response.BinaryWrite(mChartSpace.GetPicture("png", 720, 900))
Response.End()
End Sub
 
Ad

Advertisements

A

Alvin Bruney [MVP]

I believe it is because of the type of chart. You can choose to either
re-arrange the order of the legend or the bars, legend is probably easier if
you use the index of the legend collection.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
 

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