ChartDirector 7.0 (ASP/COM/VB Edition)
Polar Area Chart
Source Code Listing
<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")
' Data for the chart
data0 = Array(5, 3, 10, 4, 3, 5, 2, 5)
data1 = Array(12, 6, 17, 6, 7, 9, 4, 7)
data2 = Array(17, 7, 22, 7, 18, 13, 5, 11)
labels = Array("North", "North<*br*>East", "East", "South<*br*>East", "South", "South<*br*>West", _
"West", "North<*br*>West")
' Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0) background and 1 pixel
' 3D border
Set c = cd.PolarChart(460, 500, &He0e0e0, &H000000, 1)
' Add a title to the chart at the top left corner using 15pt Arial Bold Italic font. Use a wood
' pattern as the title background.
Call c.addTitle("Polar Area Chart Demo", "Arial Bold Italic", 15).setBackground(c.patternColor( _
Server.MapPath("wood.png")))
' Set center of plot area at (230, 280) with radius 180 pixels, and white (ffffff) background.
Call c.setPlotArea(230, 280, 180, &Hffffff)
' Set the grid style to circular grid
Call c.setGridStyle(False)
' Add a legend box at top-center of plot area (230, 35) using horizontal layout. Use 10pt Arial Bold
' font, with 1 pixel 3D border effect.
Set b = c.addLegend(230, 35, False, "Arial Bold", 9)
Call b.setAlignment(cd.TopCenter)
Call b.setBackground(cd.Transparent, cd.Transparent, 1)
' Set angular axis using the given labels
Call c.angularAxis().setLabels(labels)
' Specify the label format for the radial axis
Call c.radialAxis().setLabelFormat("{value}%")
' Set radial axis label background to semi-transparent grey (40cccccc)
Call c.radialAxis().setLabelStyle().setBackground(&H40cccccc, 0)
' Add the data as area layers
Call c.addAreaLayer(data2, -1, "5 m/s or above")
Call c.addAreaLayer(data1, -1, "1 - 5 m/s")
Call c.addAreaLayer(data0, -1, "less than 1 m/s")
' Output the chart
Set viewer = cd.WebChartViewer(Request, "chart1")
Call viewer.setChart(c, cd.SVG)
' Include tool tip for the chart
viewer.ImageMap = c.getHTMLImageMap("", "", "title='[{label}] {dataSetName}: {value}%'")
%>
<!DOCTYPE html>
<html>
<head>
<title>Polar Area Chart</title>
<!-- Include ChartDirector Javascript Library to support chart interactions -->
<script type="text/javascript" src="cdjcv.js"></script>
</head>
<body style="margin:5px 0px 0px 5px">
<div style="font:bold 18pt verdana;">
Polar Area Chart
</div>
<hr style="border:solid 1px #000080; background:#000080" />
<div style="font:10pt verdana; margin-bottom:1.5em">
<a href="viewsource.asp?file=<%= Request("SCRIPT_NAME") %>">View Chart Source Code</a>
</div>
<!-- ****** Here is the chart image ****** -->
<%= viewer.renderHTML() %>
</body>
</html>
Public Sub createChart(viewer As Object, chartIndex As Integer)
Dim cd As New ChartDirector.API
' Data for the chart
Dim data0()
data0 = Array(5, 3, 10, 4, 3, 5, 2, 5)
Dim data1()
data1 = Array(12, 6, 17, 6, 7, 9, 4, 7)
Dim data2()
data2 = Array(17, 7, 22, 7, 18, 13, 5, 11)
Dim labels()
labels = Array("North", "North<*br*>East", "East", "South<*br*>East", "South", _
"South<*br*>West", "West", "North<*br*>West")
' Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0) background and 1
' pixel 3D border
Dim c As PolarChart
Set c = cd.PolarChart(460, 500, &He0e0e0, &H000000, 1)
' Add a title to the chart at the top left corner using 15pt Arial Bold Italic font. Use a wood
' pattern as the title background.
Call c.addTitle("Polar Area Chart Demo", "arialbi.ttf", 15).setBackground(c.patternColor( _
"wood.png"))
' Set center of plot area at (230, 280) with radius 180 pixels, and white (ffffff) background.
Call c.setPlotArea(230, 280, 180, &Hffffff)
' Set the grid style to circular grid
Call c.setGridStyle(False)
' Add a legend box at top-center of plot area (230, 35) using horizontal layout. Use 10pt Arial
' Bold font, with 1 pixel 3D border effect.
Dim b As LegendBox
Set b = c.addLegend(230, 35, False, "arialbd.ttf", 9)
Call b.setAlignment(cd.TopCenter)
Call b.setBackground(cd.Transparent, cd.Transparent, 1)
' Set angular axis using the given labels
Call c.angularAxis().setLabels(labels)
' Specify the label format for the radial axis
Call c.radialAxis().setLabelFormat("{value}%")
' Set radial axis label background to semi-transparent grey (40cccccc)
Call c.radialAxis().setLabelStyle().setBackground(&H40cccccc, 0)
' Add the data as area layers
Call c.addAreaLayer(data2, -1, "5 m/s or above")
Call c.addAreaLayer(data1, -1, "1 - 5 m/s")
Call c.addAreaLayer(data0, -1, "less than 1 m/s")
' Output the chart
Set viewer.Picture = c.makePicture()
'include tool tip for the chart
viewer.ImageMap = c.getHTMLImageMap("clickable", "", _
"title='[{label}] {dataSetName}: {value}%'")
End Sub