高图表数组格式

时间:2018-11-17 16:40:12

标签: javascript jquery arrays foreach

我有一个数组,其输出如下。必须创建一个新的键值对

var obj = [
{
Title: "North America",
Value: 66457682.57055664,
Year: [
{Value: 11061419.089111328, Year: 2017},
{Value: 11039525.639892578, Year: 2018},
{Value: 11040422.410644531, Year: 2019}
]},
{Title: "USA",
Value: 66457682.57055664,
Year: [
{Value: 11454419.089111328, Year: 2017},
{Value: 11456.639892578, Year: 2018},
{Value: 11056562.410644531, Year: 2019}
]}]

如何在jQuery中以这种格式获取数组?

var year = [2017,2018,2019];

var data = [
{

name:North America
data:[11061419.089111328,11039525.639892578,11056562.410644531]
},
{
name:USA
data:[11061419.034328,13439525.6343478,1167672.4106761]
}]

1 个答案:

答案 0 :(得分:0)

您可以使用map转换数组(无需jQuery)。

[name: string]: any;