|
||||||||||||||||||||||||
Creating a chart with AnyChart Flash Chart ComponentAnyChart is a flexible component for creation charts in Web, so let's see step by step how to create a page with chart. Create a web pageFirst af all we need a plain HTML page that contains a Flash object, and place it to some folder on your web site: Below we've done it, creating AnyChartTest folder in IIS wwwroot folder:
TermsContainer page: a page where chart will be displayed; it should contain <object> tag that will hold a Flash object linking to one of AnyChart SWF files, this page can be HTML, ASP, ASP.NET, CF, PHP, CGI, Perl (or any other scripting language capable to produce HTML output).Data provider: AnyChart accepts all data needed to show tha chart in a single XML File. The structure of this file will be explained later. Chart SWF: Every chart type displayed by AnyChart is contained in a separate swf file - that is why we created an swf subfolder. Choosing Chart data and its visual styleAs we are creating a chart we need some data for it. Imagine that we want to compare in a visual manner top ten Western Pennsylvania's companies. So, we have the following numbers:
To transmit this data to AnyChart component we need to convert it to XML, like that:
Now copy the above code, open anychart.xml from AnyChartTest folder in any plain text editor and paste code there. XML structure may look complex, but most of the tags are self descriptive and we can describe everything done in XML in several words:
HTML File structureOnly one step remains and we will see our chart on the Web! Here is the code you should paste in anychart.html (just open it in any text editor and copy-paste the code):
Only text in bold is the html code, that you need to embed AnyChart into a HTML page. The explanation of this code is simple, but requires attention: We've inserted an <object> and <embed> tag, that holds an information about Flash movie inserted into HTML page, we've set that swf used is Horizontal2DColumn.swf and supplied it with the parameter that points to XML Data file:
<param name="movie" value="./swf/Horizontal2DColumn.swf?XMLFile=anychart.xml" /> Why should we use all these HTML tags? What do they do?The OBJECT tag is for Internet Explorer 3.0 or later on Windows 9x/2000/NT/ME/XP platforms or any browser that supports the use of the Flash ActiveX control. The "classid" must appear exactly as it does in this example. The "codebase" attribute must also appear exactly as it does in this example; it tells the browser where to find Flash Player for automatic download. Internet Explorer 3.0 or later on Windows 9x/2000/NT/ME/XP will prompt the user with a dialog asking if they would like to auto-install the Flash Player if it's not already installed. This process can occur without the user having to restart the browser. The EMBED tag is for Netscape Navigator 2.0 or later, or browsers that support the use of the Netscape-compatible plugin version of Flash Player. The "pluginspage" attribute tells the browser where to direct the user to find Flash Player for download if the Player is not already installed. The user would then need to download and run the installer and restart their browser. To ensure that the most browsers will play your Flash Player movies, you should place the EMBED tag nested within the OBJECT tag as shown in the above example. ActiveX-enabled browsers will "ignore" the EMBED tag inside the OBJECT tag. Netscape and Microsoft browsers using the Flash Plugin will not recognize the OBJECT tag and will read only the EMBED tag. See the full explanation of embedding Flash into HTML page at Adobe Flash website: Flash TechNote - Macromedia Flash OBJECT and EMBED tag syntax FinalNow we should launch our html page in a web browser, in our case we can use both:
http://localhost/AnyChartTest/anychart.html
If everything was done exactly as described above, you will see the following chart:
|
| Copyright ©2007 AnyChart.Com All rights reserved. |