Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have 3 separate array's that i want to convert to one 2-dimensional array so i can use it for D3.js

Example of the arrays that i have:

var data1 = [ 0.10, 0.09, 0.08, 0.07, 0.06, ... ]; // series 1
var data2 = [ 0.10, 0.09, 0.08, 0.07, 0.06, ... ]; // series 2
var data3 = [ 0.10, 0.09, 0.08, 0.07, 0.06, ... ]; // series 3

What i want:

var data = [
              [ 0.10, 0.09, 0.08, 0.07, 0.06, ... ], // series 1
              [ 0.10, 0.09, 0.08, 0.07, 0.06, ... ], // series 2
              [ 0.10, 0.09, 0.08, 0.07, 0.06, ... ]  // series 3
            ];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
163 views
Welcome To Ask or Share your Answers For Others

1 Answer

Anything wrong with just doing this?

data = [data1, data2, data3]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...