我们如何格式化以下json格式,以转换成Highchart使用的必需格式。需要将层次结构json转换为具有适当过滤器值(类别)的平面json。系列值用于显示主条(类别)内的子条图 请参考下面的链接,我正试图从下面的json中获取。
https://www.highcharts.com/demo/column-basic
要转换的Json(可用):
{
"SalesValue": {
"barValue":[{
"type" :"Maruti",
"Drills": [
{"region":"Asia", "value":4},
{"region":"Australia", "value":87},
{"region":"America", "value":12}
]
},{
"type" :"Hyundai",
"Drills": [
{"region":"Asia", "value":33},
{"region":"Australia", "value":5}
]
},{
"type" :"Toyota",
"Drills": [
{"region":"America", "value":33}
]
}]
}
}
所需的Json(待定):
{
"Chart Value": {
"Categories":[{
"name" :["Maruti","Hyundai","Toyota"]
}],
"Series":[{
"name":"Asia",
"data":[4,33]
},{
"name":"Australia",
"data":[87, 5]
},{
"name":"America",
"data":[12 , 33]
}]
}
}