Extra chart???

B

Brian Cecil

I'm new to OWC charts.

I'm trying to display a simple graph based on a query from a database.
It seems I am getting one more chart than I should be. As soon as I
assign the recordset to the chart datasource, I get an extra chart in
my charts collection. Any ideas?

strChartAbsPath = "c:\temp"
strChartRelPath = "temp"

Set objChartSpace = CreateObject("OWC11.ChartSpace")
Set objchart = objChartSpace.Charts.Add()
Set c = objChartSpace.Constants

objchart.Type = c.chChartTypeLine
objchart.Type = c.chChartTypeColumnClustered
objchart.HasLegend = True
objChartSpace.DisplayFieldButtons = False
Set objConn = CreateObject("ADODB.Connection")
'Other recordset stuff here...
objRS.Open "select * from testscore order by test"

Set objChartSpace.DataSource = objRS
'After the above call, I have both a objChartSpace.Charts(0) and a
'objChartSpace.Charts(1). Shouldn't I have just the
objChartSpace.Charts(0)???
objchart.SetData c.chDimSeriesNames, 0, "student"
objchart.SetData c.chDimCategories, 0, "test"
objchart.SetData c.chDimValues, 0, "score"
objchart.HasTitle = True
objchart.Title.Caption = "My Title"

For Each Axis In objchart.Axes
Axis.HasTitle = True
If Axis.Type = c.chCategoryAxis Then
Axis.Title.Caption = "Test"
Else
Axis.Title.Caption = "Score"
End If
Next
 
M

Michael Weiss

Hi Brian,
OWC 10 adds a chart to the chartspace by default when the
chartspace is created. I am assuming that OWC 11 does the
same therefore when you add a chart to the chartspace
yourself with the line
Set objchart = objChartSpace.Charts.Add()
you then end up with two charts. Try commenting out the
above line in your code below and run it and see if that
solves your problem.
Hope this helps,
Michael
 
B

Brian Cecil

Thanks Michael, but that doesn't seem to work. If I do:

Set objChart = objChartSpace.Charts(0)

right after the 'create' statement, I get an invalid parameter. There
is no chart(0) right after creation. I also get no chart(0) just be
setting the datasource to a recordset. Only after doing a charts.add()
and then setting the datasource do I get the extra chart. Strange.
 
M

Michael Weiss

That's strange, Brian. I have no experience with OWC 11
so I am at a loss for suggestions. Perhaps someone else
on the list will be able to contribute a solution.
Michael
 
T

Thao Moua [ms]

Chartspace will only add an extra chart AFTER you set the DataSource. Your
code should be

Set objChartSpace.DataSource = objRS
Set objchart = objChartSpace.Charts(0)

---------------------------------------
Thao Moua
OWC Chartspace Support

This posting is provided "AS IS" with no warranties, and
confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
---------------------------------------
 

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