11 Replies Latest reply on Nov 13, 2006 5:01 AM by David_S_deB

    dataTipFunction and ChartItemEvent bug?

    Jim the Knife
      Hi,

      I pulled the sample that follows from the Help file because of a problem I'm having putting data tips on my chart. I upgraded to the full version of Flex 2 from Beta 3, and my chart data tips stopped working. I redid them following the example from Help, but kept getting the following error when I move the mouse over the chart item: TypeError: Error #1034: Type Coercion failed: cannot convert mx.charts::HitData@3557fc1 to mx.charts.events.ChartItemEvent. I get the same error when I run the sample below (which had a couple of errors in it already that I fixed).

      So two questions: 1) is this a bug? and 2) how can I work around this?

      Thanks, Jim

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script><![CDATA[
      import mx.charts.events.ChartItemEvent;
      import mx.collections.ArrayCollection;

      [Bindable]
      public var expenses:ArrayCollection = new ArrayCollection([
      {Expense: "Taxes", Amount: 2000},
      {Expense: "Gas", Amount: 100},
      {Expense: "Food", Amount: 200}
      ]);

      public function dtFunc(e:ChartItemEvent):String {
      return e.hitData.item.Expense + ": <B>$" + e.hitData.item.Amount + "</B>";
      }
      ]]></mx:Script>
      <mx:BarChart dataProvider="{expenses}" showDataTips="true" dataTipFunction="dtFunc">
      <mx:verticalAxis>
      <mx:CategoryAxis dataProvider="{expenses}" categoryField="Expense" id="Expense"/>
      </mx:verticalAxis>
      <mx:horizontalAxis>
      <mx:LinearAxis id="Amount"/>
      </mx:horizontalAxis>
      <mx:series>
      <mx:BarSeries xField="Amount" yField="Expense"/>
      </mx:series>
      </mx:BarChart>
      </mx:Application>