Error Bars

C

Cam Fraser

Hi all:

I am trying to add error bars to some OWC10 Charts. I am using ASP (not
..NET). So far, I've been unable to add anything other than percentage
or fixed value error bars. When I've tried using the
chErrorBarTypeCustom, the result I get is an error bar on only the
first data point in the series. Alvin J. Bruney's otherwise excellent
tome on the office web components offers nothing beyond a bare mention
of the errorbarscollection. I've attached the relevant code snippet
below. Any help you can offer would be greatly appreciated.

Cam Fraser

[snippet]

sql = "SELECT rate, year, (higher95-rate) as YHigh, (rate-lower95) as
YLow FROM " & TableName
if len(where_clause)>0 then
sql = sql & " WHERE " & where_clause & " ORDER BY year"
end if
set rs = cn.execute(sql)
i = 0
do while not rs.EOF
aXPt(i) = rs("year")
aYPt(i) = rs("rate")
aYhigh(i) = rs("YHigh")
aYlow(i) = rs("YLow")
'response.write "#"&i&" ("&rs("YHigh")&","&rs("YLow")&")"&vbCrLf
i = i + 1
rs.MoveNext
loop

set m_cspace = server.CreateObject("OWC10.ChartSpace")
set cht = m_cspace.Charts.Add()
set c = m_cspace.Constants
cht.Type = c.chChartTypeLineMarkers
cht.HasLegend = False
M_cspace.DisplayFieldButtons = False

set m_cspace.DataSource = m_rs
cht.SetData c.chDimCategories, c.chDataLiteral, aXPt
cht.SetData c.chDimValues, 0, aYPt
'add error bars
set ErrorBar1 = cht.SeriesCollection(1).ErrorBarsCollection.Add()

ErrorBar1.Type = c.chErrorBarTypeCustom
ErrorBar1.Line.Color = "Green"
ErrorBar1.SetData c.chErrorBarPlusValues, c.chDataLiteral, "YHigh"
ErrorBar1.SetData c.chErrorBarMinusValues, c.chDataLiteral, "YLow"

[/snippet]
 
A

Alvin Bruney - ASP.NET MVP

Alvin J. Bruney's otherwise excellent
tome on the office web components offers nothing beyond a bare mention
of the errorbarscollection
I couldn't put everything...:)

Write a small loop to print out the values that you expect the error bars to
show up for. See what that shows.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Cam Fraser said:
Hi all:

I am trying to add error bars to some OWC10 Charts. I am using ASP (not
.NET). So far, I've been unable to add anything other than percentage
or fixed value error bars. When I've tried using the
chErrorBarTypeCustom, the result I get is an error bar on only the
first data point in the series. Alvin J. Bruney's otherwise excellent
tome on the office web components offers nothing beyond a bare mention
of the errorbarscollection. I've attached the relevant code snippet
below. Any help you can offer would be greatly appreciated.

Cam Fraser

[snippet]

sql = "SELECT rate, year, (higher95-rate) as YHigh, (rate-lower95) as
YLow FROM " & TableName
if len(where_clause)>0 then
sql = sql & " WHERE " & where_clause & " ORDER BY year"
end if
set rs = cn.execute(sql)
i = 0
do while not rs.EOF
aXPt(i) = rs("year")
aYPt(i) = rs("rate")
aYhigh(i) = rs("YHigh")
aYlow(i) = rs("YLow")
'response.write "#"&i&" ("&rs("YHigh")&","&rs("YLow")&")"&vbCrLf
i = i + 1
rs.MoveNext
loop

set m_cspace = server.CreateObject("OWC10.ChartSpace")
set cht = m_cspace.Charts.Add()
set c = m_cspace.Constants
cht.Type = c.chChartTypeLineMarkers
cht.HasLegend = False
M_cspace.DisplayFieldButtons = False

set m_cspace.DataSource = m_rs
cht.SetData c.chDimCategories, c.chDataLiteral, aXPt
cht.SetData c.chDimValues, 0, aYPt
'add error bars
set ErrorBar1 = cht.SeriesCollection(1).ErrorBarsCollection.Add()

ErrorBar1.Type = c.chErrorBarTypeCustom
ErrorBar1.Line.Color = "Green"
ErrorBar1.SetData c.chErrorBarPlusValues, c.chDataLiteral, "YHigh"
ErrorBar1.SetData c.chErrorBarMinusValues, c.chDataLiteral, "YLow"

[/snippet]
 
C

Cam Fraser

Hi Alvin:

Before I give the data, I just wanted to note that there is an error in
what I posted. The last two lines should read:
ErrorBar1.SetData c.chErrorBarPlusValues, c.chDataLiteral,
"YHigh"
ErrorBar1.SetData c.chErrorBarMinusValues, c.chDataLiteral,
"YLow"

The data I get looks correct:
aXpt(0)=1986
aYpt(0)=27.2141882216993
aYhigh(0)=6.61508873664078
aYlow(0)=6.61508873664079

aXpt(1)=1987
aYpt(1)=20.5033153860979
aYhigh(1)=5.68264641669822
aYlow(1)=5.68264641669822

