1 Reply Latest reply on Oct 26, 2006 12:50 PM by stratosnatcher

    Chart stops showing series

      I'm making a custom component based on PlotChart. It has two series, one of which uses animations. A private member _dataSeries:ArrayCollection is assigned via a set method, and acts as a dataProvider to the non-animated series. The actual binding is of a slice of the ArrayCollection, which leaves out the last point.

      The set method that sets _dataSeries also sets a lastPoint:Object private member equal to the last point in the new ArrayCollection. This lastPoint object is bound as the animated series' dataProvider.

      The containing application initially assigns a new, empty ArrayCollection to the component, and then, from outside, slowly adds objects to the AC. This is, of course, updated inside the component too, since _dataSeries only holds a reference to the AC. An event handler within the component updates the lastPoint object everytime the ArrayCollection changes. Thus, the effect is that the newest point added (the Application always adds points to the end of the AC) animates into view, and the other points are bound to the non-animating series.

      Occasionally, though, the outer Application will assign in a populated ArrayCollection through the set method. The lastPoint variable is pointed to the last object, as always. And, in the event handler that processes subsequent changes to the ArrayCollection, I trace both the lastPoint object (trace(lastPoint.serial)), and the dataProvider (dataProvider[0].serial) of the animated series, and both show that this all occurs correctly.

      That is, the dataProvider for the animated series is still bound properly, and updated properly. However, after having made this new assignment to _dataSeries, the animated series ceases to display on-screen. The dataProvider keeps getting updated, but the graph on-screen never reflects this. You only see new points as they move into the non-animated series' dataProvider (the AC slice).

      Here's some of the component code:

      public function set dataSeries(newData:ArrayCollection):void {
      _dataSeries = newData; // _dataSeries is an ArrayCollection
      if(newData != null && newData.length > 0) {
      lastPoint = _dataSeries[_dataSeries.length - 1];
      if(_dataSeries != null)
      _dataSeries.addEventListener(CollectionEvent.COLLECTION_CHANGE, dataChangeHandler);

      private function dataChangeHandler(event:CollectionEvent):void {
      if(_dataSeries.length > 0) {
      // lastPoint is the bound dataProvider of newSeries
      lastPoint = _dataSeries[_dataSeries.length - 1];
      trace(this.id + " from dataProvider " + newSeries.dataProvider[0].serial);

      public function set animate(useEffect:Boolean):void {
      zoomIn.duration = 1500; // zoomIn is a SeriesZoom
      zoomIn.duration = 0;

      public function get animate():Boolean {
      if(zoomIn.duration == 0)
      return false;
      return true;

      P.S. Is there a way to insert one of those little code boxes in the forums? Like, the blue, sidescrolling text area?
        • 1. Re: Chart stops showing series
          stratosnatcher Level 1
          New developments:

          I've got two PlotCharts and two ColumnCharts. Each PlotChart shares an ArrayCollection with a ColumnChart. When I set the animation duration on the ColumnChart to 0, it turns of the animation (and display) of a corresponding point in the PlotChart, which also uses animation.

          So, I decided to make copies (I have functions to make forced copies of objects and ArrayCollections of Objects by making new objects, and copying property-by-property) so that each Chart has its own ArrayCollection dataProvider. The problem persists. Any ideas?