Update with new data string
Description of dynamic data update through xml_string on Javascript example
In this method, you send the XML data along with the HTML Content and chart SWF file to the browser. The SWF loads, reads this data (present in same page) and then renders the chart.
The following steps are involved in this process:
- You send the HTML content, chart SWF file and XML data all at once to the end viewer's browser.
- Once the SWF is loaded on the end viewer's machine, it reads the XML data present on the same page
- It finally parses it and then renders the chart.
Javascript example:
For example we will create updateChartByString() function, that will receive two parameters:
- object identifier (object id) - should be unique for every Flash SWF
object in case of several objects on one page. You create it embedding
flash content: <object id="flashchart" ..> and <embed
name="flashchart" ...>
- variable 'file' (string) - this variable will receive XML string
If your XML Data Document contains special characters in XML data mode, you'll need to XML/URL Encode them.
Now we declare XML string variables themselves:
Our functionality is just changing the data XML source file with chart update by clicking on the correspondent page button. So we should put our function with required parameters on button click event (onClick):
Where:
- flashchart - que identifier of our FCP Chart object on the page
- xml1, xml2, xml3 - variables with XML data
So the whole code will look like this:
Clicking on the "Load XML String 1" button browser forced to send two parameters (object name and xml1 variable containing our XML string data) to our function
updateChartByString() and FCP Chart will immediately render the chart based on new data from XML string.
Note: XML data string method is not recommended if you have higher amounts of data. In that case, use should use XML Data URL method.