mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Limit amount of chart data passed to browser
Summary: Firefox has a limit of ~500,000 elements which can be passed in literal array. This amount of data is meaningless anyway because even Retina displays don't have such resolution. Limit the amount of data to mitigate browser limitations and also reduce the page size. Ensure that first and last element is passed. I considered also reducing the granularity to days but I want new repositories to have nice precise graph. Test Plan: Displayed the chart in Firefox. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3134
This commit is contained in:
parent
d391177984
commit
9a19cfb9de
1 changed files with 14 additions and 0 deletions
|
@ -51,6 +51,20 @@ final class PhabricatorFactChartController extends PhabricatorFactController {
|
|||
throw new Exception("No data to show!");
|
||||
}
|
||||
|
||||
// Limit amount of data passed to browser.
|
||||
$count = count($points);
|
||||
$limit = 2000;
|
||||
if ($count > $limit) {
|
||||
$i = 0;
|
||||
$every = ceil($count / $limit);
|
||||
foreach ($points as $epoch => $sum) {
|
||||
$i++;
|
||||
if ($i % $every && $i != $count) {
|
||||
unset($points[$epoch]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$x = array_keys($points);
|
||||
$y = array_values($points);
|
||||
|
||||
|
|
Loading…
Reference in a new issue