Last active
August 29, 2015 14:23
-
-
Save tarzak/de033ef90ea7f51407e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Input Data Structure: | |
| [ | |
| { | |
| _id: "id", | |
| date: "1-May-12", | |
| close: 68.13, | |
| open: 34.12 | |
| }, | |
| ... | |
| ] | |
| */ | |
| var arr = ['close', 'open']; | |
| var parsedArr = []; | |
| for (var i = 0; i < arr.length; i += 1) { | |
| if (!parsedArr[i]) { | |
| parsedArr[i] = []; | |
| } | |
| parsedArr[i] = data.map( | |
| function (d) { | |
| return { value: d[arr[i]], date: d.date } | |
| } | |
| ); | |
| } | |
| /* | |
| Needed output Data structure: | |
| [ | |
| [{date: "date", value: "value"}, ...], | |
| [{date: "date", value: "value"}, ...] | |
| ] | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment