//实现彩虹柱子
private function myFillFunction(element:ChartItem, index:Number):IFill
{
//四色柱子
var c:SolidColor = new SolidColor(0x00CC00);
var temp:int = index%4;
if(0 == temp)
{
c.color = 0xEE716A;
}
else if(1 == temp)
{
c.color = 0xFEE05F;
}
else if(2 == temp)
{
c.color = 0x90CE99;
}
else
{
c.color = 0x0983D3;
}
//简单的按值显示颜色
/*var item:ColumnSeriesItem = ColumnSeriesItem(element);
var profit:Number = Number(item.yValue);
if (profit >= 2) {
return c;
} else {
c.color = 0xFF0000;
}
return c;*/
}
[Bindable]
private var clickGroup:String = "";
//图形点击事件
private function columnseries2_clickHandler(event:ChartItemEvent):void
{
var temp:String=event.hitData.item.year;//横坐标
clickGroup = temp;//赋值给变量
var psi:ColumnSeriesItem= event.hitData.chartItem as ColumnSeriesItem;
if(null != psi)
{
changefunction(psi);
}
}
//改变单个柱子颜色,点击的柱子变成红色
private function changefunction(psi:ColumnSeriesItem):void
{
if(psi != null)
{
if (psi.item["year"]==clickGroup)
{
line2.setStyle("fill",new SolidColor(0xEE5B58, 1));//line2为ColumnSeries的id,将点击柱子颜色改变
line2.validateNow();
}
else
{
line2.setStyle("fill",new SolidColor(0x4197FF));//柱子原来的颜色
line2.validateNow();
}
}
}
//必须使用fillfunction,不然所有line2的柱子都变红了
private function fillfunction2(item:ChartItem, index:Number):IFill
{
var psi:ColumnSeriesItem = ColumnSeriesItem(item);
if (psi.item["year"] == clickGroup)
{
return (new SolidColor(0xEE5B58, 1)); //红色
}
return (new SolidColor(0x4197FF));//蓝色
}
flex -设置柱状图ColumnChart的彩虹柱子、点击单个柱子高亮显示(三)
最新推荐文章于 2018-03-05 18:26:17 发布