我正在尝试使用highcharts-chart
指令在Highmaps中部署美国县映射。这与美国国家映射效果很好,但是在我遇到汇编错误的情况下为美国县定义数据元素时遇到问题。
这是尝试:
html
<highcharts-chart
[Highcharts]="Highcharts"
[constructorType]="'mapChart'"
[options]="chartMap"
[(update)]="updateFlag"
[oneToOne]="true"
style="width: 500px; height: 400px; display: block;"
></highcharts-chart>
打字稿
import * as Highcharts from 'highcharts';
import MapModule from 'highcharts/modules/map';
const mapX = require('@highcharts/map-collection/countries/us/us-all-all.geo.json')
MapModule(Highcharts);
.....
.....
this.chartMap = {
chart: {
map: mapX
},
title: {
text: 'THIS IS THE US COUNTIES MAP'
},
series: [{ // <-- error is thrown here
name: 'Unemployment',
borderWidth: 0.5,
states: {
hover: {
color: 'red'
}
},
joinBy: ['hc-key', 'code'],
data: [
{
"code": "us-al-001",
"name": "Autauga County, AL",
"value": 3.9
},
{
"code": "us-al-003",
"name": "Baldwin County, AL",
"value": 4.3
}
]
}]
};
我收到以下汇编错误:
类型'{name:string;borderwidth:数字;状态:{悬停:{颜色: 细绳;};};JOINBY:string [];数据:{"代码":String;"姓名": 细绳;" value":数字;} [];}'不能分配给类型 'seriesabandsoptions |系列adoptions |系列AOPTIONS | 系列操作|系列方面|系列areArgeOptions | 系列AreasplineOptions |系列AreasPlinerAngeOptions |... 82 ... |系列。类型中缺少属性"类型" { 名称:字符串;borderwidth:数字;状态:{悬停:{颜色:string; };};JOINBY:string [];数据:{"代码":String;"名称":字符串; " value":数字;} [];}',但在类型中需要 'seriesxrangeoptions'.ts(2322(HighCharts.d.ts(335083,5(:"类型"是 在这里声明。
我从此处和地图示例中获取了数据示例。
这个错误是什么以及如何修复?
发生此错误是因为您没有设置使用Typescript时每个系列所需的系列type
。
series: [{
name: 'Unemployment',
type: 'map', // type is required for each series
borderWidth: 0.5,
states: {
hover: {
color: 'red'
}
},
joinBy: ['hc-key', 'code'],
data: [{
"code": "us-al-001",
"name": "Autauga County, AL",
"value": 3.9
},
{
"code": "us-al-003",
"name": "Baldwin County, AL",
"value": 4.3
}
]
}]
有关此问题的更多信息:
- 如何修复类型中缺少"类型"的属性"类型",但类型为"系列XrangeOptions"中需要在Angular Highcharts模块
- https://github.com/highcharts/highcharts/issues/9867