0 Replies Latest reply on Feb 28, 2007 8:14 AM by morty123

    Chart causes window to freeze

    morty123 Level 1
      The code sample below causes the flex charting code to freeze.

      The code is basically unable to recover in some circumstances if all the data is removed from the data provider.
      Any insight? Any way that I can submit this as a bug?

      --Morten Hoyer

      -----------------
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
      <mx:Script>
      <![CDATA[

      import mx.collections.ArrayCollection;
      import mx.core.UIComponent;
      import mx.charts.*;
      import mx.charts.series.*;
      import mx.charts.renderers.*;
      import mx.charts.chartClasses.*;
      import flash.xml.*;
      import mx.graphics.Stroke;
      import mx.controls.Alert;

      import mx.containers.TabNavigator;
      import mx.containers.Box;
      import mx.controls.DataGrid;

      public function init():void {

      // create chart
      var chart:CartesianChart = new CartesianChart();
      chart.percentHeight = 100;
      chart.percentWidth = 100;
      chart.showDataTips = true;
      chart.seriesFilters = [];

      var ls:LineSeries = new LineSeries();
      ls.xField = "Price";
      ls.yField = "Bid Size";
      ls.sortOnXField = true;
      ls.radius = 3;
      ls.displayName = "Size";
      ls.setStyle("fill", 0x0000FF);

      var stroke:Stroke = new Stroke();
      stroke.weight = 2;
      stroke.color = 0x0000FF;
      stroke.alpha = 0.3;
      ls.setStyle("lineStroke", stroke);
      ls.setStyle("stroke", stroke);

      var ls2:LineSeries = new LineSeries();
      ls2.xField = "Price";
      ls2.yField = "Ask Size";
      ls2.sortOnXField = true;
      ls2.radius = 3;
      ls2.displayName = "Size";
      ls2.setStyle("fill", 0x0000FF);

      var stroke:Stroke = new Stroke();
      stroke.weight = 2;
      stroke.color = 0x0000FF;
      stroke.alpha = 0.3;
      ls2.setStyle("lineStroke", stroke);
      ls2.setStyle("stroke", stroke);

      chart.series = [ls, ls2];

      //ls.setStyle("form", "step");
      var itemRenderer:ClassFactory = new ClassFactory(CircleItemRenderer);
      ls.setStyle("itemRenderer", itemRenderer);

      // vertical axis 1
      var verticalAxis:LinearAxis = new LinearAxis()
      verticalAxis.baseAtZero = false;
      chart.verticalAxis = verticalAxis;

      // horizontal axis
      var numAxis:LinearAxis = new LinearAxis()
      numAxis.baseAtZero = false;
      chart.horizontalAxis = numAxis;

      // horizontal axis renderer
      var axisRenderer:AxisRenderer = new AxisRenderer();
      axisRenderer.setStyle("canDropLabels", true);
      axisRenderer.setStyle("labelRotation", 90);
      axisRenderer.setStyle("labelGap", 4);
      chart.horizontalAxisRenderer = axisRenderer;

      // vertical axis renderer
      var vAxisRenderer:AxisRenderer = new AxisRenderer();
      vAxisRenderer.setStyle("canDropLabels", true);
      vAxisRenderer.setStyle("labelRotation", 0);
      vAxisRenderer.setStyle("labelGap", 4);
      chart.verticalAxisRenderer = vAxisRenderer;

      // add the
      this.addChild(chart);

      var data:ArrayCollection = new ArrayCollection();
      ls.dataProvider = data;
      ls2.dataProvider = data;

      var o:Object = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 1000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10179011;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 20000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29885;
      o['Bid Size'] = null;
      o['Ask Size'] = 6900000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29885;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29885;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29888;
      o['Bid Size'] = null;
      o['Ask Size'] = 3000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2989;
      o['Bid Size'] = null;
      o['Ask Size'] = 7000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.299;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = 10000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2987;
      o['Bid Size'] = 3500000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2987;
      o['Bid Size'] = 10179795;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2987;
      o['Bid Size'] = 3200000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2987;
      o['Bid Size'] = 10000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29868;
      o['Bid Size'] = 2200000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29865;
      o['Bid Size'] = 10000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29865;
      o['Bid Size'] = 5000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2986;
      o['Bid Size'] = 5000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2986;
      o['Bid Size'] = 20000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2986;
      o['Bid Size'] = 9750000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2986;
      o['Bid Size'] = 1000000;
      o['Ask Size'] = null;
      data.addItem(o);

      data.removeAll();

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 1000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10179011;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 20000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29885;
      o['Bid Size'] = null;
      o['Ask Size'] = 6900000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29885;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29885;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29888;
      o['Bid Size'] = null;
      o['Ask Size'] = 3000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2989;
      o['Bid Size'] = null;
      o['Ask Size'] = 7000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.299;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = 10000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2987;
      o['Bid Size'] = 3500000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2987;
      o['Bid Size'] = 10179795;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2987;
      o['Bid Size'] = 3200000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2987;
      o['Bid Size'] = 10000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29868;
      o['Bid Size'] = 2200000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29865;
      o['Bid Size'] = 10000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.29865;
      o['Bid Size'] = 5000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2986;
      o['Bid Size'] = 5000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2986;
      o['Bid Size'] = 20000000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2986;
      o['Bid Size'] = 9750000;
      o['Ask Size'] = null;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2986;
      o['Bid Size'] = 1000000;
      o['Ask Size'] = null;
      data.addItem(o);

      data.removeAll();

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 1000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10179011;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 20000000;
      data.addItem(o);

      o = new Object()
      o['Price'] = 1.2988;
      o['Bid Size'] = null;
      o['Ask Size'] = 10000000;
      data.addItem(o);
      }
      ]]>
      </mx:Script>




      </mx:Application>


      ---------------------------------------