FusionCharts Beginner’s Guide:The Official Guide for FusionCharts Suite
上QQ阅读APP看书,第一时间看更新

Time for action — set up FusionCharts for our first chart

  1. Create a folder on your hard-drive to centrally store all the examples that we will build iteratively. If you are working on a web server, you can create this under the root folder of the web application. Let us name it as LearningFusionCharts. You can give it any other name as well.

    Tip

    Downloading the example code

    You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

  2. Create a subfolder called FusionCharts within this folder. This folder will contain all the SWF and JavaScript files of FusionCharts, which are the FusionCharts Core files. If you are working on a web server, create this folder under the root of the web application, so that the entire web application can conveniently access this.
  3. Copy all the SWF and JS files from the Charts folder under the FusionCharts Installation Folder (where you had earlier downloaded and extracted the FusionCharts ZIP file) to the newly created FusionCharts folder. This step completes the installation of FusionCharts for your application.
  4. Create another folder under LearningFusionCharts and name it as FirstChart. This will be used to store the XML data and the HTML file for our first chart.

    Tip

    Upgrading the FusionCharts version, or converting from trial to licensed

    If you are upgrading to a newer version of FusionCharts, or converting from evaluation to a licensed version, all you need to do is copy the SWF and JS files from the new or licensed version and overwrite the existing files in the FusionCharts folder.

What just happened?

You just installed FusionCharts. It involved copying of all the SWF and JavaScript files of FusionCharts, which are the FusionCharts Core files. If you intend to plot just a subset of chart types, you can select only those SWF files and paste them here. However, copying all files makes it easier in the future whenever you need to create a new chart type in your application. Each SWF file is used to plot a particular type of chart in Flash and the name of the file represents the chart type. You can find the complete list of charts in FusionCharts Documentation | Introduction | List of Charts. For our first chart, we are going to use Column3D.swf to plot a 3D Column chart.

The FusionCharts folder also contains six JavaScript files that aid in embedding and configuring charts, along with rendering them in JavaScript when viewed on devices that do not support Flash. These files are as follows:

While creating your chart, as you will soon see, you just need to include FusionCharts.js in your page. The other files such as FusionCharts.HC.js, FusionCharts.HC.Charts.js, and jquery.min.js are dynamically loaded by the code in FusionCharts.js.

With the basic setup in place, let us focus on the data for our chart.