{"action":"created","comment":{"url":"https://api.github.com/repos/palantir/plottable/pulls/comments/33970360","id":33970360,"diff_hunk":"@@ -0,0 +1,195 @@\n+///<reference path=\"../reference.ts\" />\n+\n+module Plottable {\n+export module Plots {\n+  export class Waterfall<X, Y> extends Bar<X, Y> {\n+    private static _BAR_DECLINE_CLASS = \"waterfall-decline\";\n+    private static _BAR_GROWTH_CLASS = \"waterfall-growth\";\n+    private static _BAR_TOTAL_CLASS = \"waterfall-total\";\n+    private static _CONNECTOR_CLASS = \"connector\";\n+    private static _CONNECTOR_AREA_CLASS = \"connector-area\";\n+    private static _TOTAL_KEY = \"total\";\n+    private _connectorArea: d3.Selection<void>;\n+    private _connectorsEnabled = false;\n+    private _extent: number[];\n+    private _subtotals: number[];\n+\n+    constructor() {\n+      super();\n+      this.addClass(\"waterfall-plot\");\n+    }\n+\n+    /**\n+     * Gets whether connectors are enabled.\n+     * \n+     * @returns {boolean} Whether connectors should be shown or not.\n+     */\n+    public connectorsEnabled(): boolean;\n+    /**\n+     * Sets whether connectors are enabled.\n+     * \n+     * @param {boolean} enabled\n+     * @returns {Waterfall} The calling Waterfall Plot.\n+     */\n+    public connectorsEnabled(enabled: boolean): Waterfall<X, Y>;\n+    public connectorsEnabled(enabled?: boolean): any {\n+      if (enabled === undefined) {\n+        return this._connectorsEnabled;\n+      }\n+      this._connectorsEnabled = enabled;\n+      return this;\n+    }\n+\n+    /**\n+     * Gets the AccessorScaleBinding for whether a bar represents a total or a delta.\n+     */\n+    public total<T>(): Plots.AccessorScaleBinding<T, boolean>;\n+    /**\n+     * Sets total to a constant number or the result of an Accessor\n+     * \n+     * @param {Accessor<boolean>}\n+     * @returns {Waterfall} The calling Waterfall Plot.\n+     */\n+    public total(total: Accessor<boolean>): Waterfall<X, Y>;\n+    public total<T>(total?: Accessor<boolean> | T | Accessor<T>): any {\n+      if (total === undefined) {\n+        return this._propertyBindings.get(Waterfall._TOTAL_KEY);\n+      }\n+      this._bindProperty(Waterfall._TOTAL_KEY, total, null);\n+      return this;\n+    }\n+\n+    protected _additionalPaint(time: number) {\n+      this._connectorArea.selectAll(\"line\").remove();\n+      if (this._connectorsEnabled) {\n+        Utils.Window.setTimeout(() => this._drawConnectors(), time);\n+      }\n+    }\n+\n+    protected _createNodesForDataset(dataset: Dataset) {\n+      var drawer = super._createNodesForDataset(dataset);\n+      this._connectorArea = this._renderArea.append(\"g\").classed(Waterfall._CONNECTOR_AREA_CLASS, true);\n+      return drawer;\n+    }\n+\n+    protected _extentsForProperty(attr: string) {\n+      var primaryAttr = \"y\";\n+      if (attr === primaryAttr) {\n+        return [this._extent];\n+      } else {\n+        return super._extentsForProperty(attr);\n+      }\n+    }\n+\n+    protected _generateAttrToProjector() {\n+      var attrToProjector = super._generateAttrToProjector();\n+\n+      var yScale = this.y().scale;\n+      var totalAccessor = Plot._scaledAccessor(this.total());\n+\n+      var yAttr = this.attr(\"y\");\n+      if (yAttr === undefined) {\n+        attrToProjector[\"y\"] = (d, i, dataset) => {\n+          var isTotal = totalAccessor(d, i, dataset);\n+          if (isTotal) {\n+            return Plot._scaledAccessor(this.y())(d, i, dataset);\n+          } else {\n+            var currentSubtotal = this._subtotals[i];\n+            var priorSubtotal = this._subtotals[i - 1];\n+            if (currentSubtotal > priorSubtotal) {\n+              return yScale.scale(<any> currentSubtotal);\n+            } else {\n+              return yScale.scale(<any> priorSubtotal);\n+            }\n+          }\n+        };\n+      }\n+\n+      var heightAttr = this.attr(\"height\");\n+      if (heightAttr === undefined) {\n+        attrToProjector[\"height\"] = (d, i, dataset) => {\n+          var isTotal = totalAccessor(d, i, dataset);\n+          var currentValue = this.y().accessor(d, i, dataset);\n+          if (isTotal) {\n+            return Math.abs(yScale.scale(<any> currentValue) - yScale.scale(<any> 0));","path":"src/plots/waterfallPlot.ts","position":114,"original_position":114,"commit_id":"3aaed04e4dc4f487793ea8deed3b7873dadfc52f","original_commit_id":"3aaed04e4dc4f487793ea8deed3b7873dadfc52f","user":{"login":"aicioara","id":3248682,"avatar_url":"https://avatars.githubusercontent.com/u/3248682?v=3","gravatar_id":"","url":"https://api.github.com/users/aicioara","html_url":"https://github.com/aicioara","followers_url":"https://api.github.com/users/aicioara/followers","following_url":"https://api.github.com/users/aicioara/following{/other_user}","gists_url":"https://api.github.com/users/aicioara/gists{/gist_id}","starred_url":"https://api.github.com/users/aicioara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aicioara/subscriptions","organizations_url":"https://api.github.com/users/aicioara/orgs","repos_url":"https://api.github.com/users/aicioara/repos","events_url":"https://api.github.com/users/aicioara/events{/privacy}","received_events_url":"https://api.github.com/users/aicioara/received_events","type":"User","site_admin":false},"body":"Extending what?","created_at":"2015-07-06T19:04:54Z","updated_at":"2015-07-06T19:04:54Z","html_url":"https://github.com/palantir/plottable/pull/2426#discussion_r33970360","pull_request_url":"https://api.github.com/repos/palantir/plottable/pulls/2426","_links":{"self":{"href":"https://api.github.com/repos/palantir/plottable/pulls/comments/33970360"},"html":{"href":"https://github.com/palantir/plottable/pull/2426#discussion_r33970360"},"pull_request":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2426"}}},"pull_request":{"url":"https://api.github.com/repos/palantir/plottable/pulls/2426","id":39035120,"html_url":"https://github.com/palantir/plottable/pull/2426","diff_url":"https://github.com/palantir/plottable/pull/2426.diff","patch_url":"https://github.com/palantir/plottable/pull/2426.patch","issue_url":"https://api.github.com/repos/palantir/plottable/issues/2426","number":2426,"state":"open","locked":false,"title":"Implement Plots.Waterfall","user":{"login":"rcchen","id":1175041,"avatar_url":"https://avatars.githubusercontent.com/u/1175041?v=3","gravatar_id":"","url":"https://api.github.com/users/rcchen","html_url":"https://github.com/rcchen","followers_url":"https://api.github.com/users/rcchen/followers","following_url":"https://api.github.com/users/rcchen/following{/other_user}","gists_url":"https://api.github.com/users/rcchen/gists{/gist_id}","starred_url":"https://api.github.com/users/rcchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcchen/subscriptions","organizations_url":"https://api.github.com/users/rcchen/orgs","repos_url":"https://api.github.com/users/rcchen/repos","events_url":"https://api.github.com/users/rcchen/events{/privacy}","received_events_url":"https://api.github.com/users/rcchen/received_events","type":"User","site_admin":false},"body":"![image](https://cloud.githubusercontent.com/assets/1175041/8484060/34584806-20aa-11e5-857c-5d1512406e7b.png)\r\n\r\nBased off of `Plots.Bar`, `Plots.Waterfall` has the following API points in addition to what is expected from `Plots.Bar`:\r\n\r\n- `.connectorsEnabled()`/`.connectorsEnabled(enabled)` - gets/sets whether connector lines should be enabled or not.\r\n- `.total()`/`.total(total)` - gets/sets the accessor for whether each bar represents a total or not. Must return a boolean.\r\n\r\nData model:\r\n```javascript\r\n{\r\n  x: \"A\", // xValue for each bar. Will be interpreted as a category\r\n  y: 150, // yValue for each bar. Can be a total or a delta.\r\n  t: \"total\" // the type of each bar. You can put anything here but its accessor should return a boolean\r\n}\r\n```\r\n\r\nFiddle: http://jsfiddle.net/a3mmsbdt/","created_at":"2015-07-01T23:21:29Z","updated_at":"2015-07-06T19:04:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57ae4a3ef5ed70ba2c49c816bc0bed204b144575","assignee":{"login":"rcchen","id":1175041,"avatar_url":"https://avatars.githubusercontent.com/u/1175041?v=3","gravatar_id":"","url":"https://api.github.com/users/rcchen","html_url":"https://github.com/rcchen","followers_url":"https://api.github.com/users/rcchen/followers","following_url":"https://api.github.com/users/rcchen/following{/other_user}","gists_url":"https://api.github.com/users/rcchen/gists{/gist_id}","starred_url":"https://api.github.com/users/rcchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcchen/subscriptions","organizations_url":"https://api.github.com/users/rcchen/orgs","repos_url":"https://api.github.com/users/rcchen/repos","events_url":"https://api.github.com/users/rcchen/events{/privacy}","received_events_url":"https://api.github.com/users/rcchen/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/palantir/plottable/pulls/2426/commits","review_comments_url":"https://api.github.com/repos/palantir/plottable/pulls/2426/comments","review_comment_url":"https://api.github.com/repos/palantir/plottable/pulls/comments{/number}","comments_url":"https://api.github.com/repos/palantir/plottable/issues/2426/comments","statuses_url":"https://api.github.com/repos/palantir/plottable/statuses/3aaed04e4dc4f487793ea8deed3b7873dadfc52f","head":{"label":"palantir:1853fix","ref":"1853fix","sha":"3aaed04e4dc4f487793ea8deed3b7873dadfc52f","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":16149854,"name":"plottable","full_name":"palantir/plottable","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/plottable","description":"A library of modular chart components, built on D3","fork":false,"url":"https://api.github.com/repos/palantir/plottable","forks_url":"https://api.github.com/repos/palantir/plottable/forks","keys_url":"https://api.github.com/repos/palantir/plottable/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/plottable/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/plottable/teams","hooks_url":"https://api.github.com/repos/palantir/plottable/hooks","issue_events_url":"https://api.github.com/repos/palantir/plottable/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/plottable/events","assignees_url":"https://api.github.com/repos/palantir/plottable/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/plottable/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/plottable/tags","blobs_url":"https://api.github.com/repos/palantir/plottable/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/plottable/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/plottable/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/plottable/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/plottable/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/plottable/languages","stargazers_url":"https://api.github.com/repos/palantir/plottable/stargazers","contributors_url":"https://api.github.com/repos/palantir/plottable/contributors","subscribers_url":"https://api.github.com/repos/palantir/plottable/subscribers","subscription_url":"https://api.github.com/repos/palantir/plottable/subscription","commits_url":"https://api.github.com/repos/palantir/plottable/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/plottable/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/plottable/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/plottable/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/plottable/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/plottable/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/plottable/merges","archive_url":"https://api.github.com/repos/palantir/plottable/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/plottable/downloads","issues_url":"https://api.github.com/repos/palantir/plottable/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/plottable/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/plottable/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/plottable/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/plottable/labels{/name}","releases_url":"https://api.github.com/repos/palantir/plottable/releases{/id}","created_at":"2014-01-22T19:29:19Z","updated_at":"2015-07-06T14:51:36Z","pushed_at":"2015-07-06T18:48:31Z","git_url":"git://github.com/palantir/plottable.git","ssh_url":"git@github.com:palantir/plottable.git","clone_url":"https://github.com/palantir/plottable.git","svn_url":"https://github.com/palantir/plottable","homepage":"plottablejs.org","size":126839,"stargazers_count":599,"watchers_count":599,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":170,"forks":54,"open_issues":170,"watchers":599,"default_branch":"develop"}},"base":{"label":"palantir:develop","ref":"develop","sha":"be88b43d43ddbd54f87835d36b51da30ed28a837","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":16149854,"name":"plottable","full_name":"palantir/plottable","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/plottable","description":"A library of modular chart components, built on D3","fork":false,"url":"https://api.github.com/repos/palantir/plottable","forks_url":"https://api.github.com/repos/palantir/plottable/forks","keys_url":"https://api.github.com/repos/palantir/plottable/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/plottable/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/plottable/teams","hooks_url":"https://api.github.com/repos/palantir/plottable/hooks","issue_events_url":"https://api.github.com/repos/palantir/plottable/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/plottable/events","assignees_url":"https://api.github.com/repos/palantir/plottable/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/plottable/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/plottable/tags","blobs_url":"https://api.github.com/repos/palantir/plottable/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/plottable/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/plottable/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/plottable/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/plottable/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/plottable/languages","stargazers_url":"https://api.github.com/repos/palantir/plottable/stargazers","contributors_url":"https://api.github.com/repos/palantir/plottable/contributors","subscribers_url":"https://api.github.com/repos/palantir/plottable/subscribers","subscription_url":"https://api.github.com/repos/palantir/plottable/subscription","commits_url":"https://api.github.com/repos/palantir/plottable/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/plottable/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/plottable/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/plottable/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/plottable/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/plottable/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/plottable/merges","archive_url":"https://api.github.com/repos/palantir/plottable/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/plottable/downloads","issues_url":"https://api.github.com/repos/palantir/plottable/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/plottable/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/plottable/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/plottable/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/plottable/labels{/name}","releases_url":"https://api.github.com/repos/palantir/plottable/releases{/id}","created_at":"2014-01-22T19:29:19Z","updated_at":"2015-07-06T14:51:36Z","pushed_at":"2015-07-06T18:48:31Z","git_url":"git://github.com/palantir/plottable.git","ssh_url":"git@github.com:palantir/plottable.git","clone_url":"https://github.com/palantir/plottable.git","svn_url":"https://github.com/palantir/plottable","homepage":"plottablejs.org","size":126839,"stargazers_count":599,"watchers_count":599,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":170,"forks":54,"open_issues":170,"watchers":599,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2426"},"html":{"href":"https://github.com/palantir/plottable/pull/2426"},"issue":{"href":"https://api.github.com/repos/palantir/plottable/issues/2426"},"comments":{"href":"https://api.github.com/repos/palantir/plottable/issues/2426/comments"},"review_comments":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2426/comments"},"review_comment":{"href":"https://api.github.com/repos/palantir/plottable/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2426/commits"},"statuses":{"href":"https://api.github.com/repos/palantir/plottable/statuses/3aaed04e4dc4f487793ea8deed3b7873dadfc52f"}}}}