{"action":"created","comment":{"url":"https://api.github.com/repos/smaato/ui-framework/pulls/comments/88496461","pull_request_review_id":9067545,"id":88496461,"diff_hunk":"@@ -0,0 +1,121 @@\n+\n+import classNames from 'classnames';\n+/* global d3 */\n+import 'd3';\n+import React, {\n+  Component,\n+  PropTypes,\n+} from 'react';\n+\n+import Box from '../box/Box.jsx';\n+import ChartDot from './chartDot/ChartDot.jsx';\n+import Heading from '../text/Heading.jsx';\n+import HorizontalLine from '../horizontalLine/HorizontalLine.jsx';\n+import LineChart from './LineChart.jsx';\n+import Progress from '../progress/Progress.jsx';\n+\n+export {\n+  default as LineChart,\n+} from './LineChart.jsx';\n+\n+export default class Chart extends Component {\n+\n+  constructor(props) {\n+    super(props);\n+\n+    this.COLORS = ['#2799C4', '#35D0A0'];\n+    this.HEIGHT = 520;\n+\n+    this.resetData();\n+  }\n+\n+  setData() {\n+    this.resetData();\n+\n+    this.props.data.forEach((dataSet, index) => {\n+      this.data.push({\n+        color: this.COLORS[index],\n+        name: this.props.legendLabelProvider(dataSet),\n+        values: [],\n+      });\n+\n+      dataSet.forEach(dataPoint => {\n+        const date = dataPoint.date;\n+        const yValue = dataPoint.value;\n+\n+        this.data[index].values.push({\n+          date,\n+          yValue,\n+        });\n+        this.minDate = Math.min(date, this.minDate) || date;\n+        this.maxDate = Math.max(date, this.maxDate) || date;\n+        this.minY = Math.min(yValue, this.minY) || yValue;\n+        this.maxY = Math.max(yValue, this.maxY) || yValue;\n+      });\n+    });\n+  }\n+\n+  resetData() {\n+    this.data = [];\n+    this.minDate = undefined;\n+    this.maxDate = undefined;\n+    this.minY = undefined;\n+    this.maxY = undefined;\n+  }\n+\n+  renderLegend() {\n+    const legendItems = this.data.map((item, index) => (\n+      <span key={index}><ChartDot color={item.color} /> {item.name}</span>\n+    ));\n+\n+    return (\n+      <div className=\"chart__legend\">{legendItems}</div>\n+    );\n+  }\n+\n+  renderLineChart() {\n+    let lineChartClasses = 'chart__lineChart';\n+    let progress;\n+\n+    if (this.props.isLoading) {\n+      lineChartClasses =\n+        classNames(lineChartClasses, 'chart__lineChart--blurred');\n+      progress = <Progress />;\n+    }\n+\n+    return (\n+      <div className={lineChartClasses}>\n+        <LineChart\n+          data={this.data}\n+          dateFormat={d3.time.days}\n+          dateRange={[this.minDate, this.maxDate]}\n+          height={this.HEIGHT}\n+          yAxisRange={[this.minY, this.maxY]}\n+        />\n+        {progress}\n+      </div>\n+    );\n+  }\n+\n+  render() {\n+    this.setData();\n+","path":"src/framework/chart/Chart.jsx","position":102,"original_position":102,"commit_id":"52112cc69a909d86630b384beabaa58e9c32bf7a","original_commit_id":"52112cc69a909d86630b384beabaa58e9c32bf7a","user":{"login":"mohsinhijazee","id":24268,"avatar_url":"https://avatars.githubusercontent.com/u/24268?v=3","gravatar_id":"","url":"https://api.github.com/users/mohsinhijazee","html_url":"https://github.com/mohsinhijazee","followers_url":"https://api.github.com/users/mohsinhijazee/followers","following_url":"https://api.github.com/users/mohsinhijazee/following{/other_user}","gists_url":"https://api.github.com/users/mohsinhijazee/gists{/gist_id}","starred_url":"https://api.github.com/users/mohsinhijazee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohsinhijazee/subscriptions","organizations_url":"https://api.github.com/users/mohsinhijazee/orgs","repos_url":"https://api.github.com/users/mohsinhijazee/repos","events_url":"https://api.github.com/users/mohsinhijazee/events{/privacy}","received_events_url":"https://api.github.com/users/mohsinhijazee/received_events","type":"User","site_admin":false},"body":"This seems bit out of place. May be `componentWillUpdate()` or constructor can be used for that. So it is called in constructor, this will take care of the initial render. For subsequent renders, I think `componentWillUpdate()` would be able to compute. As per convention, `render()` would stay clean. Just a suggestion.","created_at":"2016-11-17T16:56:06Z","updated_at":"2016-11-17T16:59:06Z","html_url":"https://github.com/smaato/ui-framework/pull/264#discussion_r88496461","pull_request_url":"https://api.github.com/repos/smaato/ui-framework/pulls/264","_links":{"self":{"href":"https://api.github.com/repos/smaato/ui-framework/pulls/comments/88496461"},"html":{"href":"https://github.com/smaato/ui-framework/pull/264#discussion_r88496461"},"pull_request":{"href":"https://api.github.com/repos/smaato/ui-framework/pulls/264"}}},"pull_request":{"url":"https://api.github.com/repos/smaato/ui-framework/pulls/264","id":94194148,"html_url":"https://github.com/smaato/ui-framework/pull/264","diff_url":"https://github.com/smaato/ui-framework/pull/264.diff","patch_url":"https://github.com/smaato/ui-framework/pull/264.patch","issue_url":"https://api.github.com/repos/smaato/ui-framework/issues/264","number":264,"state":"open","locked":false,"title":"[SDX-1035] Added Chart component with example","user":{"login":"jenslonkowski","id":3855209,"avatar_url":"https://avatars.githubusercontent.com/u/3855209?v=3","gravatar_id":"","url":"https://api.github.com/users/jenslonkowski","html_url":"https://github.com/jenslonkowski","followers_url":"https://api.github.com/users/jenslonkowski/followers","following_url":"https://api.github.com/users/jenslonkowski/following{/other_user}","gists_url":"https://api.github.com/users/jenslonkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/jenslonkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenslonkowski/subscriptions","organizations_url":"https://api.github.com/users/jenslonkowski/orgs","repos_url":"https://api.github.com/users/jenslonkowski/repos","events_url":"https://api.github.com/users/jenslonkowski/events{/privacy}","received_events_url":"https://api.github.com/users/jenslonkowski/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-17T15:53:43Z","updated_at":"2016-11-17T16:59:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be1fcdeb1cc6f6bb5294f2b7d7fcf3e7dd0ce1f8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/smaato/ui-framework/pulls/264/commits","review_comments_url":"https://api.github.com/repos/smaato/ui-framework/pulls/264/comments","review_comment_url":"https://api.github.com/repos/smaato/ui-framework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/smaato/ui-framework/issues/264/comments","statuses_url":"https://api.github.com/repos/smaato/ui-framework/statuses/52112cc69a909d86630b384beabaa58e9c32bf7a","head":{"label":"smaato:feature/SDX-1035_chart","ref":"feature/SDX-1035_chart","sha":"52112cc69a909d86630b384beabaa58e9c32bf7a","user":{"login":"smaato","id":6848742,"avatar_url":"https://avatars.githubusercontent.com/u/6848742?v=3","gravatar_id":"","url":"https://api.github.com/users/smaato","html_url":"https://github.com/smaato","followers_url":"https://api.github.com/users/smaato/followers","following_url":"https://api.github.com/users/smaato/following{/other_user}","gists_url":"https://api.github.com/users/smaato/gists{/gist_id}","starred_url":"https://api.github.com/users/smaato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smaato/subscriptions","organizations_url":"https://api.github.com/users/smaato/orgs","repos_url":"https://api.github.com/users/smaato/repos","events_url":"https://api.github.com/users/smaato/events{/privacy}","received_events_url":"https://api.github.com/users/smaato/received_events","type":"Organization","site_admin":false},"repo":{"id":41702416,"name":"ui-framework","full_name":"smaato/ui-framework","owner":{"login":"smaato","id":6848742,"avatar_url":"https://avatars.githubusercontent.com/u/6848742?v=3","gravatar_id":"","url":"https://api.github.com/users/smaato","html_url":"https://github.com/smaato","followers_url":"https://api.github.com/users/smaato/followers","following_url":"https://api.github.com/users/smaato/following{/other_user}","gists_url":"https://api.github.com/users/smaato/gists{/gist_id}","starred_url":"https://api.github.com/users/smaato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smaato/subscriptions","organizations_url":"https://api.github.com/users/smaato/orgs","repos_url":"https://api.github.com/users/smaato/repos","events_url":"https://api.github.com/users/smaato/events{/privacy}","received_events_url":"https://api.github.com/users/smaato/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/smaato/ui-framework","description":"React + Sass framework","fork":false,"url":"https://api.github.com/repos/smaato/ui-framework","forks_url":"https://api.github.com/repos/smaato/ui-framework/forks","keys_url":"https://api.github.com/repos/smaato/ui-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smaato/ui-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smaato/ui-framework/teams","hooks_url":"https://api.github.com/repos/smaato/ui-framework/hooks","issue_events_url":"https://api.github.com/repos/smaato/ui-framework/issues/events{/number}","events_url":"https://api.github.com/repos/smaato/ui-framework/events","assignees_url":"https://api.github.com/repos/smaato/ui-framework/assignees{/user}","branches_url":"https://api.github.com/repos/smaato/ui-framework/branches{/branch}","tags_url":"https://api.github.com/repos/smaato/ui-framework/tags","blobs_url":"https://api.github.com/repos/smaato/ui-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smaato/ui-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smaato/ui-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/smaato/ui-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smaato/ui-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/smaato/ui-framework/languages","stargazers_url":"https://api.github.com/repos/smaato/ui-framework/stargazers","contributors_url":"https://api.github.com/repos/smaato/ui-framework/contributors","subscribers_url":"https://api.github.com/repos/smaato/ui-framework/subscribers","subscription_url":"https://api.github.com/repos/smaato/ui-framework/subscription","commits_url":"https://api.github.com/repos/smaato/ui-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/smaato/ui-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/smaato/ui-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/smaato/ui-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/smaato/ui-framework/contents/{+path}","compare_url":"https://api.github.com/repos/smaato/ui-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smaato/ui-framework/merges","archive_url":"https://api.github.com/repos/smaato/ui-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smaato/ui-framework/downloads","issues_url":"https://api.github.com/repos/smaato/ui-framework/issues{/number}","pulls_url":"https://api.github.com/repos/smaato/ui-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/smaato/ui-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/smaato/ui-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smaato/ui-framework/labels{/name}","releases_url":"https://api.github.com/repos/smaato/ui-framework/releases{/id}","deployments_url":"https://api.github.com/repos/smaato/ui-framework/deployments","created_at":"2015-08-31T21:50:27Z","updated_at":"2016-11-01T16:23:06Z","pushed_at":"2016-11-17T15:53:43Z","git_url":"git://github.com/smaato/ui-framework.git","ssh_url":"git@github.com:smaato/ui-framework.git","clone_url":"https://github.com/smaato/ui-framework.git","svn_url":"https://github.com/smaato/ui-framework","homepage":"http://smaato.github.io/ui-framework/","size":6269,"stargazers_count":39,"watchers_count":39,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":39,"default_branch":"develop"}},"base":{"label":"smaato:develop","ref":"develop","sha":"833a2596b0412b321153714ef9788d468292e39d","user":{"login":"smaato","id":6848742,"avatar_url":"https://avatars.githubusercontent.com/u/6848742?v=3","gravatar_id":"","url":"https://api.github.com/users/smaato","html_url":"https://github.com/smaato","followers_url":"https://api.github.com/users/smaato/followers","following_url":"https://api.github.com/users/smaato/following{/other_user}","gists_url":"https://api.github.com/users/smaato/gists{/gist_id}","starred_url":"https://api.github.com/users/smaato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smaato/subscriptions","organizations_url":"https://api.github.com/users/smaato/orgs","repos_url":"https://api.github.com/users/smaato/repos","events_url":"https://api.github.com/users/smaato/events{/privacy}","received_events_url":"https://api.github.com/users/smaato/received_events","type":"Organization","site_admin":false},"repo":{"id":41702416,"name":"ui-framework","full_name":"smaato/ui-framework","owner":{"login":"smaato","id":6848742,"avatar_url":"https://avatars.githubusercontent.com/u/6848742?v=3","gravatar_id":"","url":"https://api.github.com/users/smaato","html_url":"https://github.com/smaato","followers_url":"https://api.github.com/users/smaato/followers","following_url":"https://api.github.com/users/smaato/following{/other_user}","gists_url":"https://api.github.com/users/smaato/gists{/gist_id}","starred_url":"https://api.github.com/users/smaato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smaato/subscriptions","organizations_url":"https://api.github.com/users/smaato/orgs","repos_url":"https://api.github.com/users/smaato/repos","events_url":"https://api.github.com/users/smaato/events{/privacy}","received_events_url":"https://api.github.com/users/smaato/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/smaato/ui-framework","description":"React + Sass framework","fork":false,"url":"https://api.github.com/repos/smaato/ui-framework","forks_url":"https://api.github.com/repos/smaato/ui-framework/forks","keys_url":"https://api.github.com/repos/smaato/ui-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smaato/ui-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smaato/ui-framework/teams","hooks_url":"https://api.github.com/repos/smaato/ui-framework/hooks","issue_events_url":"https://api.github.com/repos/smaato/ui-framework/issues/events{/number}","events_url":"https://api.github.com/repos/smaato/ui-framework/events","assignees_url":"https://api.github.com/repos/smaato/ui-framework/assignees{/user}","branches_url":"https://api.github.com/repos/smaato/ui-framework/branches{/branch}","tags_url":"https://api.github.com/repos/smaato/ui-framework/tags","blobs_url":"https://api.github.com/repos/smaato/ui-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smaato/ui-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smaato/ui-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/smaato/ui-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smaato/ui-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/smaato/ui-framework/languages","stargazers_url":"https://api.github.com/repos/smaato/ui-framework/stargazers","contributors_url":"https://api.github.com/repos/smaato/ui-framework/contributors","subscribers_url":"https://api.github.com/repos/smaato/ui-framework/subscribers","subscription_url":"https://api.github.com/repos/smaato/ui-framework/subscription","commits_url":"https://api.github.com/repos/smaato/ui-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/smaato/ui-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/smaato/ui-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/smaato/ui-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/smaato/ui-framework/contents/{+path}","compare_url":"https://api.github.com/repos/smaato/ui-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smaato/ui-framework/merges","archive_url":"https://api.github.com/repos/smaato/ui-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smaato/ui-framework/downloads","issues_url":"https://api.github.com/repos/smaato/ui-framework/issues{/number}","pulls_url":"https://api.github.com/repos/smaato/ui-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/smaato/ui-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/smaato/ui-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smaato/ui-framework/labels{/name}","releases_url":"https://api.github.com/repos/smaato/ui-framework/releases{/id}","deployments_url":"https://api.github.com/repos/smaato/ui-framework/deployments","created_at":"2015-08-31T21:50:27Z","updated_at":"2016-11-01T16:23:06Z","pushed_at":"2016-11-17T15:53:43Z","git_url":"git://github.com/smaato/ui-framework.git","ssh_url":"git@github.com:smaato/ui-framework.git","clone_url":"https://github.com/smaato/ui-framework.git","svn_url":"https://github.com/smaato/ui-framework","homepage":"http://smaato.github.io/ui-framework/","size":6269,"stargazers_count":39,"watchers_count":39,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":39,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/smaato/ui-framework/pulls/264"},"html":{"href":"https://github.com/smaato/ui-framework/pull/264"},"issue":{"href":"https://api.github.com/repos/smaato/ui-framework/issues/264"},"comments":{"href":"https://api.github.com/repos/smaato/ui-framework/issues/264/comments"},"review_comments":{"href":"https://api.github.com/repos/smaato/ui-framework/pulls/264/comments"},"review_comment":{"href":"https://api.github.com/repos/smaato/ui-framework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/smaato/ui-framework/pulls/264/commits"},"statuses":{"href":"https://api.github.com/repos/smaato/ui-framework/statuses/52112cc69a909d86630b384beabaa58e9c32bf7a"}}}}
{"actor":{"display_login":"mohsinhijazee"}}