[Web Version (in ASP)] aspdemo\enhancedarea.asp
<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")
' The data for the area chart
data = Array(30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66, 56, _
48, 52, 65, 62)
' The labels for the area chart
labels = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", _
"15", "16", "17", "18", "19", "20", "21", "22", "23", "24")
' Create a XYChart object of size 600 x 360 pixels, with a brushed silver background, 1 pixel 3D
' border effect, rounded corners and soft drop shadow.
Set c = cd.XYChart(600, 360, cd.brushedSilverColor(), cd.Transparent, 1)
Call c.setRoundedFrame()
Call c.setDropShadow()
' Set default directory for loading images from current script directory
Call c.setSearchPath(Server.MapPath("."))
' Add a title box to the chart using 18pt Times Bold Italic font.
Set title = c.addTitle( _
"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance Enhancer " & _
"<*img=star.png*><*img=star.png*><*/*>", "Times New Roman Bold Italic", 18)
'
' Use a text box with a depressed 3D border to create the inner depressed region
'
' The width of the frame border
frameWidth = 5
' Set the depressed region position
Set contentBox = c.addText(frameWidth, title.getHeight(), "")
Call contentBox.setSize(c.getDrawArea().getWidth() - 1 - frameWidth * 2, c.getDrawArea( _
).getHeight() - title.getHeight() - frameWidth - 1)
' Use -1 as the rasied effect to create a depressed region
Call contentBox.setBackground(cd.Transparent, cd.Transparent, -1)
' Set rounded corners, and put the text box at the back of the chart
Call contentBox.setRoundedCorners(10)
Call contentBox.setZOrder(cd.ChartBackZ)
' Tentatively set the plotarea to 50 pixels from the left depressed edge, and 25 pixels under the
' top depressed edge. Set the width to 75 pixels less than the depressed region width, and the
' height to 75 pixels less than the depressed region height. Use white (ffffff) background,
' transparent border, and grey (cccccc) horizontal and vertical grid lines.
Set plotArea = c.setPlotArea(50 + contentBox.getLeftX(), contentBox.getTopY() + 25, _
contentBox.getWidth() - 75, contentBox.getHeight() - 75, &Hffffff, -1, -1, &Hcccccc, -1)
' Add a title to the y axis
Call c.yAxis().setTitle("Energy Concentration (KJ per liter)")
' Set the labels on the x axis.
Call c.xAxis().setLabels(labels)
' Display 1 out of 3 labels on the x-axis.
Call c.xAxis().setLabelStep(3)
' Add a title to the x axis using CDML
Call c.xAxis().setTitle("<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>")
' Set the axes width to 2 pixels
Call c.xAxis().setWidth(2)
Call c.yAxis().setWidth(2)
' Add an area layer to the chart using a gradient color that changes vertically from
' semi-transparent red (60ff0000) to semi-transparent white (60ffffff)
Call c.addAreaLayer(data, c.linearGradientColor(0, contentBox.getTopY() + 20, 0, _
contentBox.getTopY() + contentBox.getHeight() - 50, &H60ff0000, &H60ffffff))
' Adjust the plot area size, such that the bounding box (inclusive of axes) is 15 pixels from the
' left depressed edge, 25 pixels below the top depressed edge, 25 pixels from the right depressed
' edge, and 15 pixels above the bottom depressed edge.
Call c.packPlotArea(contentBox.getLeftX() + 15, contentBox.getTopY() + 25, contentBox.getLeftX() + _
contentBox.getWidth() - 25, contentBox.getTopY() + contentBox.getHeight() - 15)
' Add a custom CDML text with the bottom right corner is anchored to the bootom right corner of the
' plot area, with 5 pixels margin.
Call c.addText(plotArea.getLeftX() + plotArea.getWidth() - 5, plotArea.getTopY() + _
plotArea.getHeight() - 5, _
"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*><*font=Times New Roman Bold " & _
"Italic,size=10,color=804040*>Molecular<*br*>Engineering<*/*>").setAlignment(cd.BottomRight)
' 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='Hour {xLabel}: {value} KJ/liter'")
%>
<!DOCTYPE html>
<html>
<head>
<title>Enhanced 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;">
Enhanced 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>
[Windows Version (in Visual Basic)] vbdemo\enhancedarea.cls
Public Sub createChart(viewer As Object, chartIndex As Integer)
Dim cd As New ChartDirector.API
' The data for the area chart
Dim data()
data = Array(30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66, _
56, 48, 52, 65, 62)
' The labels for the area chart
Dim labels()
labels = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", _
"15", "16", "17", "18", "19", "20", "21", "22", "23", "24")
' Create a XYChart object of size 600 x 360 pixels, with a brushed silver background, 1 pixel 3D
' border effect, rounded corners and soft drop shadow.
Dim c As XYChart
Set c = cd.XYChart(600, 360, cd.brushedSilverColor(), cd.Transparent, 1)
Call c.setRoundedFrame()
Call c.setDropShadow()
' Add a title box to the chart using 18pt Times Bold Italic font.
Dim title As ChartDirector.TextBox
Set title = c.addTitle( _
"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance Enhancer " & _
"<*img=star.png*><*img=star.png*><*/*>", "timesbi.ttf", 18)
'
' Use a text box with a depressed 3D border to create the inner depressed region
'
' The width of the frame border
Dim frameWidth As Long
frameWidth = 5
' Set the depressed region position
Dim contentBox As ChartDirector.TextBox
Set contentBox = c.addText(frameWidth, title.getHeight(), "")
Call contentBox.setSize(c.getDrawArea().getWidth() - 1 - frameWidth * 2, c.getDrawArea( _
).getHeight() - title.getHeight() - frameWidth - 1)
' Use -1 as the rasied effect to create a depressed region
Call contentBox.setBackground(cd.Transparent, cd.Transparent, -1)
' Set rounded corners, and put the text box at the back of the chart
Call contentBox.setRoundedCorners(10)
Call contentBox.setZOrder(cd.ChartBackZ)
' Tentatively set the plotarea to 50 pixels from the left depressed edge, and 25 pixels under
' the top depressed edge. Set the width to 75 pixels less than the depressed region width, and
' the height to 75 pixels less than the depressed region height. Use white (ffffff) background,
' transparent border, and grey (cccccc) horizontal and vertical grid lines.
Dim plotArea As PlotArea
Set plotArea = c.setPlotArea(50 + contentBox.getLeftX(), contentBox.getTopY() + 25, _
contentBox.getWidth() - 75, contentBox.getHeight() - 75, &Hffffff, -1, -1, &Hcccccc, -1)
' Add a title to the y axis
Call c.yAxis().setTitle("Energy Concentration (KJ per liter)")
' Set the labels on the x axis.
Call c.xAxis().setLabels(labels)
' Display 1 out of 3 labels on the x-axis.
Call c.xAxis().setLabelStep(3)
' Add a title to the x axis using CDML
Call c.xAxis().setTitle( _
"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>")
' Set the axes width to 2 pixels
Call c.xAxis().setWidth(2)
Call c.yAxis().setWidth(2)
' Add an area layer to the chart using a gradient color that changes vertically from
' semi-transparent red (60ff0000) to semi-transparent white (60ffffff)
Call c.addAreaLayer(data, c.linearGradientColor(0, contentBox.getTopY() + 20, 0, _
contentBox.getTopY() + contentBox.getHeight() - 50, &H60ff0000, &H60ffffff))
' Adjust the plot area size, such that the bounding box (inclusive of axes) is 15 pixels from
' the left depressed edge, 25 pixels below the top depressed edge, 25 pixels from the right
' depressed edge, and 15 pixels above the bottom depressed edge.
Call c.packPlotArea(contentBox.getLeftX() + 15, contentBox.getTopY() + 25, _
contentBox.getLeftX() + contentBox.getWidth() - 25, contentBox.getTopY() + _
contentBox.getHeight() - 15)
' Add a custom CDML text with the bottom right corner is anchored to the bootom right corner of
' the plot area, with 5 pixels margin.
Call c.addText(plotArea.getLeftX() + plotArea.getWidth() - 5, plotArea.getTopY() + _
plotArea.getHeight() - 5, _
"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>" & _
"<*font=timesbi.ttf,size=10,color=804040*>Molecular<*br*>Engineering<*/*>").setAlignment( _
cd.BottomRight)
' Output the chart
Set viewer.Picture = c.makePicture()
'include tool tip for the chart
viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='Hour {xLabel}: {value} KJ/liter'")
End Sub
© 2021 Advanced Software Engineering Limited. All rights reserved.