如何根据对象内的数组拆分对象数组?

时间:2017-03-17 14:32:54

标签: javascript jquery highcharts

对象数组是:

[{seriesObject:{data:[a1,a2,a3,... a1000]}}]

我希望将其转换为10个不同的数组对象

[{seriesObject:{data:[a1,a2,a3,.... a1000]}] //第一块

[{seriesObject:{data:[a1,a2,a3,.... a1000]}] //第二块

[{seriesObject:{data:[a1,a2,a3,... a1000]}] // ...

[{seriesObject:{data:[a1,a2,a3,... a1000]}] //第10块

2 个答案:

答案 0 :(得分:1)

我认为对象就像这样{data:[a0,a1,...,a9999]}。



function partition (obj, n) {
  var count = obj.data.length, len = count/n;
  var arr = [];
  for(var k = 0; k < count; ) {
    var new_obj = {"data":[]};
    for (var j = 0 ; k < count && j < len; ++j, ++k) {
      new_obj.data.push(obj.data[k]);
    }
    arr.push(new_obj);
  }
  return arr;
}

var o = {"data":[]};
for(var k = 0; k < 10000; ++k) {
  o.data.push(k);
}

console.log( partition(o, 10) );
&#13;
&#13;
&#13;

答案 1 :(得分:0)

这应该是你想要的:

Sub YesNoChkBox()
    Dim ChkBx As CheckBox, g As Integer, h As Integer, r As Integer
    Set ChkBx = ActiveSheet.CheckBoxes(Application.Caller)

    With ChkBx.TopLeftCell
      r = .Row
      g = .Column + 2
      h = .Column + 3
    End With

    If ChkBx = 1 Then
        gr = "NO"
        hr = "NO"
    Else
        gr = "YES"
        hr = ""
    End If
End Sub

- 编辑1:

这是你在找什么?

http://jsfiddle.net/fqqz8vjc/3/