3

我正在尝试覆盖烛台图表项目渲染器,但无法在我自己的基础上发出基类渲染

来自 flex api 帮助:

itemRenderer
Type: mx.core.IFactory CSS Inheritance: No
Language Version: ActionScript 3.0  Product Version: Flex 3  Runtime Versions: Flash9, AIR 1.1 

A factory that represents the class the series will use to represent individual items on the chart. This class is instantiated once for each element in the chart. Classes used as an itemRenderer should implement the IFlexDisplayObject, ISimpleStyleClient, and IDataRenderer interfaces. The data property is assigned the chartItem that the skin instance renders.

作为自定义渲染器的文件声明:

package { // Empty package.

  import mx.charts.series.items.HLOCSeriesItem;
  import mx.core.IDataRenderer;
  import mx.core.IFlexDisplayObject;
  import mx.styles.ISimpleStyleClient;
  import flash.display.Graphics;
  import mx.charts.chartClasses.HLOCSeriesBase;
  import mx.charts.series.CandlestickSeries;

  public class CycleColorRenderer extends HLOCSeriesBase 

     implements IFlexDisplayObject, ISimpleStyleClient, IDataRenderer {

     private var colors:Array = [0xCCCC99,0x999933,0x999966];
     private var _chartItem:HLOCSeriesItem;

     public function CycleColorRenderer() {
        super();
     }

     public function get data():Object {
        return _chartItem;
     }

     public function set data(value:Object):void {
        _chartItem = value as HLOCSeriesItem; 
        invalidateDisplayList();
     }

     override protected function
        updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void {
           super.updateDisplayList(unscaledWidth, unscaledHeight);
/*           var g:Graphics = graphics;

           g.clear();  
           g.beginFill(colors[(_chartItem == null)? 0:0]);
           g.drawRect(0, 0, unscaledWidth, unscaledHeight);
           g.endFill();
*/      
/*         
           if( _chartItem && _chartItem.index == 0) {
            g.beginFill(0xFF0000); // Red line, you can select your own color
            // Draw the line across the chart. This is actually a rectangle with height 1.
            g.drawRect(-50,0,this.parent.width+50, 1);
            g.endFill();
           }
*/         
     }
  } // Close class.
} // Close package.

mxml 声明:

<mx:CandlestickSeries
    dataProvider="{TICKER}"
    openField="open"
    highField="high"
    lowField="low"
    closeField="close"
    displayName="TICKER"
    itemRenderer="CycleColorRenderer"
    >

图表正在被渲染,但默认的烛台不是空的,而是代替它们,但我可以检索条形属性并自己渲染 - 我只想从基类发出基本渲染器并在其上绘制。我错过了什么?

4

0 回答 0