1
フレックスチャートのスタイルを値に応じて変更する方法はありますか? たとえば、縦棒グラフでは、正の値は緑、負の値は赤を設定しますか?フレックスチャート:正と負の値のスタイルを変更する
フレックスチャートのスタイルを値に応じて変更する方法はありますか? たとえば、縦棒グラフでは、正の値は緑、負の値は赤を設定しますか?フレックスチャート:正と負の値のスタイルを変更する
ColumnSeriesに、指定された列の値に基づいてIFillを調整するために使用されるfillFunctionプロパティを与える必要があります。次のようなものがあります。
<?xml version="1.0"?>
<!-- Simple example to demonstrate the ColumnChart and BarChart controls. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.charts.ChartItem;
import mx.graphics.IFill;
import mx.collections.ArrayCollection;
private function fillFunction (item:ChartItem, index:Number):IFill
{
if(item.item.Gold > 0)
{
return new SolidColor(0x00FF00);
} else {
return new SolidColor(0xFF0000);
}
}
[Bindable]
private var medalsAC:ArrayCollection = new ArrayCollection([
{ Country: "USA", Gold: 35},
{ Country: "China", Gold: -5},
{ Country: "Russia", Gold: 27} ]);
]]>
</mx:Script>
<!-- Define custom colors for use as fills. -->
<mx:SolidColor id="sc1" color="yellow" alpha=".8"/>
<!-- Define custom Strokes for the columns. -->
<mx:Stroke id="s1" color="yellow" weight="2"/>
<mx:Panel title="ColumnChart and BarChart Controls Example"
height="100%" width="100%" layout="horizontal">
<mx:ColumnChart id="column"
height="100%"
width="100%"
paddingLeft="5"
paddingRight="5"
showDataTips="true"
dataProvider="{medalsAC}"
>
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Country"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries
xField="Country"
yField="Gold"
displayName="Gold"
fill="{sc1}"
stroke="{s1}"
fillFunction="{fillFunction}"
/>
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{column}"/>
</mx:Panel>
</mx:Application>
10の質問と1つの受け入れられた回答ではありません。クールではありません。 – grapefrukt