如何在PieChart图表中填充自己的颜色
程序员文章站
2022-04-30 09:59:41
...
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.charts.series.items.PieSeriesItem;
import mx.graphics.IFill;
import mx.charts.ChartItem;
import mx.graphics.SolidColor;
private function pieSeries_fillFunc(item:ChartItem, index:Number):IFill {
var curItem:PieSeriesItem = PieSeriesItem(item);
/* Convert to a number between 0 and 1. */
var pct:Number = curItem.percentValue / 100;
return new SolidColor(0x0000FF * pct, 1.0);
}
]]>
</mx:Script>
<mx:XML id="dp">
<products>
<product label="Product 1" data="3" />
<product label="Product 2" data="1" />
<product label="Product 3" data="4" />
<product label="Product 4" data="1" />
<product label="Product 5" data="5" />
<product label="Product 6" data="9" />
</products>
</mx:XML>
<mx:PieChart id="chart"
height="100%"
width="100%"
showDataTips="true"
dataProvider="{dp.product}">
<mx:series>
<mx:PieSeries id="series"
nameField="@label"
field="@data"
fillFunction="pieSeries_fillFunc"
filters="[]" />
</mx:series>
</mx:PieChart>
</mx:Application>
上一篇: 图论之最短路1(Floyd和Dijkstra算法)
下一篇: 接入京东云