简体   繁体   English

Amcharts:为雷达柱系列的项目着色

[英]Amcharts: Colorize the items of a Radar Column Series

I would like to create a radar chart with Amcharts.我想用 Amcharts 创建一个雷达图。 The value "value" should be displayed as a RadarColumnSeries.值“值”应显示为 RadarColumnSeries。 But the elements should have an individual color.但是元素应该有一个单独的颜色。 I tried to set the colors by setting the configField = "config" and add the color value to the data set.我尝试通过设置 configField = "config" 来设置 colors 并将颜色值添加到数据集中。 But the color of all elements stays the same.但是所有元素的颜色保持不变。 Any idea?任何想法?

The code: http://jsfiddle.net/lefrank/1kft0sd3/3代码: http://jsfiddle.net/lefrank/1kft0sd3/3

or:或者:

<style>
#chartdiv {
  width: 100%;
  height: 600px;
}
</style>

<!-- Resources -->
<script src="amcharts/core.js"></script>
<script src="amcharts/charts.js"></script>
<script src="amcharts/themes/animated.js"></script>

<!-- Chart code -->
<script>
am4core.ready(function() {

// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end

var radarChart = am4core.create("chartdiv", am4charts.RadarChart);

radarChart.data= [
{"element":"One","value": 68,"config": {"fill": "#fff000" }},
{"element":"Two","value": 58,"config": {"fill": "#fff000" }},
{"element":"Three","value": 88,"config": {"fill": "#fff000" }}
];

var categoryAxis = radarChart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = "element";

var radarValueAxis = radarChart.yAxes.push(new am4charts.ValueAxis());
radarValueAxis.renderer.axisFills.template.fill = "#ff0000";
radarValueAxis.renderer.axisFills.template.fillOpacity = 0.05;
radarValueAxis.min = 0;
radarValueAxis.max = 100;

var radarSeries = radarChart.series.push(new am4charts.RadarColumnSeries());
radarSeries.columns.template.tooltipText = "{name}: {valueY.value}";
radarSeries.name = "Value";
radarSeries.dataFields.categoryX = "element";
radarSeries.dataFields.valueY = "value";
radarSeries.columns.template.configField = "config";

}); // end am4core.ready()
</script>

<!-- HTML -->
<div id="chartdiv"></div>

Okay, I got it:好的,我明白了:

radarSeries1.columns.template.radarColumn.configField = 'config'; radarSeries1.columns.template.radarColumn.configField = 'config';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM