OWC11 Chart - How to programmatically change AutoCalc properties of Series from Sum to Average

P

Primoz Orehar

Hi!

In an MS Access form I am trying to represent data in chart object (OWC11)
with different series.

Everything works fine but I can't change default AutoCalc property from Sum
to Average. It's possible and works in runtime with right click on the
series AutoCalc a Average, but I want to do this in code because I'd like to
prevent user to change this property in runtime. I found an example which
work with different property like (chCommandShowDropZones) but they don't
work with chCommandAverage.

Dim ssConstants

Dim ChartSpace1 As OWC10.ChartSpace
Set ssConstants = CSpace.Constants

If (CSpace.Commands(ssConstants.chCommandShowDropZones).Checked = True) Then
CSpace.Commands(ssConstants.chCommandShowDropZones).Execute
End If

If I change the line
CSpace.Commands(ssConstants.chCommandShowDropZones).Execute with

CSpace.Commands(ssConstants.chCommandAverage).Execute the computer return
error: "Application-defined or object-defined error".

Hoping some of you can help me...
Many thanks in advance, you saved my day few times
already!!!

Primoz
 
T

Thao Moua [ms]

The code is correct, however it will only work depending
on your data in the Data drop zone. If data in the Data
dropzone is numeric then you can perform AutoCalc (sum,
average, min, max, etc) otherwise the AutoCalc defaults
to Count and you cannot change it. I think the later
case is what you are experiencing. Try to verify your
data.

Thao Moua
OWC Webchart 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
-----Original Message-----
Hi!

In an MS Access form I am trying to represent data in chart object (OWC11)
with different series.

Everything works fine but I can't change default AutoCalc property from Sum
to Average. It's possible and works in runtime with right click on the
series AutoCalc a Average, but I want to do this in code because I'd like to
prevent user to change this property in runtime. I found an example which
work with different property like
(chCommandShowDropZones) but they don't
work with chCommandAverage.

Dim ssConstants

Dim ChartSpace1 As OWC10.ChartSpace
Set ssConstants = CSpace.Constants

If (CSpace.Commands
(ssConstants.chCommandShowDropZones).Checked = True) Then
CSpace.Commands (ssConstants.chCommandShowDropZones).Execute
End If

If I change the line
CSpace.Commands
(ssConstants.chCommandShowDropZones).Execute with
 
P

Primoz Orehar

I think that there is no problem with data. I use Recordset from SQL server
2000 table and the column is numeric datatype.
And If I create this chart manually I could change AutoCalc from Sum to
Average for each series, but I can't do this in code,
I think that I must to do something before:

CSpace.Commands(ssConstants.chCommandAverage).Execute

Primoz Orehar
 
P

petert

The problem is that you have to reference (and Select) the ChChartField
object of ChartSpace control.
You can do that from chDropZone object of ChartSpace control.
(Function DropZones(dz As ChartDropZonesEnum) As ChDropZone).
Than you iterate through Field colection, select the field and execute the
command.
Code:
Dim DataDropZone1 As ChDropZone
Dim DataFields As ChChartFields
Dim ChartField As ChChartField
Dim c
Set DataDropZone1 = CSpace.DropZones(chDropZoneData)
Set DataFields = DataDropZone1.ChartFields
For j = 1 To DataFields.Count
Set ChartField = DataFields.Item((j - 1))
ChartField.Select
Set c = CSpace.Constants
CSpace.Commands(c.chCommandAverage).Execute
Next
:)
by Peter Topolsek
 
T

Thao Moua [ms]

Yes, this is correct. The chartfield must be selected to
activate AutoCalc before you can execute any command on
it.

Thao Moua
OWC Webchart 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