FusionCharts "stackedcolumn2d"チャートを使用して上記で提供されたフィドルは、データプロットの色を設定するために使用される個々のデータオブジェクトに定義された "color"属性を持っています。
各凡例は、それぞれのデータセットシリーズを表します。シリーズに設定されている色は、そのシリーズの凡例に反映されます。このためには、データセットレベルで「カラー」属性を設定する必要があります。
注意:凡例は、個々のデータプロットを表すことはできません。
ここでフィドルを参照してください:http://jsfiddle.net/Akash008/dty7dfzk/4/
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'stackedcolumn2d',
renderAt: 'chart-container',
width: '500',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Revenue split by product category",
"subCaption": "For current year",
"xAxisname": "Quarter",
"yAxisName": "Revenues (In USD)",
//"paletteColors": "#FF0000,#00FF00,#0000FF,#FFFF00",
"showSum": "1",
"numberPrefix": "$",
"showLegend": "1",
"theme": "fint",
"legendPosition": "right",
"legendCaption": "food Items",
"legendScrollBgColor": "#cccccc",
"legendScrollBarColor": "#999999",
"plotHighlightEffect": "fadeout",
},
"categories": [{
"category": [{
"label": "Non-dairy Product"
}, {
"label": "Vegetables"
}, {
"label": "Fruits"
}, {
"label": "Vegetables"
}]
}],
"dataset": [{
"seriesname": "Food Products",
"color": "#FF0000",
"data": [{
"toolText": "Egg",
"value": "11000"
}, {
"toolText": "Potato",
"value": "15000"
}, {
"toolText": "Apple",
"value": "13500"
}, {
"toolText": "lettuce",
"value": "15000"
}]
}, {
"seriesname": "Non-Food Products",
"color": "#00FF00",
"data": [{
"toolText": "Meat",
"value": "11400"
}, {
"toolText": "Eggplant",
"value": "14800"
}, {
"toolText": "Oranges",
"value": "8300"
}, {
"toolText": "cilantro",
"value": "11800"
}]
}, {
"seriesname": "Non-Food Products",
"color": "#0000FF",
"data": [{
"toolText": "Fish",
"value": "11400"
}, {
"toolText": "Carrot",
"value": "14800"
}, {
"toolText": "plums",
"value": "8300"
}, {
"toolText": "Kale",
"value": "11800"
}]
}, {
"seriesname": "Non-Food Products",
"color": "#FFFF00",
"data": [{
"toolText": "Fish",
"value": "11400"
}, {
"toolText": "Carrot",
"value": "14800"
}, {
"toolText": "plums",
"value": "8300"
}, {
"toolText": "Kale",
"value": "11800"
}]
}],
}
})
revenueChart.render();
});
また、一度に全てのシリーズに色を設定するチャートレベル属性「paletteColors」を設定することで、同じことを達成することができます。フィドルを参照してください:http://jsfiddle.net/Akash008/dty7dfzk/3/
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'stackedcolumn2d',
renderAt: 'chart-container',
width: '500',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Revenue split by product category",
"subCaption": "For current year",
"xAxisname": "Quarter",
"yAxisName": "Revenues (In USD)",
"paletteColors": "#FF0000,#00FF00,#0000FF,#FFFF00",
"showSum": "1",
"numberPrefix": "$",
"showLegend": "1",
"theme": "fint",
"legendPosition": "right",
"legendCaption": "food Items",
"legendScrollBgColor": "#cccccc",
"legendScrollBarColor": "#999999",
"plotHighlightEffect": "fadeout",
},
"categories": [{
"category": [{
"label": "Non-dairy Product"
}, {
"label": "Vegetables"
}, {
"label": "Fruits"
}, {
"label": "Vegetables"
}]
}],
"dataset": [{
"seriesname": "Food Products",
"data": [{
"toolText": "Egg",
"value": "11000"
}, {
"toolText": "Potato",
"value": "15000"
}, {
"toolText": "Apple",
"value": "13500"
}, {
"toolText": "lettuce",
"value": "15000"
}]
}, {
"seriesname": "Non-Food Products",
"data": [{
"toolText": "Meat",
"value": "11400"
}, {
"toolText": "Eggplant",
"value": "14800"
}, {
"toolText": "Oranges",
"value": "8300"
}, {
"toolText": "cilantro",
"value": "11800"
}]
}, {
"seriesname": "Non-Food Products",
"data": [{
"toolText": "Fish",
"value": "11400"
}, {
"toolText": "Carrot",
"value": "14800"
}, {
"toolText": "plums",
"value": "8300"
}, {
"toolText": "Kale",
"value": "11800"
}]
}, {
"seriesname": "Non-Food Products",
"data": [{
"toolText": "Fish",
"value": "11400"
}, {
"toolText": "Carrot",
"value": "14800"
}, {
"toolText": "plums",
"value": "8300"
}, {
"toolText": "Kale",
"value": "11800"
}]
}],
}
})
revenueChart.render();
});
これが役に立ちます。
答えに感謝します。 – user5249203