ColorList は、円グラフ、ピラミッドグラフ、面グラフ、横棒グラフ、円錐グラフ、円柱グラフ、またはステップグラフでのみ機能します。cfchartシリーズ。
2 つの異なる方法で、各列に特定の色を作成できます。ルールまたはスタイルのリストを介して。
プロット属性に追加されるルールを作成できます。そのルールに適用される色を指定します。以下の例は、x 軸の値が true の場合のルールを示しています。
<cfset plot= {"rules": [
{"rule":"'%k'=='2007'",
"background-color":"purple"},
{"rule":"'%k'=='2008'",
"background-color":"pink"},
{"rule":"'%k'=='2009'",
"background-color":"green"}]}
>
または、プロットの styles 属性を使用して、グラフのスタイルのリストを作成できます。
<cfset plot = {"styles":[
{
"background-color":"##e95d22"
},
{
"background-color":"##017890"
},
{
"background-color":"##da534d"
},
{
"background-color":"##4a266d"
},
{
"background-color":"##f4913c"
}]}>
次のように、グラフ要素にプロット変数を含めます。
<cfchart format="png" chartheight="180" chartwidth="233" showlegend="false" style="test.js" plot="#plot#">
<cfchartseries type="bar">
<cfchartdata item="2005" value="1000"/>
<cfchartdata item="2006" value="3000"/>
<cfchartdata item="2007" value="1000"/>
<cfchartdata item="2008" value="4000"/>
<cfchartdata item="2009" value="2000"/>
</cfchartseries>
私の例を支援するために、ここに私のtest.jsがあります
{
"graphset":[
{
"border-width":1,
"background-color":"transparent",
"plotarea":{"margin":"dynamic"}
}]
}
これらの手法はどちらも test.js ファイルに直接含めることができますが、これらの色を動的にするには、plot 属性を介して入力する方が簡単です。