Using FusionCharts with ASP > Charting Data from an Array |
In this section, we'll show you how to use FusionCharts and ASP to plot charts from data contained in ASP arrays. We'll cover the following examples here:
Before you go further with this page, we recommend you to please see the previous section "Basic Examples" as we start off from concepts explained in that page. The code examples contained in this page are present in Download Package > Code > ASP > ArrayExample folder. |
Creating a single series chart from data contained in arrays |
The code to create a single series chart is contained in SingleSeries.asp and can be listed as under: |
<%@ Language=VBScript %> 'Now, we need to convert this data into XML. We convert using string concatenation. |
In the above example, we first include FusionCharts.js file to enable us embed the chart using JavaScript. We also include FusionCharts.asp to help us easily embed the charts. Thereafter, we define an ASP array arrData to store sales data for 6 different products. The array has two columns - first one for data label and the next one for data values. We define a variable strXML to store the entire XML data. To build the XML, we iterate through the array and using string concatenation. Finally, we render the chart using renderChart() function and pass strXML as dataXML. We include FC_Colors.asp, which contains the default color set for the FusionCharts. These colors in Hex code are optimized to give a snazzy look to the charts.The getFCColor() function in cyclic iteration returns these color values. When you view the chart, you'll see a chart as under: |
Creating a multi-series chart from data contained in arrays |
Let us now create a multi-series chart from data contained in arrays. We create a file MultiSeries.asp with the following code: |
<%@ Language=VBScript %> <% 'Now, we need to convert this data into multi-series XML. |
In the above example, we first include FusionCharts.js file to enable us embed the chart using JavaScript. We also include FusionCharts.asp to help us easily embed the charts. Thereafter, we define an ASP array arrData to store sales data for 6 different products. The array has three columns - first one for data label (product) and the next two for data values. The first data value column would store sales information for current year and the second one for previous year. We define a variable strXML to store the entire XML data. We also define strCategories, strDataCurr and strDataPrev variables to store XML data for categories elements, current year's dataset and previous year's dataset respectively. To build the XML, we iterate through the array and using string concatenation. We concatenate the entire XML finally in strXML. Finally, we render the chart using renderChart() function and pass strXML as dataXML. When you view the chart, you'll see a chart as under: |
In Download Package > Code > ASP > ArrayExample, we've more example codes to create Stacked and Combination Charts too, which we have not explained here, as they're similar in concept. You can directly see the code if you want to. |