array error for pie graphic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • franciros
    New Member
    • Mar 2008
    • 1

    array error for pie graphic

    Hi, I've the problem with data array generated for query. The graphic include only first record, not all records. Why? This is the code in the my asp page:

    Code:
    <%@ language="vbscript" %>
    <!--#include file="../Connections/dicomp.asp" -->
    <%
    Dim oConn, oRs
    set oConn= Server.CreateObject ("ADODB.Connection")
    Set oRs= Server.CreateObject("ADODB.Recordset")
    
    oConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("dicomp.mdb")
    
    'oRs.open "Select conteggio,catgramm From sommacat order by catgramm asc", oConn
    'oRs.open "SELECT Sum(Conteggio) AS SommaDiConteggio, catgramm FROM conteggiocat GROUP BY catgramm ORDER BY catgramm", oConn
    oRs.open "SELECT catgramm,sum(conteggio) as sommaconteggio FROM conteggiocat GROUP BY catgramm ORDER BY catgramm", oConn
    
    set cd = CreateObject("ChartDirector.API")
    '------------------------------------------
    if not oRs.EOF then
    do while not oRs.EOF
    data = data&","&oRs("sommaconteggio")
    labels = labels &","& oRs("catgramm")
    oRs.MoveNext
    loop
    end if
    
    Arraydata = Split(right(data,len(data)-1), ",",-1,1)
    Arraylabels = Split(right(labels,len(labels)-1), ",",-1,1)
    
    for i = 0 to ubound(Arraydata)
    data = Array(Arraydata(i))',Arraydata(1)',Arraydata(2),Arraydata(3),Arraydata(4))
    next
    
    for i = 0 to Ubound(Arraylabels)
    labels = Array(Arraylabels(i))',Arraylabels(1),Arraylabels(2),Arraylabels(3),Arraylabels(4))
    next
    
    ' Create a PieChart object of size 560 x 270 pixels, with a golden background and a 1
    ' pixel 3D border
    Set c = cd.PieChart(560, 270, cd.goldColor(), -1, 1)
    
    ' Add a title box using 15 pts Times Bold Italic font and metallic pink background
    ' color
    Call c.addTitle("Grafico delle Categorie Grammaticali", "timesbi.ttf", 15).setBackground( _
        cd.metalColor(&Hff9999))
    
    ' Set the center of the pie at (280, 135) and the radius to 110 pixels
    Call c.setPieSize(280, 135, 110)
    
    ' Draw the pie in 3D with 20 pixels 3D depth
    Call c.set3D(20)
    
    ' Use the side label layout method
    Call c.setLabelLayout(cd.SideLayout)
    
    ' Set the label box background color the same as the sector color, with glass effect,
    ' and with 5 pixels rounded corners
    Set t = c.setLabelStyle()
    Call t.setBackground(cd.SameAsMainColor, cd.Transparent, cd.glassEffect())
    Call t.setRoundedCorners(5)
    
    ' Set the border color of the sector the same color as the fill color. Set the line
    ' color of the join line to black (0x0)
    Call c.setLineColor(cd.SameAsMainColor, &H000000)
    
    ' Set the start angle to 135 degrees may improve layout when there are many small
    ' sectors at the end of the data array (that is, data sorted in descending order). It
    ' is because this makes the small sectors position near the horizontal axis, where
    ' the text label has the least tendency to overlap. For data sorted in ascending
    ' order, a start angle of 45 degrees can be used instead.
    Call c.setStartAngle(135)
    
    ' Set the pie data and the pie labels
    Call c.setData(data, labels)
    
    ' output the chart
    Response.ContentType = "image/png"
    Response.BinaryWrite c.makeChart2(cd.PNG)
    Response.End
    
    Set c = nothing
    
    Set cd = nothing
    %>
    tks very very much

    F
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    The two "for...next " loops starting on lines 27 and 31 are looping and overwriting, rather than appending data.

    Jared

    Comment

    Working...