yjwzuumu / birdeye

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

If colors array is non-0 length for MicroBarChart and MicroColumnChart, then columns not drawn - missing else case in createColumns/createBars. #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set a colors array on MicroBarChart or MicroColumnChart

<microcharts:MicroBarChart backgroundColor="#DDDDDD" 
backgroundStroke="#888888" colors="[0x666666, 0x000000, 0x000000, 
0x000000, 0x000000]" height="40" width="200" stroke="#888888" 
showDataTips="true" spacing="3" id="costChart" />

2. No columns appear, just an empty microchart background.

Here's the current code in createColumns()/createBars():
  if (colors == null || colors.lenght == 0)
      if (negative && dataValue < 0)
      column.fill = new SolidFill(_negativeColor);
      else
      {
    if (isNaN(color))
      column.fill = black;
    else 
      column.fill = new SolidFill(color);
      }

  Notice that there isn't an else case for the first if.  Missing {} make 
this difficult to notice at first glance.

Here is fixed code for both classes:

   if (colors == null || colors.length == 0) {
    if (negative && dataValue < 0) {
        column.fill = new SolidFill(_negativeColor);
    }
    else
    {
        if (isNaN(color)) {
            column.fill = black;
        }
        else {
            column.fill = new SolidFill(color);
        }
    }
}
else {
    if (i < colors.length) {
        column.fill = new SolidFill(colors[i]);
    }   
    else {
        // Use the last color in the array if colors size is less
        // than the number of data points.  
        column.fill = new SolidFill(colors[colors.length - 1]);
    }                   
}

What version of the product are you using? On what operating system?
trunk, (March 28th), windows

Original issue reported on code.google.com by boni...@frii.com on 28 Mar 2009 at 10:53

GoogleCodeExporter commented 9 years ago
Thanks.

Original comment by f4us...@gmail.com on 30 Mar 2009 at 9:45