0
플렉스 차트에는 각 데이터 시리즈에서 범례를 만드는 코드가 있습니다. 현재 버튼을 클릭하면 drawLegend 함수가 실행됩니다.플렉스에서 범례를 렌더링하는 경우
자동으로 그릴 전설을 얻으려고하지만 drawLegend 함수를 호출 할 때 결정하는 데 문제가 있습니다. 사용자는 데이터를 검색하는 '업데이트'버튼을 클릭합니다. 사용자가 다른 버튼을 클릭 할 필요없이 전설을 만들고 싶습니다.
내가 여러 곳에서 내 drawLegend 기능을 넣어 가지고 (ResultHandler는 afterEffectEnd은 (차트 애니메이션 등) 아무것도 작동합니다.이 시리즈는 차트와 시리즈 애니메이션이 종료 된 이후에 추가 된 얼마 후
을, 전설을 추가 할 수 있습니다.
을 나는 함정이 시점과 내 함수를 호출 할 수 있습니까?
어떤 아이디어? 아래
나는 전설을 만드는 데 사용되는 코드입니다. 참고에도 불구하고 코드 각 시리즈를 처리 할 때 너무 일찍 호출되면 채우기 색상이 null이라는 사실을 발견했습니다.private function drawLegend(event:Event):void {
clearLegend();
// Use a counter for the series.
var z:int = 0;
var numRows:int;
if (chart.series.length % rowSize == 0) {
// The number of series is exactly divisible by the rowSize.
numRows = Math.floor(chart.series.length/rowSize);
} else {
// One extra row is needed if there is a remainder.
numRows = Math.floor(chart.series.length/rowSize) + 1;
}
for (var j:int = 0; j < numRows; j++) {
var gr:GridRow = new GridRow();
myGrid.addChild(gr);
for (var k:int = 0; k < rowSize; k++) {
// As long as the series counter is less than the number of series...
//skip columnset group
if (chart.series[z] is LineSeries || chart.series[z] is ColumnSeries){
if (z < chart.series.length) {
var gi:GridItem = new GridItem();
gr.addChild(gi);
var li:LegendItem = new LegendItem();
// Apply the current series' displayName to the LegendItem's label.
li.label = chart.series[z].displayName;
// Get the current series' fill.
var sc:SolidColor = new SolidColor();
sc.color = chart.series[z].items[0].fill.color;
// Apply the current series' fill to the corresponding LegendItem.
li.setStyle("fill", sc.color);//was just sc
// Apply other styles to make the LegendItems look uniform.
li.setStyle("textIndent", 5);
li.setStyle("labelPlacement", "left");
li.setStyle("fontSize", 9);
gi.setStyle("backgroundAlpha", "1");
gi.setStyle("backgroundColor", sc.color);
//gi.width = 80;
// Add the LegendItem to the GridItem.
gi.addChild(li);
}
}
// Increment any time a LegendItem is added.
z++;
}
}
}