我想将 amcharts 中相同列的颜色更改为第一个绿色为红色,第二个为绿色作为账单。系列图表定义堆叠列的颜色,但同一列的颜色不同 [demo] ( https://jsfiddle.net/rfgwaohp/ ) 在这里
am4core.ready(function() {
am4core.useTheme(am4themes_animated);
am4core.useTheme(am4themes_kelly);
// Create chart instance
var chart = am4core.create("chartdiv", am4charts.XYChart);
chart.marginRight = 400;
// Add data
chart.data = [{
"retailer": "Current",
"bill": 120,
"saving": null
}, {
"retailer": "New",
"bill": -90,
"saving": 219
}];
var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = "retailer";
categoryAxis.title.text = "";
categoryAxis.renderer.grid.template.location = 0;
categoryAxis.renderer.minGridDistance = 20;
categoryAxis.renderer.labels.template.disabled = true;
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.title.text = "";
// Create series
var series = chart.series.push(new am4charts.ColumnSeries());
series.dataFields.valueY = "bill";
series.dataFields.categoryX = "retailer";
series.name = "Bill";
series.fill = "#00af50";
series.stroke = "#00af50";
series.color = "#f2f2f2";
series.tooltipText = "{name}: [bold]{valueY}[/]";
series.stacked = true;
var series2 = chart.series.push(new am4charts.ColumnSeries());
series2.dataFields.valueY = "saving";
series2.dataFields.categoryX = "retailer";
series2.name = "Saving";
series2.fill = "#f2f2f2";
series2.stroke = "#f2f2f2";
series2.color = "#00af50";
series2.tooltipText = "{name}: [bold]{valueY}[/]";
series2.stacked = true;
chart.cursor = new am4charts.XYCursor();
});