Flex柱形图定制

发布于 2024-08-28 04:06:32 字数 232 浏览 5 评论 0原文

当我通过重写 updateDisplayList 函数在 Flex 中自定义 ColumnChart 时,图例中的颜色不再显示。如下图所示:

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

我错过了什么吗?

谢谢。

When I customized the ColumnChart in Flex by overrided updateDisplayList function, colors in legend no longer display. As you will see in the below picture:

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

Does I missed anything?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

复古式 2024-09-04 04:06:32

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

覆盖受保护的功能
updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void
{
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);

}

In case you want to look into the source code, here is what I did.

override protected function
updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void
{
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);

}
慕巷 2024-09-04 04:06:32

您可以使用 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

自定义图例的示例:
如何排除图例中的系列 (Flex)

You can format the legend markers by using legendMarkerRenderer. This article shows you how towards the bottom:
http://livedocs.adobe.com/flex/3/html/help.html?content=charts_formatting_13.html

You can also customize your LegendItem's even more by creating your own LegendItem's:
http://livedocs.adobe.com/flex/3/langref/mx/charts/LegendItem.html

Example to customize your Legend:
How to exclude series in legend (Flex)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文