Jquery – required help in array function

I have an array like this.

[{"label":"2013-12-01","value":"2372"},{"label":"2014-01-01","value":"2458"},{"label":"2014-02-01","value":"1636"},{"label":"2014-03-01","value":"2527"},{"label":"2014-04-01","value":"2129"},{"label":"2014-05-01","value":"149"}]

I’m creating a line chart using highcharts
.

Data excepted format for line chart is

[["2013-12-01",2372],["2014-01-01",2458],["2014-02-01",1636],["2014-03-01",2527],["2014-04-01",2129],["2014-05-01",149]]

I got no idea on how to do it.

Actually the result is from a ajax result.

I get the result in Object Object
and I converted it using JSON.stringify
. But after converting I get both label and value.

Someone help me out to get the data in the chart expected format.

Thanks in advance.

You can map the current array and return each label inside it into a new array etc

var new_arr = $.map(arr, function(itm) { return [itm.label, itm.value]; });
Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Jquery – required help in array function

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录