Contents

Introduction
Text File Sample
Sample Screenshot
ASP Page Sample
HTML Page Sample


Introduction

The Swiff Chart Generator provides you with an efficient way to specify data to a chart directly from a text file. To create a chart using data specified in a text file, you must call the SetDataFromTxtFile method with the text file name as argument. The items in your text file must be separated by tabs, columns, semicolons or any other character. See the SetDataFromTxtFile method for more information about the method profile.


Text File Sample

The following text file contains three series and four categories, showing the first 4 weeks revenues in million $ of 3 movies "Harry Potter", "Monsters, Inc." and "Lord of the Rings". The data are delimited with a semicolon character. The table below corresponds to the data formatted in the text file named "movies.txt".


FILE: movies.txt

 Movie Revenues per Week;Week 1;Week 2;Week 3;Week 4
 Harry Potter;93.5;58.5;21.0;14.8
 Monsters, Inc.;63.4;46.2;23.0;24.3
 Lord of the Rings;45.3;37.3;23.0;16.2
  Week 1 Week 2 Week 3 Week 4
Harry Potter 93.5 58.5 21.0 14.8
Monsters, Inc. 63.4 46.2 23.0 24.3
Lord of the Rings 45.3 37.3 23.0 16.2

To run this example, copy the text block into a text file named "movies.txt".


Sample Screenshot

The following image is a screenshot of the resulting chart generated in this sample.


ASP Page Sample

The following ASP page named "movies.asp" runs in conjunction with the corresponding text file page named "movies.txt". To run this example, copy the ASP code into an ASP page named "movies.asp".

FILE: movies.asp

 <%@ LANGUAGE="VBSCRIPT" %>

 <%
    Dim chart

    ' Create a chart with three series and four categories, showing the
    ' first 4 weeks revenues in million $ of 3 movies "Harry Potter",
    ' "Monsters, Inc." and "Lord of the Rings".

    ' Create a new Swiff Chart object.
    Set chart= Server.CreateObject("SwiffChartObject.ChartObj")

    ' Specify the separator characters used in the "movie.txt" text file.
    chart.SetSeparators ";", true

    ' The series and categories are in rows.
    seriesincolumn= false

    ' The first line of the text file are the categories.
    titlesinfirstrow= true

    ' The first column of the text file are the series caption.
    titlesinfirstcolumn= true

    ' Set the series, categories and title from the text file "movie.txt".
    chart.SetDataFromTxtFile "C:\movies.txt", seriesincolumn, titlesinfirstrow, titlesinfirstcolumn

    ' Set the chart graphical layout with a Swiff Chart style file.
    chart.LoadStyle "C:\Program Files\GlobFX\Swiff Chart Generator 4\styles\column\SanFrancisco.scs"

    ' Finally generate the Flash chart into the Response object.
    chart.ExportAsResponse

    ' Release the chart object
    Set chart= Nothing

    Response.End
 %>

See Also

Creating a Chart Using Data Specified in Arrays
Creating a Chart Using Data Specified in Strings
Creating a Chart Using Data Specified in URLs
Creating a Chart Using Data From an ADO Recordset