Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

Make a 2 dimensional array with javascript or D3.js

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

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

1 Reply

0 votes
by (71.8m points)

Anything wrong with just doing this?

data = [data1, data2, data3]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...