Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135

    Classe wbGraph di Imente

    Ciao a tutti.

    Sto provando ad utilizzare la classe wbGraph di Imente:
    http://www.imente.org/docs/wbgraph/demo.asp

    Ho pero un problema: al momento la classe permette la visualizzazione al max di 5 barre grafiche ed a me ne servirebbero da visualizzare almeno 7.

    Ho provato a consultare la documentazione in linea, ma con scarso risultato:
    http://www.imente.org/docs/wbgraph/docs.asp

    La classe è la seguente, potete aiutarmi a modificarla ed a renderela utile per visualizzare 7 barre grafiche ?

    codice:
    <%
    
    Class Class_graph
    
    	private graphArray()
    	
    	public direction, showLabels, showIndicators, lines, length, indicators
    	private barStyle(4,5)
    		
    	public sub init()
    		call reset()
    	end sub
    	
    	public sub reset()
    		redim graphArray(5,0)
    		showLabels = false
    		showIndicators = true
    		lines = 2
    		length = 300
    		indicators = 10
    		barStyle(0,0) = "#26426C" : barStyle(1,0) = "#FF0000" : barStyle(2,0) = "#008000" : barStyle(3,0) = "#FFFF00" : barStyle(4,0) = "#EEF2F9"
    		
    		barStyle(0,3) = "#26426C" : barStyle(1,3) = "#FF0000" : barStyle(2,3) = "#008000" : barStyle(3,3) = "#FFFF00" : barStyle(4,2) = "#EEF2F9"
    		barStyle(0,4) = "#26426C" : barStyle(1,4) = "#FF0000" : barStyle(2,4) = "#008000" : barStyle(3,4) = "#FFFF00" : barStyle(4,3) = "#EEF2F9"
    		
    		barStyle(0,1) = 10 : barStyle(1,1) = 10 : barStyle(2,1) = 10 : barStyle(3,1) = 10 : barStyle(4,1) = 10
    		barStyle(0,2) = "" : barStyle(1,2) = "" : barStyle(2,2) = "" : barStyle(3,2) = "" : barStyle(4,2) = ""
    	end sub
    	
    	public sub clearValues()
    		redim graphArray(5,0)
    	end sub
    	
    	public sub setStyle(argBar, argType, argValue)
    		dim numType
    		
    		select case argType
    			case "barColor"
    			numType = 0
    			case "barThickness"
    			numType = 1
    			case "barBackgroundImage"
    			numType = 2
    			case "barLeftBorderColor"
    			numType = 3
    			case "barRightBorderColor"
    			numType = 4
    		end select
    		
    		if cint(argBar) <= 0 then
    			barStyle(0,numType) = argValue
    			barStyle(1,numType) = argValue
    			barStyle(2,numType) = argValue
    			barStyle(3,numType) = argValue
    			barStyle(4,numType) = argValue
    		elseif cint(argBar) <=5 then
    			barStyle(cint(argBar)-1,numType) = argValue
    		end if
    		
    	end sub
    	
    	public sub addValue(argVal0, argVal1, argVal2, argVal3, argVal4, argVal5)
    	
    		redim preserve graphArray(5,ubound(graphArray,2)+1)
    		graphArray(0,ubound(graphArray,2)) = argVal0
    		graphArray(1,ubound(graphArray,2)) = argVal1
    		graphArray(2,ubound(graphArray,2)) = argVal2
    		graphArray(3,ubound(graphArray,2)) = argVal3
    		graphArray(4,ubound(graphArray,2)) = argVal4
    		graphArray(5,ubound(graphArray,2)) = argVal5
    	
    	end sub
    	
    	public function getMaxValue()
    	
    		dim tmpMaxValue
    		tmpMaxValue = clng(1)
    		dim ii, jj
    		
    		for ii = 1 to ubound(graphArray,2)
    			for jj = 1 to lines
    				if clng(graphArray(jj,ii)) > clng(tmpMaxValue) then tmpMaxValue = clng(graphArray(jj,ii))
    			next
    		next
    		
    		getMaxValue = tmpMaxValue
    	
    	end function
    	
    	public sub printGraph()
    	
    		dim ii, jj
    		dim maxValue, finalValue
    		
    		maxValue = getMaxValue()
    		if indicators > maxValue then indicators = maxValue
    		
    		if direction = "vertical" then %>
    			<table class="gv-box"><tr><%
    			if showIndicators = true then %>
    			<td style="padding:0;">
    			<% for jj = 1 to indicators
    					%><div class="gv-ind" style="height:<%=int(clng(length)/clng(indicators))-1%>px;"><%=formatNumericValue(int((clng(maxValue)/clng(indicators))*(indicators - jj + 1)))%></div>
    				<% next 
    			%></td><%
    			end if
    			
    			for ii = 1 to ubound(graphArray,2)%>
    			<td class="gv-bar"><%
    			for jj = 1 to lines
    				finalValue = int((clng(length) * clng(graphArray(jj,ii)))/clng(maxValue))
    				if finalValue < 3 then finalValue = 3
    				%><div class="gv-bar<%=jj%>" style="height:<%=finalValue-1%>px;margin-top:<%=clng(length)-clng(finalValue)%>px;"></div><%
    				next
    			%></td><%
    			next %>
    			</tr><%
    			if showLabels = true then %>
    			<tr><%
    			if showIndicators = true then %><td></td><% end if
    			for ii = 1 to ubound(graphArray,2)%>
    			<td class="gv-txt"><%=graphArray(0,ii)%></td><%
    			next %>
    			</tr><%
    			end if %>
    		</table>
    		<% 
    		else 
    		%>
    			<table class="gh-box"><%
    			for ii = 1 to ubound(graphArray,2) %>
    			  <tr><%
    			  if showLabels = true then %>
    			  <td class="gh-txt"><%=graphArray(0,ii)%></td><%
    			  end if %>
    				<td class="gh-bar"><%
    				for jj = 1 to lines
    				finalValue = int((clng(length) * clng(graphArray(jj,ii)))/clng(maxValue))
    				if finalValue < 1 then finalValue = 1
    				%><div class="gh-bar<%=jj%>" style="width:<%=finalValue-1%>px;"></div>
    				<% next
    				%></td></tr>
    				<% next
    				if showIndicators = true then %>
    				<tr><% if showLabels = true then %><td></td><% end if %><td style="padding:0;"><%
    					for jj = 1 to indicators
    						%><div class="gh-ind" style="width:<%=int(clng(length)/clng(indicators))-1%>px;"><%=formatNumericValue(int((clng(maxValue)/clng(indicators))*(jj)))%></div><%
    					next  
    				%></td></tr><%
    				end if %>
    			</table>
    			<%
    		end if
    		
    	end sub
    	
    	public sub printStyle()
    	%>
    <style type="text/css">
    	table.gv-box { border-collapse:collapse; margin:20px auto; padding:0; }
    	table.gv-box td { border-right:1px dotted #999999; vertical-align:middle; }
    	td.gv-bar { border-left:1px dotted #999999; padding:0 5px;}
    	div.gv-bar1, div.gv-bar2, div.gv-bar3, div.gv-bar4, div.gv-bar5 { float:left; font-size:0; }
    	div.gv-bar1 { background-color:<%=barStyle(0,0)%>;width:<%=barStyle(0,1)%>px;border-left:1px solid <%=barStyle(0,3)%>;border-right:1px solid <%=barStyle(0,4)%>;border-top:1px solid <%=barStyle(0,3)%>;<% if barStyle(0,2) <> "" then %>background:url('<%=barStyle(0,2)%>') repeat-y left bottom;<% end if %> }
    	div.gv-bar2 { background-color:<%=barStyle(1,0)%>;width:<%=barStyle(1,1)%>px;border-left:1px solid <%=barStyle(1,3)%>;border-right:1px solid <%=barStyle(1,4)%>;border-top:1px solid <%=barStyle(1,3)%>;<% if barStyle(1,2) <> "" then %>background:url('<%=barStyle(1,2)%>') repeat-y left bottom;<% end if %> }
    	div.gv-bar3 { background-color:<%=barStyle(2,0)%>;width:<%=barStyle(2,1)%>px;border-left:1px solid <%=barStyle(2,3)%>;border-right:1px solid <%=barStyle(2,4)%>;border-top:1px solid <%=barStyle(2,3)%>;<% if barStyle(2,2) <> "" then %>background:url('<%=barStyle(2,2)%>') repeat-y left bottom;<% end if %> }
    	div.gv-bar4 { background-color:<%=barStyle(3,0)%>;width:<%=barStyle(3,1)%>px;border-left:1px solid <%=barStyle(3,3)%>;border-right:1px solid <%=barStyle(3,4)%>;border-top:1px solid <%=barStyle(3,3)%>;<% if barStyle(3,2) <> "" then %>background:url('<%=barStyle(3,2)%>') repeat-y left bottom;<% end if %> }
    	div.gv-bar5 { background-color:<%=barStyle(4,0)%>;width:<%=barStyle(4,1)%>px;border-left:1px solid <%=barStyle(4,3)%>;border-right:1px solid <%=barStyle(4,4)%>;border-top:1px solid <%=barStyle(4,3)%>;<% if barStyle(4,2) <> "" then %>background:url('<%=barStyle(4,2)%>') repeat-y left bottom;<% end if %> }
    	td.gv-bar { border-bottom:1px solid #666666; }
    	td.gv-txt { text-align:center; font-size:0.8em; padding:5px; }
    	div.gv-ind { border-top:1px solid #999; font-size:0.6em; text-align:left; padding-right:5px; }
    	
    	table.gh-box { border-collapse:collapse; padding:0; margin:20px auto; }
    	table.gh-box td { border-top:1px dotted #999999; vertical-align:middle; }
    	div.gh-bar1, div.gh-bar2, div.gh-bar3, div.gh-bar4, div.gh-bar5 { font-size:0; }
    	div.gh-bar1 { background-color:<%=barStyle(0,0)%>;height:<%=barStyle(0,1)%>px;border-top:1px solid <%=barStyle(0,3)%>;border-bottom:1px solid <%=barStyle(0,4)%>;border-right:1px solid <%=barStyle(0,4)%>;<% if barStyle(0,2) <> "" then %>background:url('<%=barStyle(0,2)%>') repeat-x left bottom;<% end if %> }
    	div.gh-bar2 { background-color:<%=barStyle(1,0)%>;height:<%=barStyle(1,1)%>px;border-top:1px solid <%=barStyle(1,3)%>;border-bottom:1px solid <%=barStyle(1,4)%>;border-right:1px solid <%=barStyle(1,4)%>;<% if barStyle(1,2) <> "" then %>background:url('<%=barStyle(1,2)%>') repeat-x left bottom;<% end if %> }
    	div.gh-bar3 { background-color:<%=barStyle(2,0)%>;height:<%=barStyle(2,1)%>px;border-top:1px solid <%=barStyle(2,3)%>;border-bottom:1px solid <%=barStyle(2,4)%>;border-right:1px solid <%=barStyle(2,4)%>;<% if barStyle(2,2) <> "" then %>background:url('<%=barStyle(2,2)%>') repeat-x left bottom;<% end if %> }
    	div.gh-bar4 { background-color:<%=barStyle(3,0)%>;height:<%=barStyle(3,1)%>px;border-top:1px solid <%=barStyle(3,3)%>;border-bottom:1px solid <%=barStyle(3,4)%>;border-right:1px solid <%=barStyle(3,4)%>;<% if barStyle(3,2) <> "" then %>background:url('<%=barStyle(3,2)%>') repeat-x left bottom;<% end if %> }
    	div.gh-bar5 { background-color:<%=barStyle(4,0)%>;height:<%=barStyle(4,1)%>px;border-top:1px solid <%=barStyle(4,3)%>;border-bottom:1px solid <%=barStyle(4,4)%>;border-right:1px solid <%=barStyle(4,4)%>;<% if barStyle(4,2) <> "" then %>background:url('<%=barStyle(4,2)%>') repeat-x left bottom;<% end if %> }
    	td.gh-bar { padding:5px 0; border-left:1px solid #666; }
    	td.gh-txt { text-align:right; font-size:0.8em; padding:10px; }
    	div.gh-ind { float:left; border-right:1px solid #999; font-size:0.6em; text-align:right; padding-top:5px; }
    </style>
    	<%
    	
    	end sub
    	
    	function formatNumericValue(argValue)
    		dim ii, output
    		argValue = cstr(argValue)
    		output = ""
    		for ii = 0 to len(argValue)-1
    			if (ii mod 3) = 0 and ii <> 0 then output = "." & output
    			output = mid(argValue,len(argValue)-ii,1) & output
    		next
    		formatNumericValue = output
    	end function
    	
    end class
    %>
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  2. #2
    Amministratore L'avatar di Vincent.Zeno
    Registrato dal
    May 2003
    residenza
    Emilia-Romagna (tortellini und cappelletti land!)
    Messaggi
    20,812
    ...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.