Flex柱形图自定义

时间:2010-04-06 03:42:09

标签: flex charts legend

当我通过覆盖updateDisplayList函数在Flex中自定义ColumnChart时,图例中的颜色不再显示。正如您将在下面的图片中看到的那样:

http://i41.tinypic.com/mim35d.png

我错过了什么吗?

感谢。

2 个答案:

答案 0 :(得分:0)

如果你想查看源代码,这就是我所做的。

覆盖受保护的功能     的updateDisplayList(参数unscaledWidth:编号,unscaledHeight属性:编号):无效     {             super.updateDisplayList(unscaledWidth,unscaledHeight);

        var fill:IFill;
        var state:String = "";

        if (_data is ChartItem && _data.hasOwnProperty('fill'))
        {
            state = _data.currentState;
            fill = _data.fill;
        }       
        else
            fill = GraphicsUtilities.fillFromStyle(getStyle('fill'));

        var color:uint;
        var adjustedRadius:Number = 0;

        color = ColorUtil.adjustBrightness2(GraphicsUtilities.colorFromFill(fill),-20);
        fill = new SolidColor(color);       
        adjustedRadius = getStyle('adjustedRadius');
        if (!adjustedRadius)
            adjustedRadius = 0;


        var stroke:IStroke = getStyle("stroke");

        var w:Number = stroke ? stroke.weight / 2 : 0;

        var rc:Rectangle = new Rectangle(w - adjustedRadius, w - adjustedRadius, width - 2 * w + adjustedRadius * 2, height - 2 * w + adjustedRadius * 2);

        var g:Graphics = graphics;
        g.clear();      
        g.moveTo(rc.left,rc.top);
        if (stroke)
            stroke.apply(g);
        if (fill)
            fill.begin(g,rc);
        g.lineTo(rc.right-5,rc.top);
        g.lineTo(rc.right-5,rc.bottom);
        g.lineTo(rc.left+5,rc.bottom);
        g.lineTo(rc.left+5,rc.top);
        if (fill)
            fill.end(g);

}

答案 1 :(得分:0)

您可以使用legendMarkerRenderer格式化图例标记。本文将向您展示如何走向最底: http://livedocs.adobe.com/flex/3/html/help.html?content=charts_formatting_13.html

您还可以通过创建自己的LegendItem来自定义您的LegendItem: http://livedocs.adobe.com/flex/3/langref/mx/charts/LegendItem.html

自定义图例的示例: How to exclude series in legend (Flex)