The Flash Statistical Chart can be dynamically updated in ASP. NET.

Source: Internet
Author: User

How can I insert a dynamically updated Flash Statistical Chart on my ASP. NET page? There are a lot of online resources such as Fusioncharts and amCharts ......),
However, I think the most amazing result is the amcharts Statistical Chart, which can also interact with users.

The Flash Statistical Chart can be dynamically updated:

Bar chart)


Pie chart)

Stock chart)


How is it? Is the effect dazzling? Go to the official website and try it out. It will be better than you think ~ You can also set a lot of effects on your own)
Amcharts Official WebsiteAll kinds of files can be downloaded and used for free. The only drawback is that the free version will display the links of its company, but this can be cracked,

DownloadAmcharts_key.txtPut it in the same directory of flash.

I use two different flash versions. One is a bar chart downloaded directly from the official website, and the other is a pie chart that I don't know, but it is also amcharts, but it seems to have been cracked. There should be only one xml file. Generally, there should be two files, one of which is the main setting content and the other is the main setting appearance.) For example:


Preparation: the swf file of the statistical graph, the xml data file,Swfobject1.5(Now 2. x is available, but it feels 1.5 comfortable)
Let's talk about how to download it from the official website. Directly presented in code: (for details about swfobject, referOfficial documentation)

  
  1.  <script type="text/javascript" src="js/swfobject.js"></script> 
  2.  <div id="flashcontent"> 
  3.      <strong>You need to upgrade your Flash Player</strong> 
  4.  </div> 
  5.  <script type="text/javascript"> 
  6.  // <![CDATA[  
  7.      var rand = Rand();  
  8.      var so = new SWFObject("amcolumn.swf", "column", "360", "300", "8", "#FFFFFF");  
  9.      so.addVariable("settings_file", encodeURIComponent("amcolumn_settings.xml?"+Math.random()));  
  10.     so.addVariable("data_file", encodeURIComponent("amcolumn_data.xml?"+Math.random()));  
  11.     so.write("flashcontent");  
  12. // ]]> 
  13. </script> 

Reference swfobject. js first, or the compiler will strike ~ :)

Then there is a div, or span, which contains a sentence"You need to upgrade your Flash Player ", You must have guessed it was not added in flash.
This statement is displayed at the time of loading. Why? Take a look. The first sentence in SWFObject (case sensitive) references the flash path to be loaded, and then the following two sentences are associated with the xml file, if you want to dynamically change the flash, you must add a random variable after the xml, otherwise the flash will only change after you re-run or clear the cache, And the last so. write replaces the content in the div with flash.

The following is the code for changing the content: (because I am not familiar with xml, I am confused about a method for reference only)

  
  1. Using System. Xml;
  2. XmlDocumentDoc=NewXmlDocument ();
  3. Doc. Load (Server. MapPath ("amcolumn_data.xml "));
  4. XmlNodeListNodelist=Doc. GetElementsByTagName ("value"); // obtain all nodes whose tags are named value.
  5. Nodelist. Item (4). InnerText="4000"; // Set the serial value of the node to be modified
  6. Doc. Save (Server. MapPath ("amcolumn_data.xml"); // Save it to xml

Okay, so we're done ~

Then let's talk about the usage of another flash. This is a lot of trouble. Chinese and foreign websites have all been rummaged over (a little exaggerated, but I did not solve it until half past five in the morning.) I started to say that this flash only has one xml file. If you want to implement dynamic data using the previous method, it is impossible, because the flash reads xml from the inside, it cannot be dynamically displayed when it is modified. I first want to disable the cache, but it is also impossible, I even thought of a more absolute way: directly overwrite the xml of the temporary windows folder with the modified xml.

But it still won't work. In the end, we can only decompile flash, but fortunately the flash code is not so troublesome and we haven't found the loaded function for a long time.

 
  1. function load(url)  
  2. {  
  3.       xml.load(url);  
  4. } 

Then I added random variables directly to the url.

 
  1. function load(url)  
  2. {  
  3.       xml.load(url+“?"+Math.random());  
  4. } 

In this way, the Flash Statistical Chart can be dynamically updated in ASP. NET.

This article is from the blog of Darryn, "using a dynamically updatable flash Statistical Chart in ASP. NET".

  1. ASP. NET Control Learning Summary
  2. Some basic knowledge about ASP. net mvc Framework
  3. ASP. NET cache mechanism: balance between development efficiency and Optimization
  4. How to Avoid ASP. NET cache occupying system resources
  5. Comments on ASP. net web controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.