Appendix A: Web Server Application

Use in a Web Server Application

An IMSL C# Numerical Libraries chart can be integrated into an ASP.NET application through the WebChart component. The WebChart class extends System.Web.UI.WebCon­trols.Panel and can be added to an ASP.NET application like any other web control.

There are two sides to an ASP.NET application - the user interface and the code-behind class file. The user interface is often created visually with Visual Studio with the HTML code generated automatically. The code-behind class file is compiled into an assembly that is deployed with the web pages. The following example was generated using Visual Studio 2005. The method applies to other versions of Visual Studio though the code may be different in the details. The code-behind class file is written in C# like the other examples in this document.

The following code was automatically generated by Visual Studio by dragging a WebChart onto the page from the Toolbox containing web controls. The Web­Chart control can be added to the Toolbox by using the Add Items... dialog and browsing to the IMSL C# Numerical Libraries assembly, ImslCS.dll. Notice the reference to a WebChart object. This is the object that will be referenced from the code-behind class file.

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"

    Inherits="WebApplication1._Default" %>

 

<%@ Register assembly="ImslCS" namespace="Imsl.Chart2D" tagprefix="cc1" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

   

        <cc1:WebChart ID="WebChart1" runat="server" Height="240px"

            Width="240px">

        </cc1:WebChart>

   

    </div>

    </form>

</body>

</html>

For this basic example, the chart is created in the Page_Load method. The Chart object is obtained from the WebChart and the chart is configured in a manner similar to the desktop form examples. All chart types and most functionality of the IMSL C# Numerical Libraries is available through the WebChart control.

(Download Code)

 

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using Imsl.Chart2D;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        Chart chart = WebChart1.Chart;

        AxisXY axis = new AxisXY(chart);

        Data data = new Data(axis, new double[] {5,7,4,1,8});

        data.DataType = ChartNode.DATA_TYPE_LINE | ChartNode.DATA_TYPE_MARKER;

        data.MarkerType = ChartNode.MARKER_TYPE_FILLED_SQUARE;

        data.MarkerColor = System.Drawing.Color.Red;

        data.LineColor = System.Drawing.Color.Green;

    }

}

 

 

 

 



Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260