aXpt(2)=1988
aYpt(2)=18.0469943733482
aYhigh(2)=5.27248685078475
aYlow(2)=5.27248685078475

aXpt(3)=1989
aYpt(3)=21.6782941153285
aYhigh(3)=5.72865610267482
aYlow(3)=5.72865610267482

aXpt(4)=1990
aYpt(4)=17.733162169768
aYhigh(4)=5.1241853529955
aYlow(4)=5.1241853529955

aXpt(5)=1991
aYpt(5)=19.1019778187834
aYhigh(5)=5.29429238576376
aYlow(5)=5.29429238576376

aXpt(6)=1992
aYpt(6)=27.7835924565644
aYhigh(6)=6.37268866188023
aYlow(6)=6.37268866188023

aXpt(7)=1993
aYpt(7)=25.7541744826102
aYhigh(7)=6.16609727820822
aYlow(7)=6.16609727820822

aXpt(8)=1994
aYpt(8)=21.5130310296137
aYhigh(8)=5.68498875866178
aYlow(8)=5.68498875866178

Any suggestions?
 
C

Cam Fraser

Hmm... I replied to this message already, but it doesn't seem to be
showing up. I'll try again.

Before I give you the data, I just wanted to note that there is an
error in the code snippet I posted. The last two lines should read:

ErrorBar1.SetData c.chErrorBarPlusValues, c.chDataLiteral,
aYhigh
ErrorBar1.SetData c.chErrorBarMinusValues, c.chDataLiteral,
aYlow

The data from the arrays is given below.

Any thoughts?

Cam

aXpt(0)=1986
aYpt(0)=27.2141882216993
aYhigh(0)=6.61508873664078
aYlow(0)=6.61508873664079

aXpt(1)=1987
aYpt(1)=20.5033153860979
aYhigh(1)=5.68264641669822
aYlow(1)=5.68264641669822

aXpt(2)=1988
aYpt(2)=18.0469943733482
aYhigh(2)=5.27248685078475
aYlow(2)=5.27248685078475

aXpt(3)=1989
aYpt(3)=21.6782941153285
aYhigh(3)=5.72865610267482
aYlow(3)=5.72865610267482

aXpt(4)=1990
aYpt(4)=17.733162169768
aYhigh(4)=5.1241853529955
aYlow(4)=5.1241853529955

aXpt(5)=1991
aYpt(5)=19.1019778187834
aYhigh(5)=5.29429238576376
aYlow(5)=5.29429238576376

aXpt(6)=1992
aYpt(6)=27.7835924565644
aYhigh(6)=6.37268866188023
aYlow(6)=6.37268866188023

aXpt(7)=1993
aYpt(7)=25.7541744826102
aYhigh(7)=6.16609727820822
aYlow(7)=6.16609727820822

aXpt(8)=1994
aYpt(8)=21.5130310296137
aYhigh(8)=5.68498875866178
aYlow(8)=5.68498875866178
 
A

Alvin Bruney - ASP.NET MVP

It will probably be the weekend before I can get to the message - i'm a bit
pressed for time right now.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
A

Alvin Bruney - ASP.NET MVP

you need to provide me a complete application with data already included
that i can paste into a project and start working. Please paste a cmplete
working example that demostrates the problem if this is still an issue.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Alvin Bruney - ASP.NET MVP said:
It will probably be the weekend before I can get to the message - i'm a bit
pressed for time right now.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Cam Fraser said:
Hmm... I replied to this message already, but it doesn't seem to be
showing up. I'll try again.

Before I give you the data, I just wanted to note that there is an
error in the code snippet I posted. The last two lines should read:

ErrorBar1.SetData c.chErrorBarPlusValues, c.chDataLiteral,
aYhigh
ErrorBar1.SetData c.chErrorBarMinusValues, c.chDataLiteral,
aYlow

The data from the arrays is given below.

Any thoughts?

Cam

aXpt(0)=1986
aYpt(0)=27.2141882216993
aYhigh(0)=6.61508873664078
aYlow(0)=6.61508873664079

aXpt(1)=1987
aYpt(1)=20.5033153860979
aYhigh(1)=5.68264641669822
aYlow(1)=5.68264641669822

aXpt(2)=1988
aYpt(2)=18.0469943733482
aYhigh(2)=5.27248685078475
aYlow(2)=5.27248685078475

aXpt(3)=1989
aYpt(3)=21.6782941153285
aYhigh(3)=5.72865610267482
aYlow(3)=5.72865610267482

aXpt(4)=1990
aYpt(4)=17.733162169768
aYhigh(4)=5.1241853529955
aYlow(4)=5.1241853529955

aXpt(5)=1991
aYpt(5)=19.1019778187834
aYhigh(5)=5.29429238576376
aYlow(5)=5.29429238576376

aXpt(6)=1992
aYpt(6)=27.7835924565644
aYhigh(6)=6.37268866188023
aYlow(6)=6.37268866188023

aXpt(7)=1993
aYpt(7)=25.7541744826102
aYhigh(7)=6.16609727820822
aYlow(7)=6.16609727820822

aXpt(8)=1994
aYpt(8)=21.5130310296137
aYhigh(8)=5.68498875866178
aYlow(8)=5.68498875866178
 

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