passing dynamic values to xml file -flex fusion charts
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="com.fusionwidgets.components.*">
<components:FusionWidgets FCChartType="AngularGauge" FCDataURL="data/energyMtd.xml"/>
</s:BorderContainer>
and energyMtd.xml file as
<?xml version="1.0" encoding="UTF-8"?>
<chart decimals="2" palette="2" autoScale="1" paletteThemeColor="BDBDBD" showBorder="0" basefontColor="000000"
toolTipBgColor="BFBFBF" gaugeFillMix="{dark-10},{light-70},{dark-10}" gaugeFillRatio="3"
pivotRadius="6" gaugeInnerRadius="60%" tickValueDistance="10" showTickValues="1" tickVa开发者_运维技巧lueStep="2"
placeTicksInside="0" placeValuesInside="0" showToolTip="1" baseFontSize="9" adjustTM="0"
pivotFillColor="000000" dataStreamURL="" gaugeStartAngle="225" gaugeEndAngle="-45"
gaugeOriginX="100" gaugeOriginY="98" gaugeOuterRadius="75" numberSuffix="kW" upperLimit="100"
lowerLimit="0">
<colorRange>
<color minValue="0" maxValue="100" code="bbbaba"/>
</colorRange>
<dials>
<dial value="0" rearExtension="10" baseWidth="10" bgColor="000000"/>
</dials>
</chart>
how do i pass upperLimit="", dial value="" and maxValue="" values in colorRange dynamically from the flex side. i need these 3 values to plot on the angle gauge fusion chart
Seem that you need to change the code a bit.
fw.FCDataXML = xml.toString(); fw.FCRender();
I believe it should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="com.fusionwidgets.components.*"
creationComplete="init();">
<fx:Script>
<![CDATA[
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import mx.collections.ArrayCollection;
protected var xmlLoader:URLLoader;
[Bindable]
protected var xml:XML;
/**
*
*/
protected function init():void
{
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, parse);
xmlLoader.load(new URLRequest("data.xml"));
};
/**
*
* @param event
*/
protected function parse(event:Event):void
{
xml = event.target.data;
xml.ignoreWhitespace = true;
xml.ignoreComments = true;
xml.chart.@upperLimit = 100;
xml.chart.dials.dial.@value = 0;
xml.chart.colorRange.color.@maxValue = 100;
fw.dataProvider = new ArrayCollection(xml);
};
]]>
</fx:Script>
<components:FusionWidgets id="fw" FCChartType="AngularGauge" />
</s:BorderContainer>
I think you should check the component's documentation for more details about how it handles the data provider.
Good luck, Rob
////////////////////////////////////
Hi,
after you loaded the XML file in to an XML object you can set the attributes' and elements' values.
For instance:
xml.chart.@upperLimit = 100;
xml.chart.dials.dial.@value = 0;
xml.chart.colorRange.color.@maxValue = 100;
I hope this is what you need, Rob
Angular gauge only accepts XML data. It does not accept ArrayCollection.
Please check if you are converting the XML to String before passing.
Also you can enable the debug mode of the Gauge to see more details of the issue
精彩评论