feisishui / birdeye

Automatically exported from code.google.com/p/birdeye
0 stars 0 forks source link

Using percentWidth on charts extending from BasicMicroChart.as sometimes loses data for parent with multiple children #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a Flox container (HBox in a DataGrid for example), and set the 
width to be a value that will be decreased by the Box when it does its 
measurement, or just add other children so that the % width of the 
MicroChart is more than the width the chart will be allocated.

<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"...
  <mx:Label width="30" text="{averageRequestsPerDay}" textAlign="right" />
    <microcharts:MicroLineChart width="100%" color="#666666"
          backgroundColor="#CCCCCC" height="20" 
          dataProvider="[3,7, 8, 0, 0, 4, 5]"
          negative="false" showDataTips="true"  />
</HBox>

2. When the chart is rendered, data points are lost.  
The attached image, BasicMicroChart_percentWidthIssue.gif shows that only 
the first 4 points are rendered or a 8 data point dataProvider.

3. The issue seems to be the measure() method in BasicMicroChart which is 
basically assuming that the percentage value is accurate and has not been 
reduced by the parent's measurement algorithms.
  tempWidth = Math.max(0, percentWidth/100 * (parent.width - edgeMet.left -
 edgeMet.right));

4. The issue does not appear if the width corresponding to the 
percentWidth assigned to the Chart is not reduced by the parent's 
measurement algorithm.

What is the expected output? What do you see instead?
I'd expect to see all of the data points rendered, allowing the parent's 
measurement to flow down to the children instead of having the MicroChart 
child try to do it itself.

Possible fix:
Just have the percentWidth() method work like UIComponent - if 
percentWidth is changed, then invalidate the parent size, and have it set 
the width on the child, etc.

        override public function set percentWidth(val:Number):void
        {
            _percentWidth = val;

            var p:IInvalidating = parent as IInvalidating;
            if (p) {
                p.invalidateSize();
                p.invalidateDisplayList();
            }
        }

Then in the measure() method in BasicMicroChart.as, the percentWidth 
calculations can be removed.

The BasicMicroChart_possibleFix.gif image shows the result - all of the 
data points are rendered.

What version of the product are you using? On what operating system?

Please provide any additional information below.

A BasicMicroChart.as used for the fix with the percentWidth changes and 
measure() commented  lines is attached.

percentHeight could be similarly changed.

Original issue reported on code.google.com by boni...@frii.com on 30 Mar 2009 at 4:29

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the suggested fix. It seems to work well.

Original comment by f4us...@gmail.com on 30 Mar 2009 at 10:25

GoogleCodeExporter commented 9 years ago

Original comment by f4us...@gmail.com on 31 Mar 2009 at 6:59