Visual Mining contact us | site map | search

Products Solutions Resource Library Services Customers Partners Developers Company
Developers

NetCharts® Server: ASP.NET Toolkit getChartAsImageAndMap Visual Basic Example

This example shows how to utilize the NetCharts Server ASP.NET Toolkit using Visual Basic to add an interactive chart to an ASPX page.

Web Form

<%@ Register TagPrefix="ns" Namespace="NetChartsServer" Assembly="NetChartsServer" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="nswebchart.aspx.vb" Inherits="vbtoolkitexample.nswebchart"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>NetCharts Server .NET Toolkit - NSWebChart Control Example</title>
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<link REL="stylesheet" HREF="styles.css" TYPE="text/css">
</HEAD>
<body>
<p align=center><a href="http://www.visualmining.com" target="vmwindow"><img border=0 src="images/start-page-illo2.jpg"></a></p>
<P><B>Information:</B><br>
The <I><B>NSWebChart</B></I> control is a custom control that developers can
"drag" onto a WebForm to represent a chart from <STRONG>NetCharts Server</STRONG>.&nbsp;
By setting the properties of the <i><B>NSWebChart</B></I> control a developer can
quickly integrate a chart without the need for an ASP Literal control or
coding.&nbsp; CDX variables can be sent via the <i>Variables</i> property of
the <I><B>NSWebChart</B></I> control.&nbsp; If more control over the chart is
needed, consider using the <i>getChartAsImageAndMap</i>
API function.&nbsp; Click <a href="getChartAsImageAndMap.aspx">here</a> for a
example.</P>
<P>The <I><B>NSWebChart</B></I> control uses a
Model-II Architecture when producing chart images. When the <I><B>NSWebChart</B></I>
control produces the HTML elements to include
within a page using a Model-II Architecture, the image is placed within the
HTTP Session to be retrieved during the second pass. An HTML <i>img</i> element
is produced and included in the HTML returned from the <I><B>NSWebChart</B></I>
control. The <i>src</i> attribute of the generated <i>img</i> element points to
a location that is able to retrieve the image from the HTTP session and return
it to the browser.
</P>
<P>
Included with the .NET Toolkit is a WebForm, <i>getncsimage.aspx</i>, that can
be used to retrieve the image from the HTTP Session and return it to the
browser. Copy the <i>getncsimage.aspx</i> and <i>getncsimage.aspx.vb</i> files
from the <i>asp.net</i> directory of the toolkit installation into the Web
Application root directory (e.g. C:\InetPub\wwwroot\WebApplication) and import
them into your application before requesting any NetCharts Server chart.&nbsp;</P>
<P><b>Example:</b><br>
<ns:NSWebChart id="NSWebChart1" runat="server" Height="238px" Width="524px" ChartFile="basicbar.cdx"
Project="Examples/Suppliers"></ns:NSWebChart>
</P>
<p><b>Source Code:</b><br>
<span class="code">Dim hashTable As Hashtable = NSWebChart1.Variables<br>
If (hashTable Is Nothing) Then<br>
&nbsp;&nbsp;hashTable = New Hashtable<br>
End If<br>
hashTable.Add("THETITLE", "Example Chart Using the NSWebChart Control")<br>
NSWebChart1.Variables = hashTable</span></p>
</body>
</HTML>

Source Code

Public Class nswebchart
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents NSWebChart1 As NetChartsServer.NSWebChart

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim hashTable As Hashtable = NSWebChart1.Variables
If (hashTable Is Nothing) Then
hashTable = New Hashtable
End If
hashTable.Add("THETITLE", "Example Chart Using the NSWebChart Control")
NSWebChart1.Variables = hashTable
End Sub

End Class


© 2008 Visual Mining, Inc. All rights reserved.
1-800-308-0731 | info@visualmining.com | privacy statement | legal
15825 Shady Grove Rd., Suite 20, Rockville, MD 20850 USA

Quote: Syntricity