【发布时间】:2020-07-29 16:24:40
【问题描述】:
我已经在amchartsplugin 中实现了一个地图,并在我有服务器的位置绘制了圆圈。
我想根据业务需求根据可用性Green、Yellow 和Red 在服务器上显示不同的颜色。我已经在首选位置实现了圈子,并且我能够仅分配一个color。
这是我的代码
public ServerMap()
{
this.mapChart = am4core.create("chartdiv", am4maps.MapChart);
this.mapChart .geodata = am4geodata_worldLow;
//Set projection
this.mapChart .projection = new am4maps.projections.Miller();
//Create map polygon series
this.polygonSeries = this.mapChart .series.push(new am4maps.MapPolygonSeries());
this.polygonSeries.exclude = ["AQ"];
this.polygonSeries.useGeodata = true;
this.polygonSeries.nonScalingStroke = true;
this.polygonSeries.calculateVisualCenter = true;
let imageSeries = this.mapChart .series.push(new am4maps.MapImageSeries());
imageSeries.dataFields.value = "value";
var place = imageSeries.mapImages.template;
place.nonScaling = true;
place.propertyFields.latitude = "latitude";
place.propertyFields.longitude = "longitude";
imageSeries.data=
[
{
"latitude": 17.3850,
"longitude": 78.4867,
"name": "Miam",
"value": 123,
},
{
"latitude":49.619446,
"longitude": -128.695623,
"name": "Washingto DC",
"value": 123,
},
{
"latitude": 41.8278767,
"longitude": -87.9986114,
"name": "Chicago",
"value": 123,
}
]
//Here creating circle
var circle = place.createChild(am4core.Circle);
circle.radius = 12;
circle.fill = am4core.color("#e33");
circle.strokeWidth = 1;
circle.fillOpacity = 0.7;
circle.propertyFields.fill = "color";
circle.tooltipText = "{name}: [bold]{value}[/]";
imageSeries.heatRules.push({
"target": circle,
"property": "radius",
"min": 6,
"max": 15,
"dataField": "value",
})
}
如何根据条件在圆圈上设置单独的颜色?
这是我的输出屏幕
【问题讨论】:
标签: javascript angular typescript amcharts