Imports System.Drawing
System.Drawing
Imports System.Drawing.Imaging
System.Drawing.Imaging
Public Class graph
Class graph
Inherits System.Web.UI.Page
Inherits System.Web.UI.Page
#Region " Código generado por el Diseñador de Web Forms "
Region " Código generado por el Diseñador de Web Forms "
'El Diseñador de Web Forms requiere esta llamada.
'El Diseñador de Web Forms requiere esta llamada.
<;System.Diagnostics.DebuggerStepThrough()>; Private Sub InitializeComponent()
Private Sub InitializeComponent()
End Sub
End Sub
'NOTA: el Diseñador de Web Forms necesita la siguiente declaración del marcador de posición.
'NOTA: el Diseñador de Web Forms necesita la siguiente declaración del marcador de posición.
'No se debe eliminar o mover.
'No se debe eliminar o mover.
Private designerPlaceholderDeclaration As System.Object
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: el Diseñador de Web Forms requiere esta llamada de método
'CODEGEN: el Diseñador de Web Forms requiere esta llamada de método
'No la modifique con el editor de código.
'No la modifique con el editor de código.
InitializeComponent()
End Sub
End Sub
#End Region
End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objBitmap As New Bitmap(700, 200)
Dim objBitmap As New Bitmap(700, 200)
Dim objGraphic As Graphics = Graphics.FromImage(objBitmap)
Dim objGraphic As Graphics = Graphics.FromImage(objBitmap)
Dim orange As New SolidBrush(Color.Orange)
Dim orange As New SolidBrush(Color.Orange)
Dim whiteBrush As New SolidBrush(Color.White)
Dim whiteBrush As New SolidBrush(Color.White)
Dim lineColor As New Pen(Color.Blue, 2)
Dim lineColor As New Pen(Color.Blue, 2)
objGraphic.FillRectangle(whiteBrush, 0, 0, 700, 200)
objGraphic.DrawLine(lineColor, New Point(0, 190), New Point(700, 190))
New Point(0, 190), New Point(700, 190))
objGraphic.DrawLine(lineColor, New Point(5, 5), New Point(5, 195))
New Point(5, 5), New Point(5, 195))
Dim l_arr As New ArrayList
Dim l_arr As New ArrayList
'inserción en el array de valores para el ejemplo
'inserción en el array de valores para el ejemplo
l_arr.Add("800")
l_arr.Add("01/01/07")
l_arr.Add("500")
l_arr.Add("02/01/07")
l_arr.Add("1000")
l_arr.Add("03/01/07")
l_arr.Add("200")
l_arr.Add("03/01/07")
l_arr.Add("1000")
l_arr.Add("03/01/07")
l_arr.Add("1300")
l_arr.Add("03/01/07")
l_arr.Add("1000")
l_arr.Add("03/01/07")
l_arr.Add("1000")
l_arr.Add("03/01/07")
l_arr.Add("1000")
l_arr.Add("03/01/07")
l_arr.Add("1000")
l_arr.Add("03/01/07")
Dim i As Int32 = 0
Dim i As Int32 = 0
Dim pos As Int32 = 0
Dim pos As Int32 = 0
Dim PointValue As New PointF(-30, 0)
Dim PointValue As New PointF(-30, 0)
Dim PointDate As New PointF(-30, 190)
Dim PointDate As New PointF(-30, 190)
Dim objFont As New Font("Verdana", 10)
Dim objFont As New Font("Verdana", 10)
Dim FontDate As New Font("Verdana", 7)
Dim FontDate As New Font("Verdana", 7)
Dim wb2 As New SolidBrush(Color.Black)
Dim wb2 As New SolidBrush(Color.Black)
Dim x As Int32 = -50
Dim x As Int32 = -50
Dim maxValue As Int32 = 0
Dim maxValue As Int32 = 0
'calculo del máximo valor de la gráfica
'calculo del máximo valor de la gráfica
i = 0
While i <; l_arr.Count
While i <; l_arr.Count
If l_arr(i) >; maxValue Then
If l_arr(i) >; maxValue Then
maxValue = l_arr(i)
End If
End If
i += 2
End While
End While
'creación de todos los rectángulos de la gráfica
'creación de todos los rectángulos de la gráfica
i = 0
While i <; l_arr.Count
While i <; l_arr.Count
x += 70
Dim aux As Int32
Dim aux As Int32
aux = (l_arr(i) * 189) / (maxValue + 200)
objGraphic.FillRectangle(orange, x, 189 - aux, 40, aux)
PointValue.X = x
PointDate.X = x - 10
objGraphic.DrawString(l_arr(i).ToString, objFont, wb2, PointValue)
objGraphic.DrawString(l_arr(i + 1).ToString, FontDate, wb2, PointDate)
i += 2
End While
End While
Response.ContentType = "image/gif"
objBitmap.Save(Response.OutputStream, ImageFormat.Gif)
End Sub
End Sub End Class