Highcharts系列数据不起作用

时间:2017-04-11 17:47:25

标签: json ecmascript-6 underscore.js lodash

我现有的数组如下:

"Issues": [{
    "Id": null,
    "Key": null,
    "Values": [{
        "Key": "Display Name",
        "Value": "Rya"
    }, {
        "Key": "UserName",
        "Value": "RH"
    }, {
        "Key": "Count",
        "Value": "350"
    }]
}, {
    "Id": null,
    "Key": null,
    "Values": [{
        "Key": "Display Name",
        "Value": "Mike"
    }, {
        "Key": "UserName",
        "Value": "ML"
    }, {
        "Key": "Count",
        "Value": "90"
    }]
}]

我想要的阵列:

[{
    name: 'Rya', 
    value: 350
}, {
    name: 'Mike', 
    value: 90
}]

我尝试了什么:

Data.Issues.map(o=> o.Values.reduce((acc, {Key, Value}) =>
                                       (acc[Key] = Value, acc), {}));

this.donughtChartData1 = this.donughtChartData.map( ({UserName, Count}) => 
    ({ name: UserName, value: Count}) );

但是这给了我:

[{
    "name": "RHanney",
    "value": "350"
}, { 
    "name": "MLuckenbill", 
    "value": "90"
}]

这有引号,如果有引号,我的highcharts不起作用。

1 个答案:

答案 0 :(得分:1)

在代码的最后一行,在for (byte i = 0; i < 255; i++) { var bytes = new byte[] { 0x1C, 0x70, i, 0x00 }; port.Write(bytes, 0, 4); } 之前添加+,以便将其转换为数字:

Count

如何添加一个字符可以带来解决方案: - )