{"action":"created","issue":{"url":"https://api.github.com/repos/Chorus/chorus/issues/170","labels_url":"https://api.github.com/repos/Chorus/chorus/issues/170/labels{/name}","comments_url":"https://api.github.com/repos/Chorus/chorus/issues/170/comments","events_url":"https://api.github.com/repos/Chorus/chorus/issues/170/events","html_url":"https://github.com/Chorus/chorus/pull/170","id":109379506,"number":170,"title":"Extract chorus visualization into VisLegacy component (REVIEW 1st, MERGE LAST)","user":{"login":"kevin-alpine","id":12001313,"avatar_url":"https://avatars.githubusercontent.com/u/12001313?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-alpine","html_url":"https://github.com/kevin-alpine","followers_url":"https://api.github.com/users/kevin-alpine/followers","following_url":"https://api.github.com/users/kevin-alpine/following{/other_user}","gists_url":"https://api.github.com/users/kevin-alpine/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-alpine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-alpine/subscriptions","organizations_url":"https://api.github.com/users/kevin-alpine/orgs","repos_url":"https://api.github.com/users/kevin-alpine/repos","events_url":"https://api.github.com/users/kevin-alpine/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-alpine/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-01T20:42:54Z","updated_at":"2015-12-07T23:40:25Z","closed_at":"2015-10-05T19:03:11Z","pull_request":{"url":"https://api.github.com/repos/Chorus/chorus/pulls/170","html_url":"https://github.com/Chorus/chorus/pull/170","diff_url":"https://github.com/Chorus/chorus/pull/170.diff","patch_url":"https://github.com/Chorus/chorus/pull/170.patch"},"body":"Curran, Sara, & Lawrence asked me to help Curran modify Chorus's visualization system to work with Curran's Chiasm project.\r\n\r\nThe goal of this work is to reach parity: we're simply swapping out the current system to use Chiasm for visualization.\r\n\r\nAs is often the case -- even though, during the meeting we had on Tuesday, this was the least ambitious path (adding no new functionality, just using Chiasm to replace the current Dataset visualization system), as I looked into accomplishing it on Tuesday night, I was stunned by how big of a system it is really is: there are **~22k lines of code** in Chorus devoted to generating those graphs.\r\n\r\nSo -- in order to do it in a sane way, I'm doing in four steps:\r\n* 1st (this step): extract all the code currently in the system into a component called VisLegacy.\r\n* 2nd: duplicate VisLegacy into a 2nd component called VisChiasm and switch over Chorus to use that new component.\r\n* 3rd: aggressively modify the VisChiasm component to work with Chiasm and clean out all the bits of VisLegacy that are now deprecated.\r\n* 4th (later): Delete the VisLegacy component.\r\n\r\nIn order to make these changes reviewable, I will create a chain of Github PRs (each merges into one another before finally merging into master).\r\n\r\n@midnighteuler, @AndrewLngdn, @jleealpine, @curran: this branch is cool because it's a validation of how useful the \"components\" idea can be -- also, I needed to be able to divide up the Backbone code into components, so I had to invent a simple way to do it:\r\n* I divided the `Messages_en.properties` file into two pieces.  I store the URLs in an array, and load and concatenate them before passing them into the I18n js.\r\n* This plugin is not namespaced -- [it's \"Full\" but not \"Mountable\"](http://guides.rubyonrails.org/engines.html) ... so, once the app boots ... everything gets mashed together into one namespace.  This doesn't get us quite as much namespacing and code isolation but it does get us swap-ability.\r\n\r\nI will comment more in the body of the PR ... "},"comment":{"url":"https://api.github.com/repos/Chorus/chorus/issues/comments/162706378","html_url":"https://github.com/Chorus/chorus/pull/170#issuecomment-162706378","issue_url":"https://api.github.com/repos/Chorus/chorus/issues/170","id":162706378,"user":{"login":"curran","id":68416,"avatar_url":"https://avatars.githubusercontent.com/u/68416?v=3","gravatar_id":"","url":"https://api.github.com/users/curran","html_url":"https://github.com/curran","followers_url":"https://api.github.com/users/curran/followers","following_url":"https://api.github.com/users/curran/following{/other_user}","gists_url":"https://api.github.com/users/curran/gists{/gist_id}","starred_url":"https://api.github.com/users/curran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/curran/subscriptions","organizations_url":"https://api.github.com/users/curran/orgs","repos_url":"https://api.github.com/users/curran/repos","events_url":"https://api.github.com/users/curran/events{/privacy}","received_events_url":"https://api.github.com/users/curran/received_events","type":"User","site_admin":false},"created_at":"2015-12-07T23:40:25Z","updated_at":"2015-12-07T23:40:25Z","body":"Just to keep a record in case we want to use this database random sampling API in the future - here's the front end Chiasm module that connects to it:\r\n\r\n```javascript\r\n//A Chiasm plugin that loads data from the vis_chiasm random sampling API.\r\nvar Model = require(\"model-js\");\r\nvar ChiasmComponent = require(\"chiasm-component\");\r\nvar d3 = require(\"d3\");\r\nvar dsvDataset = require(\"dsv-dataset\");\r\n\r\nmodule.exports = function (){\r\n\r\n  var my = ChiasmComponent({\r\n    dataset_id: Model.None,\r\n    numRows: 1000\r\n  });\r\n\r\n  my.when([\"dataset_id\", \"numRows\"], function (dataset_id, numRows){\r\n    if(dataset_id !== Model.None){\r\n\r\n      var columnsPath = \"datasets/\" + dataset_id + \"/chiasm_api_datasets/show_column_data\";\r\n      var dataPath = \"datasets/\" + dataset_id + \"/chiasm_api_datasets/show_data\";\r\n\r\n      dataPath += \"?numRows=\" + numRows;\r\n\r\n      d3.json(columnsPath, function(error, columns) {\r\n        if(error){ throw error; }\r\n        my.metadata = { columns: columns };\r\n      });\r\n\r\n      d3.xhr(dataPath, function (error, xhr){\r\n        if(error){ throw error; }\r\n        my.dsvString = xhr.response;\r\n      });\r\n    }\r\n  });\r\n\r\n  my.when([\"dsvString\", \"metadata\"], function (dsvString, metadata){\r\n    my.dataset = dsvDataset.parse({\r\n      dsvString: dsvString, \r\n      metadata: metadata\r\n    });\r\n    my.data = my.dataset.data;\r\n  });\r\n\r\n  return my;\r\n}\r\n```"}}