{"action":"created","comment":{"url":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/comments/77544504","id":77544504,"diff_hunk":"@@ -0,0 +1,186 @@\n+/*global document:false */\n+\n+import React, { PropTypes } from \"react\";\n+import { merge, assign, isEmpty } from \"lodash\";\n+import VictoryLabel from \"../victory-label/victory-label\";\n+import VictoryContainer from \"../victory-container/victory-container\";\n+import Point from \"../point/point\"; // it should be replaced\n+\n+const defaultFontStyle = {\n+  fontSize: 14,\n+  fontFamily: \"'Gill Sans', 'Gill Sans MT', 'Ser­avek', 'Trebuchet MS', sans-serif\",\n+  color: \"#252525\",\n+  backgroundColor: \"#d9d9d9\",\n+  stroke: \"transparent\"\n+};\n+\n+const defaultLegendStyle = {\n+  height: 200,\n+  width: 300,\n+  padding: 20\n+};\n+\n+const defaultLegendData = [{\n+  name: \"Series 1\",\n+  symbol: {\n+    type: \"circle\",\n+    style: {\n+      fill: \"red\"\n+    }\n+  }\n+}, {\n+  name: \"Series 2\",\n+  symbol: {\n+    type: \"diamond\",\n+    style: {\n+      fill: \"blue\"\n+    }\n+  }\n+}];\n+\n+export default class VictoryLegend extends React.Component {\n+  static propTypes = {\n+    x: PropTypes.number.isRequired,\n+    y: PropTypes.number.isRequired,\n+    height: PropTypes.number.isRequired,\n+    width: PropTypes.number.isRequired,\n+    orientation: PropTypes.string,\n+    data: PropTypes.arrayOf(\n+      PropTypes.shape({\n+        name: PropTypes.string.isRequired,\n+        label: PropTypes.object,\n+        symbol: PropTypes.object\n+      })\n+    ),\n+    columnItemSpacing: PropTypes.number,\n+    rowItemSpacing: PropTypes.number,\n+    groupComponent: PropTypes.element,\n+    standalone: PropTypes.bool,\n+    style: PropTypes.object\n+  };\n+\n+  static defaultProps = {\n+    x: 0,\n+    y: 0,\n+    height: 100,\n+    width: 150,\n+    orientation: \"vertical\",\n+    columnItemSpacing: 10,\n+    rowItemSpacing: 8,\n+    symbolComponent: <Point/>,\n+    labelComponent: <VictoryLabel/>,\n+    containerComponent: <VictoryContainer/>,\n+    groupComponent: <g/>,\n+    standalone: true\n+  };\n+\n+  getFontStyles(props) {\n+    return merge({}, defaultFontStyle, props.label);\n+  }\n+\n+  getLegendStyle(props) {\n+    return {\n+      style: merge({}, defaultLegendStyle, props.style)\n+    };\n+  }\n+\n+  // it should be changed to approximateTextSize\n+  getLabelBbox(text, font) {\n+    const body = document.body;\n+    const container = document.createElement(\"svg\");\n+    const label = document.createElement(\"text\");\n+\n+    label.innerText = text;\n+    label.setAttribute(\"style\",\n+      `fill: ${font.color};\n+      font-size: ${font.fontSize}px;\n+      font-family: ${font.fontFamily};\n+      background-color: ${font.backgroundColor};\n+      stroke: ${font.stroke};\n+      top: -10000px;\n+      position: absolute;`\n+    );\n+    body.appendChild(container);\n+    container.appendChild(label);\n+\n+    const bBox = label.getBoundingClientRect();\n+    body.removeChild(container);\n+\n+    return bBox;\n+  }\n+\n+  renderContainer(props, group) {\n+    return React.cloneElement(\n+      props.containerComponent,\n+      this.getLegendStyle(props),\n+      group\n+    );\n+  }\n+\n+  renderGroup(children) {\n+    return React.cloneElement(\n+      this.props.groupComponent,\n+      { role: \"presentation\" },\n+      children\n+    );\n+  }\n+\n+  render() {\n+    let yPadding = 0;\n+    let xPadding = 0;\n+    const props = this.props;\n+    const itemXPosition = [];\n+    const symbolComponents = [];\n+    const labelComponents = [];\n+    const { symbolComponent, labelComponent } = props;\n+    const data = isEmpty(props.data) ? defaultLegendData : props.data;\n+\n+    data.forEach((series, index) => {\n+      const font = this.getFontStyles(series);\n+      const symbolSize = font.fontSize;\n+      const hPadding = symbolSize * 0.87;\n+      const yPos = props.y + index * yPadding;\n+      const labelSymbolPadding = symbolSize * 1.5 + props.columnItemSpacing;\n+\n+      if (props.orientation === \"horizontal\") {\n+        itemXPosition.push(xPadding);","path":"src/victory-legend/victory-legend.js","position":146,"original_position":146,"commit_id":"e203fe08858910d57ccce8b28a9d5c39eadf68c1","original_commit_id":"e203fe08858910d57ccce8b28a9d5c39eadf68c1","user":{"login":"boygirl","id":3719995,"avatar_url":"https://avatars.githubusercontent.com/u/3719995?v=3","gravatar_id":"","url":"https://api.github.com/users/boygirl","html_url":"https://github.com/boygirl","followers_url":"https://api.github.com/users/boygirl/followers","following_url":"https://api.github.com/users/boygirl/following{/other_user}","gists_url":"https://api.github.com/users/boygirl/gists{/gist_id}","starred_url":"https://api.github.com/users/boygirl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boygirl/subscriptions","organizations_url":"https://api.github.com/users/boygirl/orgs","repos_url":"https://api.github.com/users/boygirl/repos","events_url":"https://api.github.com/users/boygirl/events{/privacy}","received_events_url":"https://api.github.com/users/boygirl/received_events","type":"User","site_admin":false},"body":"assign by array index rather than `.push` for perf.","created_at":"2016-09-05T16:53:21Z","updated_at":"2016-09-05T16:53:21Z","html_url":"https://github.com/FormidableLabs/victory-core/pull/116#discussion_r77544504","pull_request_url":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/116","_links":{"self":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/comments/77544504"},"html":{"href":"https://github.com/FormidableLabs/victory-core/pull/116#discussion_r77544504"},"pull_request":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/116"}}},"pull_request":{"url":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/116","id":82531252,"html_url":"https://github.com/FormidableLabs/victory-core/pull/116","diff_url":"https://github.com/FormidableLabs/victory-core/pull/116.diff","patch_url":"https://github.com/FormidableLabs/victory-core/pull/116.patch","issue_url":"https://api.github.com/repos/FormidableLabs/victory-core/issues/116","number":116,"state":"open","locked":false,"title":"Add initial victory-legend","user":{"login":"janesh-travolta","id":21217966,"avatar_url":"https://avatars.githubusercontent.com/u/21217966?v=3","gravatar_id":"","url":"https://api.github.com/users/janesh-travolta","html_url":"https://github.com/janesh-travolta","followers_url":"https://api.github.com/users/janesh-travolta/followers","following_url":"https://api.github.com/users/janesh-travolta/following{/other_user}","gists_url":"https://api.github.com/users/janesh-travolta/gists{/gist_id}","starred_url":"https://api.github.com/users/janesh-travolta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janesh-travolta/subscriptions","organizations_url":"https://api.github.com/users/janesh-travolta/orgs","repos_url":"https://api.github.com/users/janesh-travolta/repos","events_url":"https://api.github.com/users/janesh-travolta/events{/privacy}","received_events_url":"https://api.github.com/users/janesh-travolta/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-24T12:16:44Z","updated_at":"2016-09-05T16:53:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a51acb97e9621e50edeb7a31c0329687327b3e57","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/116/commits","review_comments_url":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/116/comments","review_comment_url":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FormidableLabs/victory-core/issues/116/comments","statuses_url":"https://api.github.com/repos/FormidableLabs/victory-core/statuses/e203fe08858910d57ccce8b28a9d5c39eadf68c1","head":{"label":"janesh-travolta:victory-legend","ref":"victory-legend","sha":"e203fe08858910d57ccce8b28a9d5c39eadf68c1","user":{"login":"janesh-travolta","id":21217966,"avatar_url":"https://avatars.githubusercontent.com/u/21217966?v=3","gravatar_id":"","url":"https://api.github.com/users/janesh-travolta","html_url":"https://github.com/janesh-travolta","followers_url":"https://api.github.com/users/janesh-travolta/followers","following_url":"https://api.github.com/users/janesh-travolta/following{/other_user}","gists_url":"https://api.github.com/users/janesh-travolta/gists{/gist_id}","starred_url":"https://api.github.com/users/janesh-travolta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janesh-travolta/subscriptions","organizations_url":"https://api.github.com/users/janesh-travolta/orgs","repos_url":"https://api.github.com/users/janesh-travolta/repos","events_url":"https://api.github.com/users/janesh-travolta/events{/privacy}","received_events_url":"https://api.github.com/users/janesh-travolta/received_events","type":"User","site_admin":false},"repo":{"id":66455209,"name":"victory-core","full_name":"janesh-travolta/victory-core","owner":{"login":"janesh-travolta","id":21217966,"avatar_url":"https://avatars.githubusercontent.com/u/21217966?v=3","gravatar_id":"","url":"https://api.github.com/users/janesh-travolta","html_url":"https://github.com/janesh-travolta","followers_url":"https://api.github.com/users/janesh-travolta/followers","following_url":"https://api.github.com/users/janesh-travolta/following{/other_user}","gists_url":"https://api.github.com/users/janesh-travolta/gists{/gist_id}","starred_url":"https://api.github.com/users/janesh-travolta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janesh-travolta/subscriptions","organizations_url":"https://api.github.com/users/janesh-travolta/orgs","repos_url":"https://api.github.com/users/janesh-travolta/repos","events_url":"https://api.github.com/users/janesh-travolta/events{/privacy}","received_events_url":"https://api.github.com/users/janesh-travolta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/janesh-travolta/victory-core","description":"Shared libraries and components for Victory","fork":true,"url":"https://api.github.com/repos/janesh-travolta/victory-core","forks_url":"https://api.github.com/repos/janesh-travolta/victory-core/forks","keys_url":"https://api.github.com/repos/janesh-travolta/victory-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/janesh-travolta/victory-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/janesh-travolta/victory-core/teams","hooks_url":"https://api.github.com/repos/janesh-travolta/victory-core/hooks","issue_events_url":"https://api.github.com/repos/janesh-travolta/victory-core/issues/events{/number}","events_url":"https://api.github.com/repos/janesh-travolta/victory-core/events","assignees_url":"https://api.github.com/repos/janesh-travolta/victory-core/assignees{/user}","branches_url":"https://api.github.com/repos/janesh-travolta/victory-core/branches{/branch}","tags_url":"https://api.github.com/repos/janesh-travolta/victory-core/tags","blobs_url":"https://api.github.com/repos/janesh-travolta/victory-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/janesh-travolta/victory-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/janesh-travolta/victory-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/janesh-travolta/victory-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/janesh-travolta/victory-core/statuses/{sha}","languages_url":"https://api.github.com/repos/janesh-travolta/victory-core/languages","stargazers_url":"https://api.github.com/repos/janesh-travolta/victory-core/stargazers","contributors_url":"https://api.github.com/repos/janesh-travolta/victory-core/contributors","subscribers_url":"https://api.github.com/repos/janesh-travolta/victory-core/subscribers","subscription_url":"https://api.github.com/repos/janesh-travolta/victory-core/subscription","commits_url":"https://api.github.com/repos/janesh-travolta/victory-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/janesh-travolta/victory-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/janesh-travolta/victory-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/janesh-travolta/victory-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/janesh-travolta/victory-core/contents/{+path}","compare_url":"https://api.github.com/repos/janesh-travolta/victory-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/janesh-travolta/victory-core/merges","archive_url":"https://api.github.com/repos/janesh-travolta/victory-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/janesh-travolta/victory-core/downloads","issues_url":"https://api.github.com/repos/janesh-travolta/victory-core/issues{/number}","pulls_url":"https://api.github.com/repos/janesh-travolta/victory-core/pulls{/number}","milestones_url":"https://api.github.com/repos/janesh-travolta/victory-core/milestones{/number}","notifications_url":"https://api.github.com/repos/janesh-travolta/victory-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/janesh-travolta/victory-core/labels{/name}","releases_url":"https://api.github.com/repos/janesh-travolta/victory-core/releases{/id}","deployments_url":"https://api.github.com/repos/janesh-travolta/victory-core/deployments","created_at":"2016-08-24T10:33:01Z","updated_at":"2016-08-24T10:33:03Z","pushed_at":"2016-08-31T14:03:00Z","git_url":"git://github.com/janesh-travolta/victory-core.git","ssh_url":"git@github.com:janesh-travolta/victory-core.git","clone_url":"https://github.com/janesh-travolta/victory-core.git","svn_url":"https://github.com/janesh-travolta/victory-core","homepage":"http://formidable.com/open-source/victory/","size":6960,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"FormidableLabs:master","ref":"master","sha":"4ca319aed4eb253573f1f47a5d6e7ff0dc446376","user":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":51957189,"name":"victory-core","full_name":"FormidableLabs/victory-core","owner":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FormidableLabs/victory-core","description":"Shared libraries and components for Victory","fork":false,"url":"https://api.github.com/repos/FormidableLabs/victory-core","forks_url":"https://api.github.com/repos/FormidableLabs/victory-core/forks","keys_url":"https://api.github.com/repos/FormidableLabs/victory-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FormidableLabs/victory-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FormidableLabs/victory-core/teams","hooks_url":"https://api.github.com/repos/FormidableLabs/victory-core/hooks","issue_events_url":"https://api.github.com/repos/FormidableLabs/victory-core/issues/events{/number}","events_url":"https://api.github.com/repos/FormidableLabs/victory-core/events","assignees_url":"https://api.github.com/repos/FormidableLabs/victory-core/assignees{/user}","branches_url":"https://api.github.com/repos/FormidableLabs/victory-core/branches{/branch}","tags_url":"https://api.github.com/repos/FormidableLabs/victory-core/tags","blobs_url":"https://api.github.com/repos/FormidableLabs/victory-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FormidableLabs/victory-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FormidableLabs/victory-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/FormidableLabs/victory-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FormidableLabs/victory-core/statuses/{sha}","languages_url":"https://api.github.com/repos/FormidableLabs/victory-core/languages","stargazers_url":"https://api.github.com/repos/FormidableLabs/victory-core/stargazers","contributors_url":"https://api.github.com/repos/FormidableLabs/victory-core/contributors","subscribers_url":"https://api.github.com/repos/FormidableLabs/victory-core/subscribers","subscription_url":"https://api.github.com/repos/FormidableLabs/victory-core/subscription","commits_url":"https://api.github.com/repos/FormidableLabs/victory-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/FormidableLabs/victory-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/FormidableLabs/victory-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/FormidableLabs/victory-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/FormidableLabs/victory-core/contents/{+path}","compare_url":"https://api.github.com/repos/FormidableLabs/victory-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FormidableLabs/victory-core/merges","archive_url":"https://api.github.com/repos/FormidableLabs/victory-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FormidableLabs/victory-core/downloads","issues_url":"https://api.github.com/repos/FormidableLabs/victory-core/issues{/number}","pulls_url":"https://api.github.com/repos/FormidableLabs/victory-core/pulls{/number}","milestones_url":"https://api.github.com/repos/FormidableLabs/victory-core/milestones{/number}","notifications_url":"https://api.github.com/repos/FormidableLabs/victory-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FormidableLabs/victory-core/labels{/name}","releases_url":"https://api.github.com/repos/FormidableLabs/victory-core/releases{/id}","deployments_url":"https://api.github.com/repos/FormidableLabs/victory-core/deployments","created_at":"2016-02-17T21:37:42Z","updated_at":"2016-08-15T19:07:42Z","pushed_at":"2016-09-05T06:33:46Z","git_url":"git://github.com/FormidableLabs/victory-core.git","ssh_url":"git@github.com:FormidableLabs/victory-core.git","clone_url":"https://github.com/FormidableLabs/victory-core.git","svn_url":"https://github.com/FormidableLabs/victory-core","homepage":"http://formidable.com/open-source/victory/","size":7106,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":12,"forks":15,"open_issues":12,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/116"},"html":{"href":"https://github.com/FormidableLabs/victory-core/pull/116"},"issue":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/issues/116"},"comments":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/FormidableLabs/victory-core/statuses/e203fe08858910d57ccce8b28a9d5c39eadf68c1"}}}}
{"actor":{"display_login":"boygirl"}}