Hi all,
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.
Hi all,
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.
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);
}
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: http://stackoverflow.com/questions/2491303/how-to-exclude-series-in-legend-flex/2495314#2495314