Imports ChartDirector
Partial Class zzsamplegraph
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
CreateGraph1(WebChartViewer1)
End Sub
Protected Sub CreateGraph1(ByVal viewer As ChartDirector.WebChartViewer)
Dim data0X(6) As Date
data0X(0) = CDate("1/20/2011 12:15:00 PM")
data0X(1) = CDate("1/20/2011 12:30:00 PM")
data0X(2) = CDate("1/20/2011 12:45:00 PM")
data0X(3) = CDate("1/20/2011 1:30:00 PM")
data0X(4) = CDate("1/20/2011 6:00:00 PM")
data0X(5) = CDate("1/20/2011 6:30:00 PM")
data0X(6) = CDate("1/28/2011 10:00:00 AM")
Dim c As XYChart = New XYChart(1005, 550)
c.setBackground(&HFFFFFF, &H0)
c.addTitle("Date Time", "Arial Bold", 10).setMargin2(0, 0, 10, 0)
Dim plotArea As PlotArea = c.setPlotArea(100, 50, 780, 350, -1, -1, _
Chart.Transparent, c.dashLineColor(&H444444, &H101), -1)
c.setClipping()
Dim legendBox As LegendBox = c.addLegend(10, 540, False, "Arial", 8)
legendBox.setAlignment(Chart.BottomLeft)
legendBox.setBackground(Chart.Transparent, Chart.Transparent)
c.xAxis().setMargin(15, 15)
c.xAxis().setLabelStyle("Arial Bold", 8, &H0, 90)
c.xAxis().setMultiFormat(Chart.StartOfDayFilter(), "<*font=Arial Bold*>{value|dd-mm-yy hh:nn}", Chart.AllPassFilter(), "{value|dd-mm-yy}") ' hh:nn
c.xAxis.setTitle("Date Time", "Arial Bold", 8)
c.yAxis().setLabelStyle("Arial Bold", 8)
c.yAxis().setTitle("Data", "Arial Bold", 8).setAlignment(Chart.TopLeft)
c.yAxis().setColors(&H6666, &H6666, &H6666, &H6666)
' Add the first data series
Dim layer0 As LineLayer = c.addLineLayer2()
layer0.setXData(data0X)
layer0.setXData2(data0X(0), data0X(data0X.Length - 1))
layer0.setLineWidth(1)
Dim data0Y() As Double = {12, 12, 12, 12, 12, 12, 328.9293}
layer0.addDataSet(data0Y, -1, "Date Time - Data").setDataSymbol(3, 9) '&H6666
'If strXAxis = "RAW_DATETIME" Then
' If myUtil.isDate(myUtil.SQLDate(txtDate.Text)).Length > 0 And myUtil.isDate(myUtil.SQLDate(txtDate2.Text)).Length > 0 Then
' Dim minval As Double = Chart.CTime(CDate(myUtil.SQLDate(txtDate.Text) & " " & txtFromTime.SelectedTime.ToString("HH:mm")))
' Dim maxval As Double = Chart.CTime(CDate(myUtil.SQLDate(txtDate2.Text) & " " & txtToTime.SelectedTime.ToString("HH:mm")))
' 'c.xAxis.setLinearScale(minval, maxval)
' c.xAxis.setDateScale(minval, maxval, 86400)
' End If
'Else
' If txtX2Min.Text.Length > 0 And txtX2Max.Text.Length > 0 Then
' c.xAxis.setLinearScale(CDbl(txtX2Min.Text), CDbl(txtX2Max.Text))
' End If
'End If
'If txty1Min.Text.Length > 0 And txty1Max.Text.Length > 0 Then
' c.yAxis.setLinearScale(CDbl(txty1Min.Text), CDbl(txty1Max.Text))
'End If
'Output the chart
viewer.Image = c.makeWebImage(Chart.PNG)
' Include tool tip for the chart
viewer.ImageMap = c.getHTMLImageMap("", "", _
"title='{dataSetName} - Y({value}), X({x|dd-mm-yyyy hh:nn})'")
viewer.Visible = True
End Sub
End Class
|