Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADM-975 [frontend]: change the style of charts #1532

Merged
merged 22 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
889c057
ADM-975 [frontend]: show the all pipeline in the lead time for change…
zhou-yinyuan Jul 11, 2024
cd8f511
ADM-975 [frontend]: finish the function that user can select pipeline…
zhou-yinyuan Jul 11, 2024
a464b5f
ADM-975 [frontend]: remove debug
zhou-yinyuan Jul 11, 2024
ff18614
ADM-975 [backend]: change the lead time for change response
zhou-yinyuan Jul 11, 2024
0ab3430
Merge main to ADM-975 and resolve conflict
zhou-yinyuan Jul 12, 2024
a49d68e
ADM-975 [frontend][backend]: finish the dora metrics chart selection
zhou-yinyuan Jul 12, 2024
49ad666
ADM-975 [frontend][backend]: finish the dora metrics chart selection
zhou-yinyuan Jul 12, 2024
865db04
ADM-975 [frontend]: fix the debug
zhou-yinyuan Jul 12, 2024
2418368
Revert "ADM-975 [frontend]: fix the debug"
zhou-yinyuan Jul 12, 2024
58fa986
ADM-975 [backend]: fix the backend test coverage
zhou-yinyuan Jul 12, 2024
0e594e0
ADM-975 [frontend]: fix test coverage and cr comment
zhou-yinyuan Jul 15, 2024
e9854e5
ADM-975 [frontend]: fix issues
zhou-yinyuan Jul 15, 2024
e438008
Merge main to ADM-975
zhou-yinyuan Jul 15, 2024
42a0264
ADM-975 [frontend]: adjust the style of pipeline selector
zhou-yinyuan Jul 15, 2024
33c4e28
ADM-975 [backend]: remove the request info files
zhou-yinyuan Jul 15, 2024
81dd00b
ADM-975 [backend][frontend]: fix the backend bug and fix e2e test
zhou-yinyuan Jul 15, 2024
801ee81
ADM-975 [docs]: modify the spike
zhou-yinyuan Jul 15, 2024
90750a6
Merge branch 'main' into ADM-975
zhou-yinyuan Jul 15, 2024
6d2f73a
ADM-975 [docs]: change the readme
zhou-yinyuan Jul 15, 2024
c702230
ADM-975 [frontend]: fix issues
zhou-yinyuan Jul 16, 2024
e4b6e3f
ADM-975 [frontend]: change the style of charts
zhou-yinyuan Jul 16, 2024
d411c00
Merge branch 'main' into ADM-975
zhou-yinyuan Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion frontend/__tests__/containers/ReportStep/ReportStep.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import { addADeploymentFrequencySetting, updateDeploymentFrequencySettings } fro
import { act, render, renderHook, screen, waitFor, within } from '@testing-library/react';
import { DATA_LOADING_FAILED, DEFAULT_MESSAGE, MESSAGE } from '@src/constants/resources';
import { closeNotification } from '@src/context/notification/NotificationSlice';
import ReportStep, { resizeChart, showChart } from '@src/containers/ReportStep';
import { addNotification } from '@src/context/notification/NotificationSlice';
import { useGenerateReportEffect } from '@src/hooks/useGenerateReportEffect';
import { backStep, updateReportId } from '@src/context/stepper/StepperSlice';
import { useExportCsvEffect } from '@src/hooks/useExportCsvEffect';
import ReportStep, { showChart } from '@src/containers/ReportStep';
import { setupStore } from '../../utils/setupStoreUtil';
import userEvent from '@testing-library/user-event';
import React, { ReactNode } from 'react';
Expand Down Expand Up @@ -696,6 +696,27 @@ describe('Report Step', () => {
});
});

describe('resizeChart', () => {
beforeEach(() => {
jest.spyOn(echarts, 'init').mockImplementation(
() =>
({
setOption: jest.fn(),
resize: jest.fn(),
dispatchAction: jest.fn(),
dispose: jest.fn(),
}) as unknown as echarts.ECharts,
);
});
it('should resize', () => {
const chart = echarts.init();
const resizeFunction = resizeChart(chart);

resizeFunction();
expect(chart.resize).toHaveBeenCalledTimes(1);
});
});

describe('showChart test', () => {
const chart = {
setOption: jest.fn(),
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/containers/MetricsStep/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ export const ChartWrapper = styled('div')({
});

export const ChartContainer = styled('div')({
display: 'grid',
gridTemplateColumns: 'repeat(2, 1fr)',
gap: '1.25rem',
display: 'flex',
width: '100%',
flexWrap: 'wrap',
justifyContent: 'space-around',
marginTop: '1.25rem',
[theme.breakpoints.down('lg')]: {
gridTemplateColumns: '1fr',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import { theme } from '@src/theme';

export const StyledChartAndTitleWrapper = styled('div')({
position: 'relative',
flex: '0 0 calc(50% - 1.25rem)',
height: '25rem',
marginBottom: '1.25rem',
borderRadius: '0.75rem',
border: theme.main.cardBorder,
background: theme.main.color,
boxShadow: theme.main.cardShadow,
[theme.breakpoints.down('lg')]: {
flex: '0 0 100%',
},
});

export const ChartTitle = styled('div')({
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/containers/ReportStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ReportContent from './ReportContent';
import { useAppSelector } from '@src/hooks';
import { useEffect, useState } from 'react';
import * as echarts from 'echarts';
import { ECharts } from 'echarts';

export interface ReportStepProps {
handleSave: () => void;
Expand All @@ -36,10 +37,18 @@ export interface DateRangeRequestResult {
reportData: ReportResponseDTO | undefined;
}

export const resizeChart = (chart: ECharts) => {
return () => {
chart.resize();
};
};

export function showChart(div: HTMLDivElement | null, isFinished: boolean, options: echarts.EChartsCoreOption) {
if (div) {
const chart = echarts.init(div);
chart.setOption(options);
const resize = resizeChart(chart);
window.addEventListener('resize', resize);
return () => {
chart.dispose();
};
Expand Down
Loading