OWC11 Chart with Date X-Axis - Grouping Bug

B

Bookham Measures

Hello

I have been working with the OWC11 Chart component and I have come across
what I can only describe as a bug.

The X (category) axis for my chart is an array of dates. When there are
more than 40 subscripts in the array, (so more than 41 dates), the chart,the
values on Y-axis are completely screwed up. (I am supplying UK date
formats, which is the same as the Regional Settings on my PC.)

For example, if I pass the following:

arrXAxis(0) = #12/12/2006#
arrXAxis(1) = #13/12/2006#
arrXAxis(2) = #14/12/2006#
arrXAxis(3) = #15/12/2006#
arrXAxis(4) = #16/12/2006#
arrXAxis(5) = #17/12/2006#
arrXAxis(6) = #18/12/2006#
arrXAxis(7) = #19/12/2006#
arrXAxis(8) = #20/12/2006#
arrXAxis(9) = #21/12/2006#
arrXAxis(10) = #22/12/2006#
arrXAxis(11) = #23/12/2006#
arrXAxis(12) = #24/12/2006#
arrXAxis(13) = #25/12/2006#
arrXAxis(14) = #26/12/2006#
arrXAxis(15) = #27/12/2006#
arrXAxis(16) = #28/12/2006#
arrXAxis(17) = #29/12/2006#
arrXAxis(18) = #30/12/2006#
arrXAxis(19) = #31/12/2006#
arrXAxis(20) = #01/01/2007#
arrXAxis(21) = #02/01/2007#
arrXAxis(22) = #03/01/2007#
arrXAxis(23) = #04/01/2007#
arrXAxis(24) = #05/01/2007#
arrXAxis(25) = #06/01/2007#
arrXAxis(26) = #07/01/2007#
arrXAxis(27) = #08/01/2007#
arrXAxis(28) = #09/01/2007#
arrXAxis(29) = #10/01/2007#
arrXAxis(30) = #11/01/2007#
arrXAxis(31) = #12/01/2007#
arrXAxis(32) = #13/01/2007#
arrXAxis(33) = #14/01/2007#
arrXAxis(34) = #15/01/2007#
arrXAxis(35) = #16/01/2007#
arrXAxis(36) = #17/01/2007#
arrXAxis(37) = #18/01/2007#
arrXAxis(38) = #19/01/2007#
arrXAxis(39) = #20/01/2007#

arrValues(0) = 314
arrValues(1) = 336
arrValues(2) = 303
arrValues(3) = 324
arrValues(4) = 333
arrValues(5) = 279
arrValues(6) = 342
arrValues(7) = 335
arrValues(8) = 304
arrValues(9) = 288
arrValues(10) = 292
arrValues(11) = 306
arrValues(12) = 231
arrValues(13) = 162
arrValues(14) = 290
arrValues(15) = 386
arrValues(16) = 427
arrValues(17) = 405
arrValues(18) = 366
arrValues(19) = 310
arrValues(20) = 355
arrValues(21) = 457
arrValues(22) = 417
arrValues(23) = 397
arrValues(24) = 391
arrValues(25) = 375
arrValues(26) = 405
arrValues(27) = 407
arrValues(28) = 383
arrValues(29) = 410
arrValues(30) = 438
arrValues(31) = 365
arrValues(32) = 396
arrValues(33) = 366
arrValues(34) = 432
arrValues(35) = 411
arrValues(36) = 366
arrValues(37) = 366
arrValues(38) = 367
arrValues(39) = 367

Set objSeries1 = objChart.SeriesCollection.Add
objSeries1.SetData objChartConstants.chDimCategories,
objChartConstants.chDataLiteral, arrXAxis
objSeries1.SetData objChartConstants.chDimValues,
objChartConstants.chDataLiteral, arrValues

Then the chart displays with no issues and scales/groups the X and Y axes
correctly, (although shows the dates in US date format instead of the
supplied and configured UK format).

HOWEVER, if I then supply one more subscript in both the X and Y arrays
thus:

