diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-11 18:13:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-11 18:13:01 +0300 |
commit | 046d6f52772ada2e08af58627f03bc18e0c932b5 (patch) | |
tree | 798d9218ecbc945593bc7d592199e78c613b9b4d /app/assets/javascripts/analytics | |
parent | cb787abec6e64a220b2807469023f4de210dac10 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/analytics')
-rw-r--r-- | app/assets/javascripts/analytics/shared/utils.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/assets/javascripts/analytics/shared/utils.js b/app/assets/javascripts/analytics/shared/utils.js index c83000e0be7..f55ef99964e 100644 --- a/app/assets/javascripts/analytics/shared/utils.js +++ b/app/assets/javascripts/analytics/shared/utils.js @@ -50,3 +50,22 @@ export const extractPaginationQueryParameters = (url = '') => { page: page?.value || null, }; }; + +export const getDataZoomOption = ({ + totalItems = 0, + maxItemsPerPage = 40, + dataZoom = [{ type: 'slider', bottom: 10, start: 0 }], +}) => { + if (totalItems <= maxItemsPerPage) { + return {}; + } + + const intervalEnd = Math.ceil((maxItemsPerPage / totalItems) * 100); + + return dataZoom.map((item) => { + return { + ...item, + end: intervalEnd, + }; + }); +}; |