Swiff Chart Generator is implemented as a COM object (swfchart.dll), invoked from a simple .NET managed assembly (GlobFX.SwiffChartGenerator.dll). It offers a variety of methods for managing and creating charts.


To insert a chart in a ASP.NET page, locate the Chart Web Control in the Visual Studio web form designer. This web control is initially located in the Swiff Chart Generator 4 tab. If it cannot be found, right-click on a Toolbox tab and select Add/Remove Items. Then check Chart with namespace GlobFX.SwiffChartGenerator. You can then insert this control into your ASP.NET page like any other web control.


A simple ASP.NET Example


The following example illustrates how simple it is to dynamically generate charts in a ASP.NET page. As mentioned in the previous paragraph, the example involves 2 files and an additional Swiff Chart style file (.scs):


To install and run this example, copy these 2 files on your Web site in the same directory.


ASP.NET page: SampleWebForm.aspx.cs

using System;
using 
GlobFX.SwiffChartGenerator;

public 
partial class SampleWebForm : System.Web.UI.Page
{
  
private void Page_Load(object sender, System.EventArgs e)
  {
    
// Set the heading for the graph
    
chart.Title"My Chart";

    
// Set chart categories
    
chart.SetCategoriesFromArray( new string[] { "Q1""Q2""Q3" } );

    
// Fill chart series
    
chart.SetSeriesCaption( 0"First Series" );
    
chart.SetSeriesValuesFromArray( 0new double[] { 1.23.511.} );

    
chart.SetSeriesCaption( 1"Second Series" );
    
chart.SetSeriesValuesFromArray( 1new double[] { 2.34.59.} );

    
chart.SetSeriesCaption( 2"Third Series" );
    
chart.SetSeriesValuesFromArray( 2new double[] { 3.25.514.} );

    
// Apply a Column style
    // The chart type is stored in the style file (*.scs)
    // Here the selected style is the predefined column style "SanFrancisco"
    
chart.LoadStyle( @"column\SanFrancisco" );

    
// Set the dimensions of the movie
    
chart.Width400;
    
chart.Height200;
  
}

ASP.NET page: SampleWebForm.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SampleWebForm.aspx.cs" Inherits="SampleWebForm" %>
<%@ Register TagPrefix="globfx" Namespace="GlobFX.SwiffChartGenerator" Assembly="GlobFX.SwiffChartGenerator" %>

<!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>Sample Chart</title>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        
<globfx:Chart id="chart" runat="server" Height="200px" Width="400px"></globfx:Chart>
    
</div>
    
</form>
</body>
</html>


What you will obtain