{"action":"created","comment":{"url":"https://api.github.com/repos/ScottLogic/d3fc/pulls/comments/39268044","id":39268044,"diff_hunk":"@@ -0,0 +1,211 @@\n+(function(d3, fc) {\n+    'use strict';\n+\n+    fc.chart.cartesianChart = function(xScale, yScale) {\n+\n+        xScale = xScale || d3.scale.linear();\n+        yScale = yScale || d3.scale.linear();\n+\n+        var plotAreaMargin = {\n+                top: 20,\n+                bottom: 30,\n+                left: 0,\n+                right: 40\n+            },\n+            yAxisLabel = 'y-axis',\n+            xAxisLabel = 'x-axis',\n+            chartLabel = 'Chart',\n+            plotArea = fc.series.line(),\n+            decorate = fc.util.fn.noop;\n+\n+        var xAxis = fc.series.axis()\n+            .orient('bottom')\n+            .baseline(function() {\n+                var domain = yScale.domain();\n+                return xAxis.orient() === 'bottom' ? domain[0] : domain[1];\n+            });\n+\n+        var yAxis = fc.series.axis()\n+            .orient('right')\n+            .baseline(function() {\n+                var domain = xScale.domain();\n+                return yAxis.orient() === 'right' ? domain[1] : domain[0];\n+            });\n+\n+        var axesSeries = fc.series.multi()\n+            .series([xAxis, yAxis]);\n+\n+        var containerDataJoin = fc.util.dataJoin()\n+            .selector('svg.cartesian-chart')\n+            .element('svg')\n+            .attr({'class': 'cartesian-chart', 'layout-css': 'flex: 1'});\n+\n+        var cartesianChart = function(selection) {\n+\n+            selection.each(function(data, index) {\n+\n+                var container = d3.select(this);\n+\n+                var svg = containerDataJoin(container, [data]);\n+                svg.enter().html(\n+                    '<g class=\"title\"> \\\n+                        <g layout-css=\"height: 0; width: 0\"> \\\n+                            <text class=\"label\"/> \\\n+                        </g> \\\n+                    </g> \\\n+                    <g class=\"y-axis\"> \\\n+                        <g layout-css=\"height: 0; width: 0\"> \\\n+                            <text class=\"label\" transform=\"rotate(-90)\"/> \\\n+                        </g> \\\n+                    </g> \\\n+                    <g class=\"x-axis\"> \\\n+                        <g layout-css=\"height: 0; width: 0\"> \\\n+                            <text class=\"label\"/> \\\n+                        </g> \\\n+                    </g> \\\n+                    <g class=\"plot-area-container\"> \\\n+                        <svg class=\"axes-container\" \\\n+                            layout-css=\"position: absolute; top: 0; bottom: 0; left: 0; right: 0\"/> \\\n+                        <svg class=\"plot-area\" \\\n+                            layout-css=\"position: absolute; top: 0; bottom: 0; left: 0; right: 0\"/> \\\n+                    </g>');\n+\n+                var margin = fc.util.expandMargin(plotAreaMargin);\n+\n+                svg.select('.plot-area-container')\n+                    .layout({\n+                        position: 'absolute',\n+                        top: margin.top,\n+                        left: margin.left,\n+                        bottom: margin.bottom,\n+                        right: margin.right\n+                    });\n+\n+                svg.select('.title')\n+                    .layout({\n+                        position: 'absolute',\n+                        top: 0,\n+                        alignItems: 'center',\n+                        left: margin.left,\n+                        right: margin.right\n+                    });\n+\n+                var yAxisLayout = {\n+                    position: 'absolute',\n+                    top: margin.top,\n+                    bottom: margin.bottom,\n+                    alignItems: 'center',\n+                    flexDirection: 'row'\n+                };\n+                if (yAxis.orient() === 'right') {\n+                    yAxisLayout.right = 0;\n+                } else {\n+                    yAxisLayout.left = 0;\n+                }\n+                svg.select('.y-axis')\n+                    .layout(yAxisLayout);\n+\n+                var xAxisLayout = {\n+                    position: 'absolute',\n+                    left: margin.left,\n+                    right: margin.right,\n+                    alignItems: 'center'\n+                };\n+                if (xAxis.orient() === 'bottom') {\n+                    xAxisLayout.bottom = 0;\n+                } else {\n+                    xAxisLayout.top = 0;\n+                }\n+                svg.select('.x-axis')\n+                    .layout(xAxisLayout);\n+\n+                // perform the flexbox / css layout\n+                container.layout();\n+\n+                // update the label text\n+                svg.select('.title .label')\n+                    .text(chartLabel);\n+\n+                svg.select('.y-axis .label')\n+                    .text(yAxisLabel);\n+\n+                svg.select('.x-axis .label')\n+                    .text(xAxisLabel);\n+\n+                // set the axis ranges\n+                var plotAreaContainer = svg.select('.plot-area');\n+                xScale.range([0, plotAreaContainer.layout('width')]);\n+                yScale.range([plotAreaContainer.layout('height'), 0]);\n+\n+                // render the axes\n+                var axesContainer = svg.select('.axes-container');\n+                axesSeries.xScale(xScale)\n+                    .yScale(yScale);\n+                axesContainer.call(axesSeries);\n+\n+                // render the plot area\n+                plotArea.xScale(xScale)\n+                    .yScale(yScale);\n+                plotAreaContainer.call(plotArea);\n+\n+                decorate(svg, data, index);\n+            });\n+        };\n+\n+        var scaleExclusions = [\n+            'range', 'rangeRound', // the scale range is set via the component layout\n+            'tickFormat'           // use axis.tickFormat instead\n+        ];\n+        fc.util.rebindAll(cartesianChart, xScale, 'x', scaleExclusions);\n+        fc.util.rebindAll(cartesianChart, yScale, 'y', scaleExclusions);\n+\n+        fc.util.rebindAll(cartesianChart, xAxis, 'x');\n+        fc.util.rebindAll(cartesianChart, yAxis, 'y');\n+\n+        cartesianChart.chartLabel = function(x) {\n+            if (!arguments.length) {\n+                return chartLabel;\n+            }\n+            chartLabel = x;\n+            return cartesianChart;\n+        };\n+        cartesianChart.plotArea = function(x) {\n+            if (!arguments.length) {\n+                return plotArea;\n+            }\n+            plotArea = x;\n+            return cartesianChart;\n+        };\n+        cartesianChart.xAxisLabel = function(x) {","path":"src/chart/cartesianChart.js","position":179,"original_position":179,"commit_id":"5b394abef161085875338965073f3317541be7da","original_commit_id":"5b394abef161085875338965073f3317541be7da","user":{"login":"ColinEberhardt","id":1098110,"avatar_url":"https://avatars.githubusercontent.com/u/1098110?v=3","gravatar_id":"","url":"https://api.github.com/users/ColinEberhardt","html_url":"https://github.com/ColinEberhardt","followers_url":"https://api.github.com/users/ColinEberhardt/followers","following_url":"https://api.github.com/users/ColinEberhardt/following{/other_user}","gists_url":"https://api.github.com/users/ColinEberhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/ColinEberhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ColinEberhardt/subscriptions","organizations_url":"https://api.github.com/users/ColinEberhardt/orgs","repos_url":"https://api.github.com/users/ColinEberhardt/repos","events_url":"https://api.github.com/users/ColinEberhardt/events{/privacy}","received_events_url":"https://api.github.com/users/ColinEberhardt/received_events","type":"User","site_admin":false},"body":"done","created_at":"2015-09-11T12:59:13Z","updated_at":"2015-09-11T12:59:13Z","html_url":"https://github.com/ScottLogic/d3fc/pull/518#discussion_r39268044","pull_request_url":"https://api.github.com/repos/ScottLogic/d3fc/pulls/518","_links":{"self":{"href":"https://api.github.com/repos/ScottLogic/d3fc/pulls/comments/39268044"},"html":{"href":"https://github.com/ScottLogic/d3fc/pull/518#discussion_r39268044"},"pull_request":{"href":"https://api.github.com/repos/ScottLogic/d3fc/pulls/518"}}},"pull_request":{"url":"https://api.github.com/repos/ScottLogic/d3fc/pulls/518","id":43371160,"html_url":"https://github.com/ScottLogic/d3fc/pull/518","diff_url":"https://github.com/ScottLogic/d3fc/pull/518.diff","patch_url":"https://github.com/ScottLogic/d3fc/pull/518.patch","issue_url":"https://api.github.com/repos/ScottLogic/d3fc/issues/518","number":518,"state":"open","locked":false,"title":"Cartesian chart","user":{"login":"ColinEberhardt","id":1098110,"avatar_url":"https://avatars.githubusercontent.com/u/1098110?v=3","gravatar_id":"","url":"https://api.github.com/users/ColinEberhardt","html_url":"https://github.com/ColinEberhardt","followers_url":"https://api.github.com/users/ColinEberhardt/followers","following_url":"https://api.github.com/users/ColinEberhardt/following{/other_user}","gists_url":"https://api.github.com/users/ColinEberhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/ColinEberhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ColinEberhardt/subscriptions","organizations_url":"https://api.github.com/users/ColinEberhardt/orgs","repos_url":"https://api.github.com/users/ColinEberhardt/repos","events_url":"https://api.github.com/users/ColinEberhardt/events{/privacy}","received_events_url":"https://api.github.com/users/ColinEberhardt/received_events","type":"User","site_admin":false},"body":"I think we need a more versatile chart component with axis labels and configurable scales. This is a quick prototype to test out a few ideas.\r\n\r\nThe non-standard part of this component is the way the scales work. In order to expose them as properties the settings from previous scales need to be re-applied and the new scale properties rebound.\r\n\r\nWhat do others think - does this look viable?","created_at":"2015-08-26T07:18:16Z","updated_at":"2015-09-11T12:59:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f97d54856fb7e5f406c61394d9cd1efa41a381c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ScottLogic/d3fc/pulls/518/commits","review_comments_url":"https://api.github.com/repos/ScottLogic/d3fc/pulls/518/comments","review_comment_url":"https://api.github.com/repos/ScottLogic/d3fc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ScottLogic/d3fc/issues/518/comments","statuses_url":"https://api.github.com/repos/ScottLogic/d3fc/statuses/5b394abef161085875338965073f3317541be7da","head":{"label":"ColinEberhardt:cartesian-chart","ref":"cartesian-chart","sha":"5b394abef161085875338965073f3317541be7da","user":{"login":"ColinEberhardt","id":1098110,"avatar_url":"https://avatars.githubusercontent.com/u/1098110?v=3","gravatar_id":"","url":"https://api.github.com/users/ColinEberhardt","html_url":"https://github.com/ColinEberhardt","followers_url":"https://api.github.com/users/ColinEberhardt/followers","following_url":"https://api.github.com/users/ColinEberhardt/following{/other_user}","gists_url":"https://api.github.com/users/ColinEberhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/ColinEberhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ColinEberhardt/subscriptions","organizations_url":"https://api.github.com/users/ColinEberhardt/orgs","repos_url":"https://api.github.com/users/ColinEberhardt/repos","events_url":"https://api.github.com/users/ColinEberhardt/events{/privacy}","received_events_url":"https://api.github.com/users/ColinEberhardt/received_events","type":"User","site_admin":false},"repo":{"id":26486000,"name":"d3-financial-components","full_name":"ColinEberhardt/d3-financial-components","owner":{"login":"ColinEberhardt","id":1098110,"avatar_url":"https://avatars.githubusercontent.com/u/1098110?v=3","gravatar_id":"","url":"https://api.github.com/users/ColinEberhardt","html_url":"https://github.com/ColinEberhardt","followers_url":"https://api.github.com/users/ColinEberhardt/followers","following_url":"https://api.github.com/users/ColinEberhardt/following{/other_user}","gists_url":"https://api.github.com/users/ColinEberhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/ColinEberhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ColinEberhardt/subscriptions","organizations_url":"https://api.github.com/users/ColinEberhardt/orgs","repos_url":"https://api.github.com/users/ColinEberhardt/repos","events_url":"https://api.github.com/users/ColinEberhardt/events{/privacy}","received_events_url":"https://api.github.com/users/ColinEberhardt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ColinEberhardt/d3-financial-components","description":"A set of re-useable components for building financial charts with D3","fork":true,"url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components","forks_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/forks","keys_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/teams","hooks_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/hooks","issue_events_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/issues/events{/number}","events_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/events","assignees_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/assignees{/user}","branches_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/branches{/branch}","tags_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/tags","blobs_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/git/refs{/sha}","trees_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/statuses/{sha}","languages_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/languages","stargazers_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/stargazers","contributors_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/contributors","subscribers_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/subscribers","subscription_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/subscription","commits_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/commits{/sha}","git_commits_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/git/commits{/sha}","comments_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/comments{/number}","issue_comment_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/issues/comments{/number}","contents_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/contents/{+path}","compare_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/merges","archive_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/downloads","issues_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/issues{/number}","pulls_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/pulls{/number}","milestones_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/milestones{/number}","notifications_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/labels{/name}","releases_url":"https://api.github.com/repos/ColinEberhardt/d3-financial-components/releases{/id}","created_at":"2014-11-11T13:25:33Z","updated_at":"2015-05-07T07:47:58Z","pushed_at":"2015-09-11T07:54:05Z","git_url":"git://github.com/ColinEberhardt/d3-financial-components.git","ssh_url":"git@github.com:ColinEberhardt/d3-financial-components.git","clone_url":"https://github.com/ColinEberhardt/d3-financial-components.git","svn_url":"https://github.com/ColinEberhardt/d3-financial-components","homepage":"","size":4291,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"ScottLogic:master","ref":"master","sha":"9ffd8b9393033b845fe75925d0db7b6c2a256911","user":{"login":"ScottLogic","id":2046037,"avatar_url":"https://avatars.githubusercontent.com/u/2046037?v=3","gravatar_id":"","url":"https://api.github.com/users/ScottLogic","html_url":"https://github.com/ScottLogic","followers_url":"https://api.github.com/users/ScottLogic/followers","following_url":"https://api.github.com/users/ScottLogic/following{/other_user}","gists_url":"https://api.github.com/users/ScottLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/ScottLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScottLogic/subscriptions","organizations_url":"https://api.github.com/users/ScottLogic/orgs","repos_url":"https://api.github.com/users/ScottLogic/repos","events_url":"https://api.github.com/users/ScottLogic/events{/privacy}","received_events_url":"https://api.github.com/users/ScottLogic/received_events","type":"Organization","site_admin":false},"repo":{"id":24850617,"name":"d3fc","full_name":"ScottLogic/d3fc","owner":{"login":"ScottLogic","id":2046037,"avatar_url":"https://avatars.githubusercontent.com/u/2046037?v=3","gravatar_id":"","url":"https://api.github.com/users/ScottLogic","html_url":"https://github.com/ScottLogic","followers_url":"https://api.github.com/users/ScottLogic/followers","following_url":"https://api.github.com/users/ScottLogic/following{/other_user}","gists_url":"https://api.github.com/users/ScottLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/ScottLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScottLogic/subscriptions","organizations_url":"https://api.github.com/users/ScottLogic/orgs","repos_url":"https://api.github.com/users/ScottLogic/repos","events_url":"https://api.github.com/users/ScottLogic/events{/privacy}","received_events_url":"https://api.github.com/users/ScottLogic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ScottLogic/d3fc","description":"A collection of components that make it easy to build interactive charts with D3","fork":false,"url":"https://api.github.com/repos/ScottLogic/d3fc","forks_url":"https://api.github.com/repos/ScottLogic/d3fc/forks","keys_url":"https://api.github.com/repos/ScottLogic/d3fc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ScottLogic/d3fc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ScottLogic/d3fc/teams","hooks_url":"https://api.github.com/repos/ScottLogic/d3fc/hooks","issue_events_url":"https://api.github.com/repos/ScottLogic/d3fc/issues/events{/number}","events_url":"https://api.github.com/repos/ScottLogic/d3fc/events","assignees_url":"https://api.github.com/repos/ScottLogic/d3fc/assignees{/user}","branches_url":"https://api.github.com/repos/ScottLogic/d3fc/branches{/branch}","tags_url":"https://api.github.com/repos/ScottLogic/d3fc/tags","blobs_url":"https://api.github.com/repos/ScottLogic/d3fc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ScottLogic/d3fc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ScottLogic/d3fc/git/refs{/sha}","trees_url":"https://api.github.com/repos/ScottLogic/d3fc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ScottLogic/d3fc/statuses/{sha}","languages_url":"https://api.github.com/repos/ScottLogic/d3fc/languages","stargazers_url":"https://api.github.com/repos/ScottLogic/d3fc/stargazers","contributors_url":"https://api.github.com/repos/ScottLogic/d3fc/contributors","subscribers_url":"https://api.github.com/repos/ScottLogic/d3fc/subscribers","subscription_url":"https://api.github.com/repos/ScottLogic/d3fc/subscription","commits_url":"https://api.github.com/repos/ScottLogic/d3fc/commits{/sha}","git_commits_url":"https://api.github.com/repos/ScottLogic/d3fc/git/commits{/sha}","comments_url":"https://api.github.com/repos/ScottLogic/d3fc/comments{/number}","issue_comment_url":"https://api.github.com/repos/ScottLogic/d3fc/issues/comments{/number}","contents_url":"https://api.github.com/repos/ScottLogic/d3fc/contents/{+path}","compare_url":"https://api.github.com/repos/ScottLogic/d3fc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ScottLogic/d3fc/merges","archive_url":"https://api.github.com/repos/ScottLogic/d3fc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ScottLogic/d3fc/downloads","issues_url":"https://api.github.com/repos/ScottLogic/d3fc/issues{/number}","pulls_url":"https://api.github.com/repos/ScottLogic/d3fc/pulls{/number}","milestones_url":"https://api.github.com/repos/ScottLogic/d3fc/milestones{/number}","notifications_url":"https://api.github.com/repos/ScottLogic/d3fc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ScottLogic/d3fc/labels{/name}","releases_url":"https://api.github.com/repos/ScottLogic/d3fc/releases{/id}","created_at":"2014-10-06T15:03:11Z","updated_at":"2015-09-10T08:16:57Z","pushed_at":"2015-09-11T07:55:42Z","git_url":"git://github.com/ScottLogic/d3fc.git","ssh_url":"git@github.com:ScottLogic/d3fc.git","clone_url":"https://github.com/ScottLogic/d3fc.git","svn_url":"https://github.com/ScottLogic/d3fc","homepage":"http://d3fc.io/","size":6772,"stargazers_count":161,"watchers_count":161,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":40,"forks":23,"open_issues":40,"watchers":161,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ScottLogic/d3fc/pulls/518"},"html":{"href":"https://github.com/ScottLogic/d3fc/pull/518"},"issue":{"href":"https://api.github.com/repos/ScottLogic/d3fc/issues/518"},"comments":{"href":"https://api.github.com/repos/ScottLogic/d3fc/issues/518/comments"},"review_comments":{"href":"https://api.github.com/repos/ScottLogic/d3fc/pulls/518/comments"},"review_comment":{"href":"https://api.github.com/repos/ScottLogic/d3fc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ScottLogic/d3fc/pulls/518/commits"},"statuses":{"href":"https://api.github.com/repos/ScottLogic/d3fc/statuses/5b394abef161085875338965073f3317541be7da"}}}}