RED-8915: made some graphs stop at the current month.

This commit is contained in:
Nicoleta Panaghiu 2024-04-10 17:26:15 +03:00
parent 60977c9306
commit 5e419e8f09
4 changed files with 12 additions and 7 deletions

View File

@ -3,7 +3,7 @@ import { LicenseService } from '@services/license.service';
import { map } from 'rxjs/operators';
import { ChartDataset } from 'chart.js';
import { ChartBlue, ChartGreen, ChartRed } from '../../utils/constants';
import { getLabelsFromLicense, getLineConfig } from '../../utils/functions';
import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig } from '../../utils/functions';
import { TranslateService } from '@ngx-translate/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { size } from '@iqser/common-ui/lib/utils';
@ -48,7 +48,7 @@ export class LicenseAnalysisCapacityUsageComponent {
},
{
data: monthlyData.map(
data: getDataUntilCurrentMonth(monthlyData).map(
(month, monthIndex) =>
month.analysedFilesBytes + monthlyData.slice(0, monthIndex).reduce((acc, curr) => acc + curr.analysedFilesBytes, 0),
),

View File

@ -3,7 +3,7 @@ import { LicenseService } from '@services/license.service';
import { map } from 'rxjs/operators';
import { ChartDataset } from 'chart.js';
import { ChartBlue, ChartGreen, ChartRed } from '../../utils/constants';
import { getLabelsFromLicense, getLineConfig } from '../../utils/functions';
import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig } from '../../utils/functions';
import { TranslateService } from '@ngx-translate/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { addPaddingToArray } from '@utils/functions';
@ -58,7 +58,7 @@ export class LicensePageUsageComponent {
order: 1,
},
{
data: monthlyData.map(
data: getDataUntilCurrentMonth(monthlyData).map(
(month, monthIndex) =>
month.numberOfAnalyzedPages +
monthlyData.slice(0, monthIndex).reduce((acc, curr) => acc + curr.numberOfAnalyzedPages, 0),

View File

@ -6,7 +6,7 @@ import { map } from 'rxjs/operators';
import type { DonutChartConfig, ILicenseReport } from '@red/domain';
import { ChartDataset } from 'chart.js';
import { ChartBlack, ChartBlue, ChartGreen, ChartGrey, ChartRed } from '../../utils/constants';
import { getLabelsFromLicense, getLineConfig } from '../../utils/functions';
import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig } from '../../utils/functions';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@Component({
@ -60,7 +60,7 @@ export class LicenseRetentionCapacityComponent {
}
#getDatasets(license: ILicenseReport): ChartDataset[] {
const monthlyData = license.monthlyData;
const monthlyData = getDataUntilCurrentMonth(license.monthlyData);
return [
{

View File

@ -1,10 +1,11 @@
import dayjs, { Dayjs } from 'dayjs';
import { FillTarget } from 'chart.js';
import { addPaddingToArray, hexToRgba } from '@utils/functions';
import { ILicenseReport } from '@red/domain';
import { ILicenseData, ILicenseReport } from '@red/domain';
import { ComplexFillTarget } from 'chart.js/dist/types';
const monthNames = dayjs.monthsShort();
const currentMonth = dayjs(Date.now()).month() + 1;
export const verboseDate = (date: Dayjs) => `${monthNames[date.month()]} ${date.year()}`;
@ -49,3 +50,7 @@ export const getLabelsFromLicense = (license: ILicenseReport) => {
return result;
};
export const getDataUntilCurrentMonth = (monthlyData: ILicenseData[]) => {
return monthlyData.slice(0, currentMonth);
};