Ver Mensaje Individual
  #4 (permalink)  
Antiguo 10/06/2003, 16:22
Avatar de Mignola
Mignola
 
Fecha de Ingreso: noviembre-2002
Ubicación: Templo Shaolin
Mensajes: 167
Antigüedad: 23 años, 11 meses
Puntos: 1
Sigue:
Código PHP:

    
'----------------------------------------------------------------------------------------------------------------------
    '
draw the actual graph
    
public sub Draw
        
        Dim startPoint
, endPoint, sumOfValues, percentage, i
        Dim strTitle
, magicNumber
        dim Height
, Width
    
        
if rsPieGraphValues.EOF and rsPieGraphValues.BOF then exit sub
        
        magicNumber 
= 23592960    ' It's mystical, magical, kinda nutty even
        startPoint 
= 5850000    ' this setting is approximately 12:00 noon
        strTitle=pvTitle
        
        '
height to width ratio is h:w = 0.75:1
        
'we work out the height and width from the diameter given
        '
the formula is diameter=100 therefore height=375pt; width=500pt
        Height 
= round(pvDiameter * 3.75,0)
        
Width  = round(pvDiameter * 5,0)
        
        
with response
        
        
' GET SUM OF VALUES ****************
        rsPieGraphValues.MoveFirst 
        do while not rsPieGraphValues.EOF 
            sumOfValues = sumOfValues + rsPieGraphValues("value").Value 
            rsPieGraphValues.MoveNext 
        loop
        if sumOfValues=0 then exit sub
        
        ' 
VML tags ***********************************
        .
Write "<xml:namespace prefix=""v""/>"
        
.Write "<object id=""VMLRender"" classid=""CLSID:10072CEC-8CC1-11D1-986E-00A0C955B42E"" width=""0"" height=""0""></object>"
        
.Write "<style> v\:* {behavior=url(#VMLRender)}</style>"
        ' ********************************************
        
        ' 
********************************************
        
' Start Outer Table //
        .Write pvHTMLouterTableDef & vbCrLf 
        .Write "<tr>" & vbCrLf 
        .Write "<td>" & vbCrLf 
        ' 
********************************************
        
        
' ********************************************
        ' 
Start Inner Table //
        
.Write pvHTMLinnertableDef & vbCrLf
        
if pvTitle<>"" then
            
.Write "<tr align=""center"" >" & vbCrLf
            
' Create Title //
            if pvShowLegend then
                .Write "<td colspan=""2""><b>" & strTitle & "</b><br><br></td>" & vbCrLf
            else
                .Write "<td><b>" & strTitle & "</b><br><br></td>" & vbCrLf
            end if
            .Write "</tr>" & vbCrLf
        end if
        ' 
********************************************
        
        
' Start Building Pie //
        .Write "<tr>" & vbCrLf
        .Write "<td>" & vbCrLf
        '
VML tags
        
.Write "<div style=""margin-top=0pt"">" & vbCrLf
        
.Write "<v:group style=""height=" & Height & "pt; width=" & Width & "pt"" coordsize=""4320,3240"">" & vbCrLf
        
        

        
' BUILD THE SHADOW ***************
        if pvShadow then
            .Write("<v:shape style='
position:relative; width:4320; height:3240' fillcolor=#C0C0C0 path=""M 790 760 AE 790 760 707 707 " & startPoint & " " & magicNumber & " X E"">" & vbCrLf)
            .Write("<v:stroke on=""False""/>" & vbCrLf)
            .Write("</v:shape>" & vbCrLf)
        end if

        ' 
BUILD THE PIE ********************
        
rsPieGraphValues.MoveFirst 
        
do while not rsPieGraphValues.EOF 
            percentage 
= FormatNumber(rsPieGraphValues("value").Value / sumOfValues, 3)
            
endPoint = magicNumber * percentage
            endPoint 
= FormatNumber(endPoint, 0)
            
endPoint = Fix(endPoint)
            .
Write("<v:shape style='width:4320; height:3240' strokeweight=0.5pt fillcolor=" & rsPieGraphValues("color").Value & " path=""M 750 720 AE 750 720 707 707 " & startPoint & " " & endPoint & " X E""/>" & vbCrLf)
            
startPoint = startPoint + endPoint
            rsPieGraphValues
.MoveNext 
        loop

        
' VML tag
        .Write("</v:group></div>" & vbCrLf)
        .Write("</td>" & vbCrLf)
        ' 
End Build Pie ******************************


        
' ********************************************
        ' 
Start Legend Table //
        
if pvShowLegend then
            
.Write("<td>" & vbCrLf)
            .
Write("<table bordercolor=""white"" border=""1"" cellpadding=""2"">" & vbCrLf)
    
            
' Step 6)    BUILD THE LEGEND
            rsPieGraphValues.MoveFirst 
            do while not rsPieGraphValues.EOF 
                .Write("<tr>" & vbCrLf)
                ' 
Color //
                
.Write "<td><img src='../images/1pixel.gif' border=1 width='" & pvLegendSize & "' height='" & pvLegendSize & "' style='background:" & rsPieGraphValues("color").Value & ";'/></td>"
                ' Category    //
                .Write("<td width=""75"">" & vbCrLf)
                .Write ReturnValueWithFontTags(rsPieGraphValues("label").Value) & vbCrLf
                .Write("</td>" & vbCrLf)
                ' 
Value or Percent //
                
if pvShowValues then
                    
.Write("<td align=""right"">" & vbCrLf)
                    if 
pvFormatValuesAsCurrency then
                        
.Write ReturnValueWithFontTags(formatnumber(rsPieGraphValues("value").Value,2,true,false,false)) & vbCrLf
                    
else
                        .
Write ReturnValueWithFontTags(rsPieGraphValues("value").Value) & vbCrLf
                    end 
if
                    .
Write("</td>" & vbCrLf)
                
end if
                .
Write("</tr>" & vbCrLf)
                
rsPieGraphValues.MoveNext 
            loop
                
            
' End Legend Table ***************************
            .Write("</table>" & vbCrLf)
            .Write("</td>" & vbCrLf)
        end if
    
        ' 
End Inner Table ****************************
        .
Write("</tr>" & vbCrLf)
        .
Write("</table>" & vbCrLf)
    
        
' End Outer Table ****************************
        .Write("</td>" & vbCrLf)
        .Write("</tr>" & vbCrlf)
        .Write("</table>" & vbCrLf)
    
        end with
        
    end sub
    '
----------------------------------------------------------------------------------------------------------------------
    
end class    
    
%>


<%

  
Dim oGraph
  
  Set oGraph 
= New DrawPieGraph
  With oGraph
    
.Diameter = 50
.Shadow = True
    
.Title = "<font face='Arial' size=3><b>This is the title</b></font>"
   
    
.ShowLegend = True
    
.LegendSize = 8
    
.ShowValues = True

.FontDef = "<font face='Arial' size=2>"
    
.HTMLouterTableDef = "<table border=2 cellpadding=1 cellspacing=0>"
    
.HTMLinnerTableDef = "<table border=1 cellspacing=0 cellpadding=3>"
    
   
.AddValue 100, "label1", "red"
    
.AddValue 200, "label2", "green"
    
.AddValue 30, "label3", "blue"
    
.AddValue 50, "label4", "yellow"
    
.AddValue 5, "label5", "gray"
    
   
 
.Draw
 
End With

  Set oGraph 
= Nothing
  
%> 

Última edición por Mignola; 10/06/2003 a las 16:26