Dim arrXAxis(40), arrValues(40)
....
arrXAxis(40) = #20/01/2007#
....
arrValues(40) = 367

The Y-axis completely mis-reports the numbers, in thousands instead of
hundreds (as per my figures above) and plots the lines at values far greater
than those that exist in the supplied arrays.

After a bit of reading I learned that this could be something to do with the
grouping features and when I added:

objChart.Axes.Item(1).GroupingType = objChartConstants.chAxisGroupingNone

.... the problem went away!

Does anyone know anything about this? Clearly removing the grouping from
the X-axis when working with large date ranges defeats the purpose because
the number of category labels it tries to show is totally illegible and
looks awful.

Presumably I could look at manual grouping but I am loathed to spend more
time investigating workarounds for this obvious bug.

Any help would be much appreciated.

Regards

David

END OF POST - FULL SAMPLE CODE FOLLOWS
Cut and paste this in to a HTML page and view it.

<html>
<body>
<p align="center"><object id=objCharts
classid=CLSID:0002E55D-0000-0000-C000-000000000046
style="width:100%;height:480"></object></p>
</body>
<script type="text/vbscript" language="vbscript">
Dim arrXAxis(40), arrValues(40), arrLastYear(40)
arrXAxis(0) = #11/12/2006#
arrXAxis(1) = #12/12/2006#
arrXAxis(2) = #13/12/2006#
arrXAxis(3) = #14/12/2006#
arrXAxis(4) = #15/12/2006#
arrXAxis(5) = #16/12/2006#
arrXAxis(6) = #17/12/2006#
arrXAxis(7) = #18/12/2006#
arrXAxis(8) = #19/12/2006#
arrXAxis(9) = #20/12/2006#
arrXAxis(10) = #21/12/2006#
arrXAxis(11) = #22/12/2006#
arrXAxis(12) = #23/12/2006#
arrXAxis(13) = #24/12/2006#
arrXAxis(14) = #25/12/2006#
arrXAxis(15) = #26/12/2006#
arrXAxis(16) = #27/12/2006#
arrXAxis(17) = #28/12/2006#
arrXAxis(18) = #29/12/2006#
arrXAxis(19) = #30/12/2006#
arrXAxis(20) = #31/12/2006#
arrXAxis(21) = #01/01/2007#
arrXAxis(22) = #02/01/2007#
arrXAxis(23) = #03/01/2007#
arrXAxis(24) = #04/01/2007#
arrXAxis(25) = #05/01/2007#
arrXAxis(26) = #06/01/2007#
arrXAxis(27) = #07/01/2007#
arrXAxis(28) = #08/01/2007#
arrXAxis(29) = #09/01/2007#
arrXAxis(30) = #10/01/2007#
arrXAxis(31) = #11/01/2007#
arrXAxis(32) = #12/01/2007#
arrXAxis(33) = #13/01/2007#
arrXAxis(34) = #14/01/2007#
arrXAxis(35) = #15/01/2007#
arrXAxis(36) = #16/01/2007#
arrXAxis(37) = #17/01/2007#
arrXAxis(38) = #18/01/2007#
arrXAxis(39) = #19/01/2007#
arrXAxis(40) = #20/01/2007#
arrValues(0) = 368
arrValues(1) = 314
arrValues(2) = 336
arrValues(3) = 303
arrValues(4) = 324
arrValues(5) = 333
arrValues(6) = 279
arrValues(7) = 342
arrValues(8) = 335
arrValues(9) = 304
arrValues(10) = 288
arrValues(11) = 292
arrValues(12) = 306
arrValues(13) = 231
arrValues(14) = 162
arrValues(15) = 290
arrValues(16) = 386
arrValues(17) = 427
arrValues(18) = 405
arrValues(19) = 366
arrValues(20) = 310
arrValues(21) = 355
arrValues(22) = 457
arrValues(23) = 417
arrValues(24) = 397
arrValues(25) = 391
arrValues(26) = 375
arrValues(27) = 405
arrValues(28) = 407
arrValues(29) = 383
arrValues(30) = 410
arrValues(31) = 438
arrValues(32) = 365
arrValues(33) = 396
arrValues(34) = 366
arrValues(35) = 432
arrValues(36) = 411
arrValues(37) = 366
arrValues(38) = 366
arrValues(39) = 367
arrValues(40) = 367
arrLastYear(0) = 269
arrLastYear(1) = 316
arrLastYear(2) = 284
arrLastYear(3) = 323
arrLastYear(4) = 277
arrLastYear(5) = 266
arrLastYear(6) = 287
arrLastYear(7) = 292
arrLastYear(8) = 322
arrLastYear(9) = 284
arrLastYear(10) = 280
arrLastYear(11) = 284
arrLastYear(12) = 334
arrLastYear(13) = 209
arrLastYear(14) = 166
arrLastYear(15) = 268
arrLastYear(16) = 330
arrLastYear(17) = 393
arrLastYear(18) = 339
arrLastYear(19) = 393
arrLastYear(20) = 300
arrLastYear(21) = 320
arrLastYear(22) = 397
arrLastYear(23) = 421
arrLastYear(24) = 366
arrLastYear(25) = 369
arrLastYear(26) = 354
arrLastYear(27) = 296
arrLastYear(28) = 317
arrLastYear(29) = 378
arrLastYear(30) = 383
arrLastYear(31) = 369
arrLastYear(32) = 316
arrLastYear(33) = 276
arrLastYear(34) = 313
arrLastYear(35) = 317
arrLastYear(36) = 332
arrLastYear(37) = 305
arrLastYear(38) = 367
arrLastYear(39) = 334
arrLastYear(40) = 291

