(三)图例渲染器:legendMarkerRenderer="renderer.MarcoLegendMarkerRenderer",主要运用graphics来绘制线条和圆点
/**
* 画连接虚线
*
* @param pointLength 点个数
* @param x1 起点横坐标
* @param y1 起点纵坐标
* @param x2 终点横坐标
* @param y2 终点纵坐标
*
* */
private function drawDash(g:Graphics, pointLength:int, x1:Number, y1:Number, x2:Number, y2:Number):void
{
var p1:Point = new Point(x1, y1);
var p2:Point = new Point(x2, y2);
var max:Number = Point.distance(p1, p2);
var dis:Number = 0;
var p3:Point;
var p4:Point;
while(dis < max){
p3 = Point.interpolate(p2, p1, dis / max);
dis += pointLength;
if(dis > max){
dis = max;
}
p4 = Point.interpolate(p2, p1, dis / max);
g.moveTo(p3.x, p3.y);
g.lineTo(p4.x, p4.y);
dis += twoPointDistance;
}
}
}
(四)显示节点的渲染器:itemRenderer="renderer.SolidColorCircleRenderer",可通过样式控制数据是否显示在图形上,比较复杂
[Style(name="fromIndex")]
[Style(name="labelPosition")]
[Style(name="labelColor")]
[Style(name="labelSize")]
public class SolidColorCircleRenderer extends ProgrammaticSkin implements IDataRenderer
{
private var chartItem:Object;
public var labelFunction:Function;
public var colorFunction:Function;
public function SolidColorCircleRenderer()
{
super();
}
public function get data():Object
{
return chartItem;
}
public function set data(value:Object):void
{
chartItem = value;
invalidateDisplayList();
}
// override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
// {
// super.updateDisplayList(unscaledWidth, unscaledHeight);
// var ls:LineSeriesItem =LineSeriesItem(chartItem);
// if(ls.yValue>0)
// {
// var solidColor:SolidColor = chartItem.fill as SolidColor;
//去年
// if(ls.element.yField== "field1")
// {
// solidColor = 0x00B0F0;
// }
// //今年
// else if(ls.element.yField == "field2")
// {
// solidColor = 0xC0504D;
// }
// //明年
// else
// {
// solidColor = 0x215968;
// }
// graphics.clear();
// graphics.beginFill(solidColor.color);
// graphics.drawCircle(width/2, height/2, 4);
// graphics.endFill();
// }
// }