This example creates a chart using data specified in arrays. The arrays are set to the category and value data, and then are used with the SetCategoriesFromArray and fcomthsetcategoriesfromarray.htm SetSeriesValuesFromArray methods to set the chart data. The image below is a snapshot of the resulting chart.


To run this example, copy the remainder of the text in this topic into an ASP page.

 <%@ LANGUAGE="VBSCRIPT" %>

 <%
  Dim categories(3), values(3), chart

    ' Create a column 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 an array of strings representing the categories.
    ' The categories will be the same for all three series.
    categories(0) = "Week 1"
    categories(1) = "Week 2"
    categories(2) = "Week 3"
    categories(3) = "Week 4"

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

    ' Set the categories for all the series 
    chart.SetCategoriesFromArray categories 

    ' Series one contains revenues data for "Harry Potter".
    ' Set the series caption (the text that appears in the legend).

    values(0) = 93.5 ' The Week 1 value.
    values(1) = 58.5 ' The Week 2 value.
    values(2) = 21.0 ' The Week 3 value.
    values(3) = 14.8 ' The Week 4 value.
   
    chart.SetSeriesCaption 0, "Harry Potter"
    chart.SetSeriesValuesFromArray 0, values

    ' Series two contains revenues data for "Monsters, Inc.".
    ' Set the series caption (the text that appears in the legend).

    values(0) = 63.4 ' The Week 1 value.
    values(1) = 46.2 ' The Week 2 value.
    values(2) = 23.0 ' The Week 3 value.
    values(3) = 24.3 ' The Week 4 value.

    chart.SetSeriesCaption 1, "Monsters, Inc."
    chart.SetSeriesValuesFromArray 1, values

    ' Series three contains revenues data for "Lord of the Rings".
    ' Set the series caption (the text that appears in the legend).

    values(0) = 45.3 ' The Week 1 value.
    values(1) = 37.3 ' The Week 2 value.
    values(2) = 23.0 ' The Week 3 value.
    values(3) = 16.2 ' The Week 4 value.

    chart.SetSeriesCaption 2, "Lord of the Rings"
    chart.SetSeriesValuesFromArray 2, values

    ' Set the chart title to "Movie Revenues per Week".
    chart.SetTitle "Movie Revenues per Week"

    ' 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 Strings
Creating a Chart Using Data Specified in URLs
Creating a Chart Using Data From a Text File
Creating a Chart Using Data From an ADO Recordset