{"id":0,"registry":{"0":{"shape":{"__isSmartRef__":true,"id":1},"submorphs":[],"scripts":[],"_ClipMode":"visible","derivationIds":["AB2CD9B1-B8A7-488A-8677-EF55AEBC35C7","E6003058-4623-47B9-84B3-2455E1235474","9668B417-0690-4B52-8E2F-8024C3EEF8DD","4C3FF1EC-50D7-4DF3-A0F8-6D00BEE5165A","32706919-245A-4590-89B6-052705777489","95CE4CEF-72FA-4233-8114-4D9556348D23","98613FA1-7CFE-48F0-A94D-849552531CB0"],"id":"626010A4-5265-4D87-A1E7-9DBA89D6278A","__layered_droppingEnabled__":true,"halosEnabled":true,"_StyleClassNames":["Morph","HtmlWrapperMorph","selectable"],"name":"StreamingD3","eventHandler":{"__isSmartRef__":true,"id":2},"layout":{"__isSmartRef__":true,"id":3},"showsHalos":false,"isBeingDragged":false,"prevScroll":[0,0],"_StyleSheet":{"__isSmartRef__":true,"id":4},"canvasId":"d3-626010A452654D87A1E79DBA89D6278A","partsBinMetaInfo":{"__isSmartRef__":true,"id":25},"data":[],"__serializedExpressions__":["_Position","distanceToDragEvent"],"_Rotation":0,"_Scale":1,"__serializedLivelyClosures__":{"__isSmartRef__":true,"id":33},"__LivelyClassName__":"lively.morphic.HtmlWrapperMorph","__SourceModuleName__":"Global.lively.morphic.AdditionalMorphs","_Position":"lively.pt(0.0,0.0)","distanceToDragEvent":"lively.pt(151.0,-20.0)"},"1":{"_BorderWidth":0,"stringifiedShapeNode":"<div xmlns=\"http://www.w3.org/1999/xhtml\" data-lively-morphid=\"626010A4-5265-4D87-A1E7-9DBA89D6278A\" class=\"Morph HtmlWrapperMorph selectable\" id=\"null\" style=\"overflow: visible; border: 0px solid rgb(95, 94, 95); padding: 0px; width: 534px; height: 409px; position: absolute; left: 0px; top: 0px; background-color: rgb(255, 255, 255);\"><div id=\"d3-626010A452654D87A1E79DBA89D6278A\"></div></div>","__serializedExpressions__":["_Padding","_BorderColor","_Fill","_Position","_Extent","extent"],"__LivelyClassName__":"lively.morphic.Shapes.External","__SourceModuleName__":"Global.lively.morphic.Shapes","_Padding":"lively.rect(0,0,0,0)","_BorderColor":"Color.rgb(95,94,95)","_Fill":"Color.rgb(255,255,255)","_Position":"lively.pt(0.0,0.0)","_Extent":"lively.pt(534.0,409.0)","extent":"lively.pt(534.0,409.0)"},"2":{"morph":{"__isSmartRef__":true,"id":0},"__LivelyClassName__":"lively.morphic.EventHandler","__SourceModuleName__":"Global.lively.morphic.Events"},"3":{"resizeWidth":true,"resizeHeight":true},"4":{"rules":[{"__isSmartRef__":true,"id":5},{"__isSmartRef__":true,"id":8},{"__isSmartRef__":true,"id":12},{"__isSmartRef__":true,"id":14},{"__isSmartRef__":true,"id":18},{"__isSmartRef__":true,"id":20},{"__isSmartRef__":true,"id":22}],"originMorph":{"__isSmartRef__":true,"id":0},"__LivelyClassName__":"lively.morphic.StyleSheet","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"5":{"declarations":[{"__isSmartRef__":true,"id":6},{"__isSmartRef__":true,"id":7}],"styleSheet":{"__isSmartRef__":true,"id":4},"selector":".Morph","__LivelyClassName__":"lively.morphic.StyleSheetRule","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"6":{"values":["10px","sans-serif"],"rule":{"__isSmartRef__":true,"id":5},"property":"font","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"7":{"values":["0"],"rule":{"__isSmartRef__":true,"id":5},"property":"margin","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"8":{"declarations":[{"__isSmartRef__":true,"id":9},{"__isSmartRef__":true,"id":10},{"__isSmartRef__":true,"id":11}],"styleSheet":{"__isSmartRef__":true,"id":4},"selector":".Morph path.line","__LivelyClassName__":"lively.morphic.StyleSheetRule","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"9":{"values":["none"],"rule":{"__isSmartRef__":true,"id":8},"property":"fill","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"10":{"values":["#666"],"rule":{"__isSmartRef__":true,"id":8},"property":"stroke","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"11":{"values":["1.5px"],"rule":{"__isSmartRef__":true,"id":8},"property":"stroke-width","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"12":{"declarations":[{"__isSmartRef__":true,"id":13}],"styleSheet":{"__isSmartRef__":true,"id":4},"selector":".Morph .axis","__LivelyClassName__":"lively.morphic.StyleSheetRule","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"13":{"values":["crispEdges"],"rule":{"__isSmartRef__":true,"id":12},"property":"shape-rendering","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"14":{"declarations":[{"__isSmartRef__":true,"id":15},{"__isSmartRef__":true,"id":16},{"__isSmartRef__":true,"id":17}],"styleSheet":{"__isSmartRef__":true,"id":4},"selector":".Morph .x.axis line","__LivelyClassName__":"lively.morphic.StyleSheetRule","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"15":{"values":["#fff"],"rule":{"__isSmartRef__":true,"id":14},"property":"stroke","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"16":{"comment":"/*stroke: #000;*/","values":[""],"rule":{"__isSmartRef__":true,"id":14},"property":"","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetInlineComment","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"17":{"comment":"/*fill: none;*/","values":[""],"rule":{"__isSmartRef__":true,"id":14},"property":"","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetInlineComment","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"18":{"declarations":[{"__isSmartRef__":true,"id":19}],"styleSheet":{"__isSmartRef__":true,"id":4},"selector":".Morph .x.axis .minor","__LivelyClassName__":"lively.morphic.StyleSheetRule","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"19":{"values":[".5"],"rule":{"__isSmartRef__":true,"id":18},"property":"stroke-opacity","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"20":{"declarations":[{"__isSmartRef__":true,"id":21}],"styleSheet":{"__isSmartRef__":true,"id":4},"selector":".Morph .x.axis path","__LivelyClassName__":"lively.morphic.StyleSheetRule","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"21":{"values":["none"],"rule":{"__isSmartRef__":true,"id":20},"property":"display","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"22":{"declarations":[{"__isSmartRef__":true,"id":23},{"__isSmartRef__":true,"id":24}],"styleSheet":{"__isSmartRef__":true,"id":4},"selector":".Morph .y.axis line, .y.axis path","__LivelyClassName__":"lively.morphic.StyleSheetRule","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"23":{"values":["none"],"rule":{"__isSmartRef__":true,"id":22},"property":"fill","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"24":{"values":["#000"],"rule":{"__isSmartRef__":true,"id":22},"property":"stroke","priority":false,"__LivelyClassName__":"lively.morphic.StyleSheetDeclaration","__SourceModuleName__":"Global.lively.morphic.StyleSheetRepresentation"},"25":{"partName":"StreamingD3","requiredModules":[],"partsSpaceName":"PartsBin/Charlie","comment":"no comment","changes":[{"__isSmartRef__":true,"id":26},{"__isSmartRef__":true,"id":27},{"__isSmartRef__":true,"id":28},{"__isSmartRef__":true,"id":29},{"__isSmartRef__":true,"id":30},{"__isSmartRef__":true,"id":31},{"__isSmartRef__":true,"id":32}],"migrationLevel":8,"__serializedExpressions__":["lastModifiedDate"],"__LivelyClassName__":"lively.PartsBin.PartsBinMetaInfo","__SourceModuleName__":"Global.lively.PartsBin","lastModifiedDate":"new Date(\"Fri Sep 26 2014 14:04:10 GMT-0700 (Pacific Daylight Time)\")"},"26":{"author":"cmagnuso","message":"no comment","id":"90C9570B-92E5-4245-8408-B78E1E14861B","__serializedExpressions__":["date"],"date":"new Date(\"Fri Sep 26 2014 14:04:04 GMT-0700 (Pacific Daylight Time)\")"},"27":{"author":"cmagnuso","message":"no comment","id":"553A7B3A-8C17-43ED-9043-D6780C8F667D","__serializedExpressions__":["date"],"date":"new Date(\"Fri Sep 26 2014 13:23:03 GMT-0700 (Pacific Daylight Time)\")"},"28":{"author":"robertkrahn","message":"no comment","id":"DA7483BC-7F0D-47A5-84B4-1D5C4D84A365","__serializedExpressions__":["date"],"date":"new Date(\"Thu May 01 2014 00:11:03 GMT-0700 (Pacific Daylight Time)\")"},"29":{"author":"robertkrahn","message":"no comment","id":"2C3083B5-AEBA-4315-9796-CFCA7DD0AA99","__serializedExpressions__":["date"],"date":"new Date(\"Thu May 01 2014 00:18:03 GMT-0700 (Pacific Daylight Time)\")"},"30":{"author":"cmagnuso","message":"no comment","id":"46AEAAF2-ED04-42C7-9B74-6028E5598756","__serializedExpressions__":["date"],"date":"new Date(\"Fri Sep 26 2014 13:16:44 GMT-0700 (Pacific Daylight Time)\")"},"31":{"author":"cmagnuso","message":"no comment","id":"C3E8505A-60AE-49A3-94A8-7EF96452F238","__serializedExpressions__":["date"],"date":"new Date(\"Fri Sep 26 2014 13:41:25 GMT-0700 (Pacific Daylight Time)\")"},"32":{"__serializedExpressions__":["date"],"author":"cmagnuso","message":"no comment","id":"7C6B33CF-D084-4920-8CC2-3580F4724CF5","date":"new Date(\"Sat Oct 11 2014 15:30:33 GMT-0700 (Pacific Daylight Time)\")"},"33":{"loadD3":{"__isSmartRef__":true,"id":34},"render":{"__isSmartRef__":true,"id":37},"reset":{"__isSmartRef__":true,"id":40},"onLoad":{"__isSmartRef__":true,"id":43},"testTick":{"__isSmartRef__":true,"id":46}},"34":{"varMapping":{"__isSmartRef__":true,"id":35},"source":"function loadD3(loadAttemptCount, thenDo) {\n    var self = this;\n    var maxLoadAttemptCount = 5;\n    var d3URL = '//cdnjs.cloudflare.com/ajax/libs/d3/3.4.6/d3.js';\n    if (!loadAttemptCount) loadAttemptCount = 1;\n    $('script[src=\"' + d3URL + '\"]').remove();\n    JSLoader.loadJs(d3URL);\n    Functions.waitFor(\n        5*1000,\n        function() { return typeof d3 !== 'undefined'; },\n        function(err) {\n            var msg;\n            if (err && loadAttemptCount < maxLoadAttemptCount) {\n                msg = Strings.format(\n                    \"Loading d3, attempt %s timed out.\\nTrying again...\",\n                    loadAttemptCount);\n                $world.setStatusMessage(msg, Color.yellow, 5);\n                self.loadD3(loadAttemptCount + 1);\n                return;\n            }\n            if (err) {\n                msg = Strings.format(\n                    \"Cannot load d3 library.\\nSorry, d3 isn't available right now.\",\n                    loadAttemptCount);\n                $world.setStatusMessage(msg, Color.red, 10);\n                return;\n            }\n            msg = Strings.format(\n                \"d3 loaded!\",\n                loadAttemptCount);\n            $world.setStatusMessage(msg, Color.green, 4);\n            thenDo && thenDo();\n            lively.bindings.signal(this, 'd3Loaded');\n        });\n}","funcProperties":{"__isSmartRef__":true,"id":36},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"35":{"this":{"__isSmartRef__":true,"id":0}},"36":{"user":"robertkrahn","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Wed Apr 30 2014 19:42:03 GMT-0700 (Pacific Daylight Time)\")"},"37":{"varMapping":{"__isSmartRef__":true,"id":38},"source":"function render(data) {\n    // this.data = Array.range(0, 300).map(function(n) { return {x: n, y: Numbers.normalRandom(100, 20)} })\n    // this.render(this.data)\n\n    var n = 40,\n    random = Global.d3.random.normal(0, .2),\n    data = Global.d3.range(n).map(random);\n \n    var margin = {top: 20, right: 20, bottom: 20, left: 40},\n        width = 960 - margin.left - margin.right,\n        height = 500 - margin.top - margin.bottom;\n     \n    var x = Global.d3.scale.linear()\n        .domain([0, n - 1])\n        .range([0, width]);\n     \n    var y = Global.d3.scale.linear()\n        .domain([-1, 1])\n        .range([height, 0]);\n     \n    var line = Global.d3.svg.line()\n        .x(function(d, i) { return x(i); })\n        .y(function(d, i) { return y(d); });\n    \n    // Add an SVG element with the desired dimensions and margin.\n    Global.d3.select(\"#\" + this.canvasId + \" svg\").remove();\n    \n    var svg = Global.d3.select(\"#\" + this.canvasId).append(\"svg\")\n        .attr(\"width\", width + margin.left + margin.right)\n        .attr(\"height\", height + margin.top + margin.bottom)\n      .append(\"g\")\n        .attr(\"transform\", \"translate(\" + margin.left + \",\" + margin.top + \")\");\n     \n    svg.append(\"defs\").append(\"clipPath\")\n        .attr(\"id\", \"clip\")\n      .append(\"rect\")\n        .attr(\"width\", width)\n        .attr(\"height\", height);\n     \n    svg.append(\"g\")\n        .attr(\"class\", \"x axis\")\n        .attr(\"transform\", \"translate(0,\" + y(0) + \")\")\n        .call(Global.d3.svg.axis().scale(x).orient(\"bottom\"));\n     \n    svg.append(\"g\")\n        .attr(\"class\", \"y axis\")\n        .call(Global.d3.svg.axis().scale(y).orient(\"left\"));\n     \n    var path = svg.append(\"g\")\n        .attr(\"clip-path\", \"url(#clip)\")\n      .append(\"path\")\n        .datum(data)\n        .attr(\"class\", \"line\")\n        .attr(\"d\", line);\n \n    tick();\n    \n    \n    function tick() {\n \n      // push a new data point onto the back\n      data.push(random());\n     \n      // redraw the line, and slide it to the left\n      path\n          .attr(\"d\", line)\n          .attr(\"transform\", null)\n        .transition()\n          .duration(500)\n          .ease(\"linear\")\n          .attr(\"transform\", \"translate(\" + x(-1) + \",0)\")\n          .each(\"end\", tick);\n     \n      // pop the old data point off the front\n      data.shift();\n     \n    }\n    \n\n}","funcProperties":{"__isSmartRef__":true,"id":39},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"38":{"this":{"__isSmartRef__":true,"id":0}},"39":{"__serializedExpressions__":["timestamp"],"user":"cmagnuso","timestamp":"new Date(\"Sat Oct 11 2014 15:29:08 GMT-0700 (Pacific Daylight Time)\")"},"40":{"varMapping":{"__isSmartRef__":true,"id":41},"source":"function reset() {\n    this.data = []\n    this.stopStepping();\n    this.canvasId = 'd3-' + this.id.replace(/-/g, '');\n    this.setHTML('<div id=\"' + this.canvasId + '\"></div>')\n    this.setClipMode('visible');\n}","funcProperties":{"__isSmartRef__":true,"id":42},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"41":{"this":{"__isSmartRef__":true,"id":0}},"42":{"user":"robertkrahn","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Thu May 01 2014 00:12:54 GMT-0700 (Pacific Daylight Time)\")"},"43":{"varMapping":{"__isSmartRef__":true,"id":44},"source":"function onLoad() {\n    this.canvasId = 'd3-' + this.id.replace(/-/g, '');\n    this.setHTML('<div id=\"' + this.canvasId + '\"></div>')\n    \n    this.loadD3();\n    \n    this.data = Array.range(0, 300).map(function(n) { return {x: n, y: Global.Numbers.normalRandom(100, 20)} })\n    this.render(this.data)\n}","funcProperties":{"__isSmartRef__":true,"id":45},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"44":{"this":{"__isSmartRef__":true,"id":0}},"45":{"user":"cmagnuso","__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Fri Sep 26 2014 13:21:35 GMT-0700 (Pacific Daylight Time)\")"},"46":{"varMapping":{"__isSmartRef__":true,"id":47},"source":"function testTick() {\n    // this.data = Array.range(0, 300).map(function(n) { return  })\n    // this.data = []\n    // this.startStepping(1000, 'testTick')\n    \n    this.data = this.data.slice(-5);\n    // data.push({x: data.last() ? data.last().x + 1 : 0, y: Numbers.normalRandom(100, 20)})\n    this.data.push({x: new Date(), y: Numbers.normalRandom(100, 20)})\n    this.render(this.data)\n}","funcProperties":{"__isSmartRef__":true,"id":48},"__LivelyClassName__":"lively.Closure","__SourceModuleName__":"Global.lively.lang.Closure"},"47":{"this":{"__isSmartRef__":true,"id":0}},"48":{"user":"robertkrahn","tags":[],"__serializedExpressions__":["timestamp"],"timestamp":"new Date(\"Thu May 01 2014 00:12:49 GMT-0700 (Pacific Daylight Time)\")"},"isSimplifiedRegistry":true}}