Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2003
    Posts
    22

    Unanswered: 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??

  2. #2
    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?

  3. #3
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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....

  4. #4
    Join Date
    Nov 2003
    Posts
    22

    help me. Write to me

    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

  5. #5
    Join Date
    Nov 2003
    Posts
    22

    Re: need to specify array location

    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

  6. #6
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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.

  7. #7
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    what sort of chart are you actually making here??

  8. #8
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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)."

  9. #9
    Join Date
    Nov 2003
    Posts
    22

    So, which type Do I need?

    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???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •