{"action":"created","comment":{"url":"https://api.github.com/repos/palantir/plottable/pulls/comments/35596097","id":35596097,"diff_hunk":"@@ -431,4 +431,36 @@ describe(\"NumericAxis\", () => {\n     svg.remove();\n   });\n \n+  it(\"reasonably approximates tick label sizes with approximate measuring\", () => {\n+    var SVG_WIDTH = 500;\n+    var SVG_HEIGHT = 100;\n+\n+    [[-1, 1],\n+     [0, 10],\n+     [0, 999999999]\n+    ].forEach((domainBounds) => {\n+      var scale = new Plottable.Scales.Linear();\n+      scale.domain(domainBounds);\n+\n+      var svgApprox = TestMethods.generateSVG(SVG_WIDTH, SVG_HEIGHT);\n+      var numericAxisApprox = new Plottable.Axes.Numeric(scale, \"left\");\n+      numericAxisApprox.usesTextWidthApproximation(true);\n+      numericAxisApprox.renderTo(svgApprox);\n+      var widthApprox = (<any> numericAxisApprox)._computeWidth();\n+\n+      var svgExact = TestMethods.generateSVG(SVG_WIDTH, SVG_HEIGHT);","path":"test/axes/numericAxisTests.ts","position":21,"original_position":21,"commit_id":"19667a5f58cdf3f0d6d94db6a26e289d69833627","original_commit_id":"19667a5f58cdf3f0d6d94db6a26e289d69833627","user":{"login":"PeterFaiman","id":6878538,"avatar_url":"https://avatars.githubusercontent.com/u/6878538?v=3","gravatar_id":"","url":"https://api.github.com/users/PeterFaiman","html_url":"https://github.com/PeterFaiman","followers_url":"https://api.github.com/users/PeterFaiman/followers","following_url":"https://api.github.com/users/PeterFaiman/following{/other_user}","gists_url":"https://api.github.com/users/PeterFaiman/gists{/gist_id}","starred_url":"https://api.github.com/users/PeterFaiman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeterFaiman/subscriptions","organizations_url":"https://api.github.com/users/PeterFaiman/orgs","repos_url":"https://api.github.com/users/PeterFaiman/repos","events_url":"https://api.github.com/users/PeterFaiman/events{/privacy}","received_events_url":"https://api.github.com/users/PeterFaiman/received_events","type":"User","site_admin":false},"body":"Can I just render over and over to 1 SVG and have stuff work? I wasn't sure.","created_at":"2015-07-27T22:39:06Z","updated_at":"2015-07-27T22:39:06Z","html_url":"https://github.com/palantir/plottable/pull/2485#discussion_r35596097","pull_request_url":"https://api.github.com/repos/palantir/plottable/pulls/2485","_links":{"self":{"href":"https://api.github.com/repos/palantir/plottable/pulls/comments/35596097"},"html":{"href":"https://github.com/palantir/plottable/pull/2485#discussion_r35596097"},"pull_request":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2485"}}},"pull_request":{"url":"https://api.github.com/repos/palantir/plottable/pulls/2485","id":40512717,"html_url":"https://github.com/palantir/plottable/pull/2485","diff_url":"https://github.com/palantir/plottable/pull/2485.diff","patch_url":"https://github.com/palantir/plottable/pull/2485.patch","issue_url":"https://api.github.com/repos/palantir/plottable/issues/2485","number":2485,"state":"open","locked":false,"title":"Add a flag on Numeric axes to approximate the width of the labels.","user":{"login":"PeterFaiman","id":6878538,"avatar_url":"https://avatars.githubusercontent.com/u/6878538?v=3","gravatar_id":"","url":"https://api.github.com/users/PeterFaiman","html_url":"https://github.com/PeterFaiman","followers_url":"https://api.github.com/users/PeterFaiman/followers","following_url":"https://api.github.com/users/PeterFaiman/following{/other_user}","gists_url":"https://api.github.com/users/PeterFaiman/gists{/gist_id}","starred_url":"https://api.github.com/users/PeterFaiman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeterFaiman/subscriptions","organizations_url":"https://api.github.com/users/PeterFaiman/orgs","repos_url":"https://api.github.com/users/PeterFaiman/repos","events_url":"https://api.github.com/users/PeterFaiman/events{/privacy}","received_events_url":"https://api.github.com/users/PeterFaiman/received_events","type":"User","site_admin":false},"body":"Part of #2433\r\n\r\nApproximating the width reduces measure() calls, which are expensive. Using a simple approximation speeds things up on my machine by 30% or more, depending on how many labels are measured to render the graph.\r\n\r\nThis approximation is particularly suited to the Numeric axis, as numbers are all basically the same size in most fonts.\r\n\r\nA test running 20 graphs takes between 400 and 500 ms to run.\r\n\r\n![head-20](https://cloud.githubusercontent.com/assets/6878538/8814096/c4231d22-2fbd-11e5-8d65-fd4ef0a29f00.png)\r\n\r\nWith approximate text measuring, it takes between 250 and 350 ms.\r\n\r\n![branch-20](https://cloud.githubusercontent.com/assets/6878538/8814105/dacb4a2c-2fbd-11e5-96ad-050489c051b8.png)\r\n\r\nThis is definitely due to the measurement calls, as can be seen in the below timeline of a single graph render.\r\n\r\n![head-1](https://cloud.githubusercontent.com/assets/6878538/8814113/e8b5abe6-2fbd-11e5-97fa-f502b7b3caec.png)\r\n\r\nAnd the corresponding improvement.\r\n\r\n![branch-1](https://cloud.githubusercontent.com/assets/6878538/8814123/0084b866-2fbe-11e5-93c1-f648df50e719.png)\r\n","created_at":"2015-07-21T22:34:50Z","updated_at":"2015-07-27T22:39:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"92bdcf20ea2fcc6a20b21d124dfa379bf2078fa3","assignee":{"login":"bluong","id":1448299,"avatar_url":"https://avatars.githubusercontent.com/u/1448299?v=3","gravatar_id":"","url":"https://api.github.com/users/bluong","html_url":"https://github.com/bluong","followers_url":"https://api.github.com/users/bluong/followers","following_url":"https://api.github.com/users/bluong/following{/other_user}","gists_url":"https://api.github.com/users/bluong/gists{/gist_id}","starred_url":"https://api.github.com/users/bluong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluong/subscriptions","organizations_url":"https://api.github.com/users/bluong/orgs","repos_url":"https://api.github.com/users/bluong/repos","events_url":"https://api.github.com/users/bluong/events{/privacy}","received_events_url":"https://api.github.com/users/bluong/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/palantir/plottable/pulls/2485/commits","review_comments_url":"https://api.github.com/repos/palantir/plottable/pulls/2485/comments","review_comment_url":"https://api.github.com/repos/palantir/plottable/pulls/comments{/number}","comments_url":"https://api.github.com/repos/palantir/plottable/issues/2485/comments","statuses_url":"https://api.github.com/repos/palantir/plottable/statuses/19667a5f58cdf3f0d6d94db6a26e289d69833627","head":{"label":"PeterFaiman:approximate-text-width","ref":"approximate-text-width","sha":"19667a5f58cdf3f0d6d94db6a26e289d69833627","user":{"login":"PeterFaiman","id":6878538,"avatar_url":"https://avatars.githubusercontent.com/u/6878538?v=3","gravatar_id":"","url":"https://api.github.com/users/PeterFaiman","html_url":"https://github.com/PeterFaiman","followers_url":"https://api.github.com/users/PeterFaiman/followers","following_url":"https://api.github.com/users/PeterFaiman/following{/other_user}","gists_url":"https://api.github.com/users/PeterFaiman/gists{/gist_id}","starred_url":"https://api.github.com/users/PeterFaiman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeterFaiman/subscriptions","organizations_url":"https://api.github.com/users/PeterFaiman/orgs","repos_url":"https://api.github.com/users/PeterFaiman/repos","events_url":"https://api.github.com/users/PeterFaiman/events{/privacy}","received_events_url":"https://api.github.com/users/PeterFaiman/received_events","type":"User","site_admin":false},"repo":{"id":38450886,"name":"plottable","full_name":"PeterFaiman/plottable","owner":{"login":"PeterFaiman","id":6878538,"avatar_url":"https://avatars.githubusercontent.com/u/6878538?v=3","gravatar_id":"","url":"https://api.github.com/users/PeterFaiman","html_url":"https://github.com/PeterFaiman","followers_url":"https://api.github.com/users/PeterFaiman/followers","following_url":"https://api.github.com/users/PeterFaiman/following{/other_user}","gists_url":"https://api.github.com/users/PeterFaiman/gists{/gist_id}","starred_url":"https://api.github.com/users/PeterFaiman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeterFaiman/subscriptions","organizations_url":"https://api.github.com/users/PeterFaiman/orgs","repos_url":"https://api.github.com/users/PeterFaiman/repos","events_url":"https://api.github.com/users/PeterFaiman/events{/privacy}","received_events_url":"https://api.github.com/users/PeterFaiman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PeterFaiman/plottable","description":"A library of modular chart components, built on D3","fork":true,"url":"https://api.github.com/repos/PeterFaiman/plottable","forks_url":"https://api.github.com/repos/PeterFaiman/plottable/forks","keys_url":"https://api.github.com/repos/PeterFaiman/plottable/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PeterFaiman/plottable/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PeterFaiman/plottable/teams","hooks_url":"https://api.github.com/repos/PeterFaiman/plottable/hooks","issue_events_url":"https://api.github.com/repos/PeterFaiman/plottable/issues/events{/number}","events_url":"https://api.github.com/repos/PeterFaiman/plottable/events","assignees_url":"https://api.github.com/repos/PeterFaiman/plottable/assignees{/user}","branches_url":"https://api.github.com/repos/PeterFaiman/plottable/branches{/branch}","tags_url":"https://api.github.com/repos/PeterFaiman/plottable/tags","blobs_url":"https://api.github.com/repos/PeterFaiman/plottable/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PeterFaiman/plottable/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PeterFaiman/plottable/git/refs{/sha}","trees_url":"https://api.github.com/repos/PeterFaiman/plottable/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PeterFaiman/plottable/statuses/{sha}","languages_url":"https://api.github.com/repos/PeterFaiman/plottable/languages","stargazers_url":"https://api.github.com/repos/PeterFaiman/plottable/stargazers","contributors_url":"https://api.github.com/repos/PeterFaiman/plottable/contributors","subscribers_url":"https://api.github.com/repos/PeterFaiman/plottable/subscribers","subscription_url":"https://api.github.com/repos/PeterFaiman/plottable/subscription","commits_url":"https://api.github.com/repos/PeterFaiman/plottable/commits{/sha}","git_commits_url":"https://api.github.com/repos/PeterFaiman/plottable/git/commits{/sha}","comments_url":"https://api.github.com/repos/PeterFaiman/plottable/comments{/number}","issue_comment_url":"https://api.github.com/repos/PeterFaiman/plottable/issues/comments{/number}","contents_url":"https://api.github.com/repos/PeterFaiman/plottable/contents/{+path}","compare_url":"https://api.github.com/repos/PeterFaiman/plottable/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PeterFaiman/plottable/merges","archive_url":"https://api.github.com/repos/PeterFaiman/plottable/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PeterFaiman/plottable/downloads","issues_url":"https://api.github.com/repos/PeterFaiman/plottable/issues{/number}","pulls_url":"https://api.github.com/repos/PeterFaiman/plottable/pulls{/number}","milestones_url":"https://api.github.com/repos/PeterFaiman/plottable/milestones{/number}","notifications_url":"https://api.github.com/repos/PeterFaiman/plottable/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PeterFaiman/plottable/labels{/name}","releases_url":"https://api.github.com/repos/PeterFaiman/plottable/releases{/id}","created_at":"2015-07-02T18:53:01Z","updated_at":"2015-07-02T18:53:02Z","pushed_at":"2015-07-25T02:45:57Z","git_url":"git://github.com/PeterFaiman/plottable.git","ssh_url":"git@github.com:PeterFaiman/plottable.git","clone_url":"https://github.com/PeterFaiman/plottable.git","svn_url":"https://github.com/PeterFaiman/plottable","homepage":"plottablejs.org","size":54691,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","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":"develop"}},"base":{"label":"palantir:develop","ref":"develop","sha":"1e6d843e52dc8ce937c8a8f7d914e2cc0c950885","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-27T05:18:15Z","pushed_at":"2015-07-27T22:32:16Z","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":128272,"stargazers_count":631,"watchers_count":631,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":148,"forks":59,"open_issues":148,"watchers":631,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2485"},"html":{"href":"https://github.com/palantir/plottable/pull/2485"},"issue":{"href":"https://api.github.com/repos/palantir/plottable/issues/2485"},"comments":{"href":"https://api.github.com/repos/palantir/plottable/issues/2485/comments"},"review_comments":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2485/comments"},"review_comment":{"href":"https://api.github.com/repos/palantir/plottable/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2485/commits"},"statuses":{"href":"https://api.github.com/repos/palantir/plottable/statuses/19667a5f58cdf3f0d6d94db6a26e289d69833627"}}}}