View Full Version : Help with Effects conflicting with Legends

05-30-2006, 08:44 AM
Hello, everybody! I have recently started to work with FLEX and I am having some problems with the showing of effects in barcharts when using Legends.

Basically, if I don't define a Legend for my barchart, the "SeriesSlide" Effect works properly. However, if I set the dataProvider for the Legend, the effect no longer appears.

The code is shown below. The data itself is not included, but I think that only with the script the problem will be spotted by those with more experience in Flex. I thank you all already! :D

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">

import com.xfactorstudio.xml.xpath.*;
import mx.charts.AxisRenderer;
import comp.*;

static var xml_doc = new XML();
var asPath:String;
function loadData(){
_global.asPath = "data.xml";
xml_doc.ignoreWhite = true;
xml_doc.onLoad = function(success){
if (success){
} else {
alert("Error while loading XML document");

function initComponents(){

mPanel0.title = "Panel0";

var query1 = "/units/datasection/chart3/months";
var data1:Array = XPath.selectNodes(xml_doc,query1);
var dp1:Array = _root.createDataProvider(data1);
barchart1.dataProvider = dp1;
barchart1.horizontalAxis.dataProvider = dp1;
barchart1.verticalAxis.dataProvider = dp1;

barchart1.series[0].showDataEffect = "Effect1";
barchart1.series[0].hideDataEffect = "Effect2";
barchart1.series[0].name = "name";

barchart1.horizontalAxisRenderer.title = "title1";
barchart1.verticalAxisRenderer.title = "title2";

function defineLegend(){
legend1.dataProvider = "barchart1";


<mx:SeriesSlide direction="up" duration="800" easing="" elementOffset="10" name="Effect1" />
<mx:SeriesSlide direction="down" duration="800" easing="" elementOffset="10" name="Effect2" />
<mx:SeriesSlide direction="right" duration="800" easing="" elementOffset="10" name="Effect21" />
<mx:SeriesSlide direction="left" duration="800" easing="" elementOffset="10" name="Effect22" />
<mx:SeriesInterpolate duration="1200" offset="20" name="Interpolate" />
<mx:Dissolve alphaFrom="0" alphaTo="100" duration="800" name="BlendIn" />
<mx:Dissolve alphaFrom="100" alphaTo="0" duration="800" name="BlendOut" />

<mx:Panel id="mPanel0" styleName="panel" backgroundColor="#FFF9FF" height="100%" width="100%">
<mx:HBox styleName="layoutMargin" height="100%" width="100%">
<mx:BarChart id="barchart1" height="100%" width="100%" showDataTips="true">
<mx:AxisRenderer styleName="axis" />
<mx:AxisRenderer />
<mx:LinearAxis minimum="0.465" interval="0.001" maximum="0.467"/>
<mx:CategoryAxis categoryField="month"/>
<mx:BarSeries xField="loans"/>
<mx:Legend id="legend1"/>