3 Replies Latest reply on May 14, 2007 6:22 PM by benrsch

    Adding effect programmatically to chart

    benrsch
      I cannot add an effect dynamically to my charts. I keep getting this error on load:



      param 1 incompatible
      virt mx.effects::IEffectInstance mx.effects::TweenEffect/mx.effects:TweenEffect::initInstance()
      over mx.effects::EffectInstance mx.charts.effects::SeriesEffect/mx.charts.effects:SeriesEffect::initInstance()
      VerifyError: Error #1053: Illegal override of SeriesEffect in mx.charts.effects.SeriesEffect.
      at com.vyante.actionscript.frontend::ChartData$iinit()
      at cspike/cspike::initSourceArray()[D:\wkExternFiles\frontend\flex\mxml\cspike.mxml:116]
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\flex_201_gmc\sdk\ frameworks\mx\core\UIComponent.as:7909]
      at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\flex_201_gmc\sdk\f rameworks\mx\core\UIComponent.as:7852]


      I've downloaded the latest hotfix sdk and charting. Any help at all would be appreciated, I've spent a number of hours trying to get this to work. I've tried setting it as a style, programmatically and with the mx tag, but to no avail.

      Thanks,
      B
        • 1. Re: Adding effect programmatically to chart
          peterrowe
          You must first define the effect before you can use it. What are you trying to do? You error shows a bad parameter, post the corresponding code so that we can see why it is failing. See the following example:

          <?xml version="1.0"?>
          <!-- charts/BasicSeriesSlideEffect.mxml -->
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
          <mx:Script><![CDATA[
          import mx.collections.ArrayCollection;

          [Bindable]
          public var expenses1:ArrayCollection = new ArrayCollection([
          {Month:"Jan", Income:2000, Expenses:1500},
          {Month:"Feb", Income:1000, Expenses:200},
          {Month:"Mar", Income:1500, Expenses:500}
          ]);

          [Bindable]
          public var expenses2:ArrayCollection = new ArrayCollection([
          {Month:"Jan", Income:1200, Expenses:800},
          {Month:"Feb", Income:2500, Expenses:300},
          {Month:"Mar", Income:575, Expenses:490}
          ]);

          public function changeProvider():void {
          myChart.dataProvider=expenses2;
          }

          ]]></mx:Script>

          <!-- Define chart effects -->
          <mx:SeriesSlide
          id="slideIn"
          duration="1000"
          direction="up"
          />
          <mx:SeriesSlide
          id="slideOut"
          duration="1000"
          direction="down"
          />

          <mx:Panel title="Column Chart with Basic Series Slide Effect">
          <mx:ColumnChart id="myChart" dataProvider="{expenses1}">
          <mx:horizontalAxis>
          <mx:CategoryAxis
          dataProvider="{expenses1}"
          categoryField="Month"
          />
          </mx:horizontalAxis>

          <mx:verticalAxis>
          <mx:LinearAxis minimum="0" maximum="3000"/>
          </mx:verticalAxis>

          <mx:series>
          <mx:ColumnSeries
          xField="Month"
          yField="Income"
          displayName="Income"
          showDataEffect="slideIn"
          hideDataEffect="slideOut"
          />
          <mx:ColumnSeries
          xField="Month"
          yField="Expenses"
          displayName="Expenses"
          showDataEffect="slideIn"
          hideDataEffect="slideOut"
          />
          </mx:series>
          </mx:ColumnChart>
          <mx:Legend dataProvider="{myChart}"/>
          </mx:Panel>

          <mx:Button id="b1" click="changeProvider()"
          label="Change Data Provider"
          />

          </mx:Application>
          • 2. Re: Adding effect programmatically to chart
            benrsch Level 1
            I compiled this code and this is the error I get on initialization:

            VerifyError: Error #1053: Illegal override of SeriesEffect in mx.charts.effects.SeriesEffect.
            at temp/::_SeriesSlide1_i()
            at temp$iinit()
            at _temp_mx_managers_SystemManager/create()
            at mx.managers::SystemManager/::initializeTopLevelWindow()
            at mx.managers::SystemManager/::docFrameHandler()

            Any ideas? I'm using a fresh SDK Version 2.0.1 build 155542.
            • 3. Re: Adding effect programmatically to chart
              benrsch Level 1
              Fixed my own problem. Wiped everything, did a complete clean install of the SDK and charting components. Obviously their was a conflicting library in there somewhere...