Sub Window_OnLoad
Dim objChart, objChartConstants, objTrendline, iTrendLinePeriod,
objSeries1, objSeries2
iTrendLinePeriod = 0
objCharts.Clear
Set objChart = objCharts.Charts.Add
Set objChartConstants = objCharts.Constants
objChart.Type = objChartConstants.chChartTypeLine
objCharts.HasChartSpaceTitle = True
objCharts.ChartSpaceTitle.Caption = "Registrations (11/12/2006 -
20/01/2007)"

' Un-comment this line to fix problem - but end up with illegible labels
' objChart.Axes.Item(1).GroupingType = objChartConstants.chAxisGroupingNone

Set objSeries1 = objChart.SeriesCollection.Add
objSeries1.SetData objChartConstants.chDimCategories,
objChartConstants.chDataLiteral, arrXAxis
objSeries1.SetData objChartConstants.chDimValues,
objChartConstants.chDataLiteral, arrValues

objSeries1.Caption = "Selected Dates"
Set objSeries2 = objChart.SeriesCollection.Add
objSeries2.Caption = "Previous Year"
objSeries2.SetData objChartConstants.chDimCategories,
objChartConstants.chDataLiteral, arrXAxis
objSeries2.SetData objChartConstants.chDimValues,
objChartConstants.chDataLiteral, arrLastYear
objCharts.HasChartSpaceLegend = True
objCharts.ChartSpaceLegend.Position =
objChartConstants.chLegendPositionBottom

If iTrendLinePeriod > 0 Then
Set objTrendLine = objSeries1.Trendlines.Add
objTrendline.Type = objChartConstants.chTrendlineTypeMovingAverage
objTrendline.Period = iTrendLinePeriod

End If
objChart.Axes.Item(1).Font.Size = 6
objChart.Axes.Item(1).Font.Name = "Small Fonts"
End Sub
</script>
</html>


Below is
 
A

Alvin Bruney [MVP]

Keep the data but remove some of the tick labels, that will clear up the
issue.
 
B

Bookham Measures

I asked if anyone knows how to fix this problem, as in, get the automatic
side of things working correctly. Am I being naive expecting something to
work as documented?

If I code the tick labels based on the date ranges I may as well code the
whole x-axis. Oh... I can't do that because when setting the x-axis I get
some other "invalid procedure call" error that loads of other people seem to
be encountering.
 

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