Skip to content

Commit

Permalink
Feature/update vertical domain #372
Browse files Browse the repository at this point in the history
Signed-off-by: Jovan Cvetkovic <[email protected]>
  • Loading branch information
jovancvetkovic3006 committed Feb 3, 2023
1 parent 99daddd commit 31a5d5c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions public/pages/Overview/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,19 @@ export function getVisualizationSpec(description: string, data: any, layers: any
};
}

/**
* Recalculates vertical domain range to add a bit of space
* so that the topmost items in the chart are not clipped
* @param {any} data
* @param {string} timeUnit
*/
export const getYDomainRange = (data: any[], timeUnit: string): number[] => {
data = data.filter((item) => item.finding === 1);

let dateFormat = 'mm';
const timeUnitSize = timeUnit.match(/.*(seconds|minutes|hours|date|month|year)$/);
if (timeUnitSize) {
if (timeUnitSize && timeUnitSize[1]) {
dateFormat = `${timeUnitSize[1][0]}${timeUnitSize[1][0]}`;
}
if (timeUnitSize && timeUnitSize[1]) {
dateFormat = `${timeUnitSize[1][0]}${timeUnitSize[1][0]}`;
}
let dataGroups = _.groupBy(data, (item) => moment(item.time).format(dateFormat));
const domainMax = _.maxBy(Object.values(dataGroups), (group) => group.length) || [];
Expand Down

0 comments on commit 31a5d5c

Please sign in to comment.