| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

11-26-03, 03:44
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 22
|
|
|
Problem of "Subscript out of range "
|
|
I have the the follwing ASP code for create Graph (use OWC object)
<%
' 2D array
Dim Vals(2,5)
Vals(0,0)=1
Vals(0,1)=2
Vals(0,2)=3
Vals(0,3)=4
Vals(0,4)=5
Vals(1,0)=10
Vals(1,1)=20
Vals(1,2)=30
Vals(1,3)=40
Vals(1,4)=50
' Create a Chart Object
Set oChart = CreateObject("OWC.Chart")
Set c = oChart.Constants
sCaption = "This is Graph "
oChart.Charts.Add
oChart.Charts(0).Type = oChart.Constants.chChartTypeColumnClustered
oChart.Charts(0).SeriesCollection.Add
oChart.Charts(0).SeriesCollection(0).Caption = sCaption
oChart.Charts(0).SeriesCollection(0).SetData c.chDimCategories, c.chDataLiteral, Categories
oChart.Charts(0).SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, Vals
%>
"Vals" is 2D array, I want to cteate Graph with 2 columns in each category (I have 5 categories). For Example: in the first category will be 2 columns, one with value 1 and seconed with value 10.
It's show me an ERROR of "Subscript out of range " on the line:
"oChart.Charts(0).SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, Vals"
Why? What's I did wrong?
What's the problem in my code? How to fix it??
|
|

11-26-03, 17:35
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Wellington NZ
Posts: 4
|
|
|
need to specify array location
The OWC.chart is a bit above my head but ...
Subscript out of range means youre asking for a value from a position that doesn't exist in an array.
Because you want two columns for each category you'd have to add two series, each from a 1D array, or specify which column of the 2D array you want.
You'd also have an array for the category names.
I think?
|
|

11-26-03, 18:16
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
|
|
from MSDN
When the DataSourceIndex argument is set to chDataLiteral, you can set DataReference to a one-dimensional array or a comma-delimited list.
You have a two dimensional array....
|
|

11-27-03, 01:38
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 22
|
|
|
help me. Write to me
Quote:
Originally posted by rokslide
from MSDN
When the DataSourceIndex argument is set to chDataLiteral, you can set DataReference to a one-dimensional array or a comma-delimited list.
You have a two dimensional array....
|
O.K so what i need to do! please write it for me. I need your help
|
|

11-27-03, 01:38
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 22
|
|
|
Re: need to specify array location
Quote:
Originally posted by dansimmo
The OWC.chart is a bit above my head but ...
Subscript out of range means youre asking for a value from a position that doesn't exist in an array.
Because you want two columns for each category you'd have to add two series, each from a 1D array, or specify which column of the 2D array you want.
You'd also have an array for the category names.
I think?
|
Can you erite it for me???
Please, I need help
|
|

11-27-03, 02:13
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
try something like this..
Code:
<%
' 2D array
Dim Vals1(5)
Dim Vals2(5)
Vals1(0)=1
Vals1(1)=2
Vals1(2)=3
Vals1(3)=4
Vals1(4)=5
Vals2(0)=10
Vals2(1)=20
Vals2(2)=30
Vals2(3)=40
Vals2(4)=50
' Create a Chart Object
Set oChart = CreateObject("OWC.Chart")
Set c = oChart.Constants
sCaption = "This is Graph "
oChart.Charts.Add
oChart.Charts(0).Type = oChart.Constants.chChartTypeColumnClustered
oChart.Charts(0).SeriesCollection.Add
oChart.Charts(0).SeriesCollection(0).Caption = sCaption
oChart.Charts(0).SeriesCollection(0).SetData c.chDimCategories, c.chDataLiteral, Categories
oChart.Charts(0).SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, Vals1
oChart.Charts(0).SeriesCollection.Add
oChart.Charts(0).SeriesCollection(1).Caption = sCaption
oChart.Charts(0).SeriesCollection(1).SetData c.chDimCategories, c.chDataLiteral, Categories
oChart.Charts(0).SeriesCollection(1).SetData c.chDimValues, c.chDataLiteral, Vals2
%>
I would guess... I haven't used the charts object much though. 
|
|

11-27-03, 02:17
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
what sort of chart are you actually making here??
|
|

11-27-03, 02:20
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
you might need to change your chart type...
"For ChErrorBars objects, this argument specifies an array of Double or String values you can use for error-bar values. Note that you can use this argument only with custom error bars (the error-bar Type property must be set to chErrorBarTypeCustom)."
|
|

11-27-03, 03:44
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 22
|
|
|
So, which type Do I need?
Quote:
Originally posted by rokslide
you might need to change your chart type...
"For ChErrorBars objects, this argument specifies an array of Double or String values you can use for error-bar values. Note that you can use this argument only with custom error bars (the error-bar Type property must be set to chErrorBarTypeCustom)."
|
So, You say that I dont need the type "chChartTypeColumnClustered"
Whitch type do I need to use in order to create a graph with 2 columns in each category???
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|