Created
January 31, 2013 04:18
-
-
Save tripp/4680116 to your computer and use it in GitHub Desktop.
changedatatwonumericaxeschart.js
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
| var myDataValues = [ | |
| {Iter:1, Generation:0, fitness:1.0542625639857393}, | |
| {Iter:1, Generation:1, fitness:0.4268963274830605}, | |
| {Iter:1, Generation:34, fitness:0.36754170974222156}, | |
| {Iter:2, Generation:0, fitness:1.483161509937983}, | |
| {Iter:2, Generation:1, fitness:0.20846076233482433}, | |
| {Iter:3, Generation:0, fitness:0.42917710631074113}, | |
| {Iter:3, Generation:19, fitness:0.3964440041134349}, | |
| {Iter:3, Generation:20, fitness:0.15911543465202604}, | |
| {Iter:3, Generation:94, fitness:0.12314257358831804}, | |
| {Iter:4, Generation:0, fitness:0.967793094170507}, | |
| {Iter:4, Generation:5, fitness:0.48447508490110447}, | |
| {Iter:4, Generation:34, fitness:0.4418438425146394}, | |
| {Iter:4, Generation:45, fitness:0.29179020030263647}, | |
| {Iter:4, Generation:73, fitness:0.2237908794115498}, | |
| {Iter:4, Generation:89, fitness:0.1579225476861018}, | |
| {Iter:5, Generation:0, fitness:0.28887972079126484}, | |
| {Iter:5, Generation:82, fitness:0.25847128335970443}, | |
| {Iter:6, Generation:0, fitness:1.0869877453329528}, | |
| {Iter:6, Generation:1, fitness:0.7740600070740621}, | |
| {Iter:6, Generation:6, fitness:0.7738215842650702}, | |
| {Iter:6, Generation:7, fitness:0.23616244129261307}, | |
| {Iter:7, Generation:0, fitness:0.8602128279896258}, | |
| {Iter:7, Generation:1, fitness:0.7730099153854231}, | |
| {Iter:7, Generation:6, fitness:0.7411925274500096}, | |
| {Iter:7, Generation:11, fitness:0.5071981432165317}, | |
| {Iter:7, Generation:55, fitness:0.3699673164428877}, | |
| {Iter:7, Generation:63, fitness:0.27371196105506684}, | |
| {Iter:8, Generation:0, fitness:0.6619490234510628}, | |
| {Iter:8, Generation:10, fitness:0.5566417369133086}, | |
| {Iter:8, Generation:29, fitness:0.3688071264841243}, | |
| {Iter:8, Generation:66, fitness:0.3507460712134937}, | |
| {Iter:9, Generation:0, fitness:1.1685593822610905}, | |
| {Iter:9, Generation:2, fitness:0.39363842314586467}, | |
| {Iter:9, Generation:34, fitness:0.14442426513415274}, | |
| {Iter:10, Generation:0, fitness:0.693064777578449}, | |
| {Iter:10, Generation:9, fitness:0.4481513332187379}, | |
| {Iter:10, Generation:32, fitness:0.4251936828848534}, | |
| {Iter:10, Generation:55, fitness:0.29648342730240984} | |
| ], | |
| i, | |
| len = myDataValues.length, | |
| myDataProvider = [], | |
| item, | |
| newItem, | |
| mychart, | |
| seriesCollection = [], | |
| xKey, | |
| yKey, | |
| yKeys = []; | |
| //build new dataProvider with multiple keys | |
| for(i = 0; i < len; i = i + 1) { | |
| item = myDataValues[i]; | |
| newItem = {}; | |
| yKey = "fitness" + item.Iter; | |
| newItem.Generation = item.Generation; | |
| newItem[yKey] = item.fitness; | |
| myDataProvider.push(newItem); | |
| //create a seriesCollection so we can style the line weights | |
| if(Y.Array.indexOf(yKeys, yKey) < 0) { | |
| yKeys.push(yKey); | |
| seriesCollection.push({ | |
| type: "line", | |
| yKey: yKey, | |
| xKey: "Generation", | |
| styles: { | |
| weight: 1 | |
| } | |
| }); | |
| } | |
| } | |
| var mychart = new Y.Chart({ | |
| dataProvider:myDataProvider, | |
| seriesCollection: seriesCollection, | |
| categoryType: "numeric", | |
| categoryKey: "Generation", | |
| seriesKeys: yKeys, | |
| render:"#mychart" | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment