Imports ChartDirector
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub buildGraph()
Dim r As RanSeries = New RanSeries(Now().Second)
Dim data0() As Double = r.getSeries(100, 100, -15, 15)
Dim data1() As Double = r.getSeries(100, 150, -15, 15)
Dim data2() As Double = r.getSeries(100, 200, -15, 15)
Dim timeStamps() As Date = r.getDateSeries(100, DateSerial(2011, 1, 1), 86400)
' Create a XYChart object of size 640 x 400 pixels
Dim c As XYChart = New XYChart(640, 400)
' Add a title to the chart using 18 pts Times New Roman Bold Italic font
c.addTitle(" Product Line Global Revenue", "Times New Roman Bold Italic", 18)
' Set the plotarea at (50, 55) with width 70 pixels less than chart width, and height 90 pixels
' less than chart height. Use a vertical gradient from light blue (f0f6ff) to sky blue (a0c0ff)
' as background. Set border to transparent and grid lines to white (ffffff).
c.setPlotArea(50, 55, c.getWidth() - 70, c.getHeight() - 90, c.linearGradientColor(0, 55, 0, _
c.getHeight() - 35, &HF0F6FF, &HA0C0FF), -1, Chart.Transparent, &HFFFFFF, &HFFFFFF)
' Add a legend box at (50, 25) using horizontal layout. Use 10pts Arial Bold as font. Set the
' background and border color to Transparent.
c.addLegend(50, 25, False, "Arial Bold", 10).setBackground(Chart.Transparent)
' Set axis label style to 8pts Arial Bold
c.xAxis().setLabelStyle("Arial Bold", 8)
c.yAxis().setLabelStyle("Arial Bold", 8)
' Set the axis stem to transparent
c.xAxis().setColors(Chart.Transparent)
c.yAxis().setColors(Chart.Transparent)
' Configure x-axis label format
c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "{value|mm/yyyy} ", _
Chart.StartOfMonthFilter(), "{value|mm}")
' Add axis title using 10pts Arial Bold Italic font
c.yAxis().setTitle("USD millions", "Arial Bold Italic", 10)
' Add a line layer to the chart using a line width of 2 pixels.
Dim layer As LineLayer = c.addLineLayer2()
layer.setLineWidth(2)
' Add 3 data series to the line layer
layer.setXData(timeStamps)
layer.addDataSet(data0, &HFF3333, "Alpha")
layer.addDataSet(data1, &H8800, "Beta")
layer.addDataSet(data2, &H3333CC, "Gamma")
' Output the chart
WebChartViewer1.Image = c.makeWebImage(Chart.PNG)
' Output Javascript chart model to the browser to suppport tracking cursor
WebChartViewer1.ChartModel = c.getJsChartModel()
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
buildGraph()
End Sub
End Class |