Skip to content

Commit

Permalink
Update ChartReportPage.jsx
Browse files Browse the repository at this point in the history
Add pan and zoom, show dot only on mouse hover
  • Loading branch information
hypoclone authored Dec 25, 2024
1 parent 582af9c commit d7ca46f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/reports/ChartReportPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
FormControl, InputLabel, Select, MenuItem, useTheme,
} from '@mui/material';
import {
CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis,
Brush, ReferenceArea, CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis,

Check failure on line 7 in src/reports/ChartReportPage.jsx

View workflow job for this annotation

GitHub Actions / build

'ReferenceArea' is defined but never used
} from 'recharts';
import ReportFilter from './components/ReportFilter';
import { formatTime } from '../common/util/formatter';
Expand All @@ -20,6 +20,9 @@ import {
import useReportStyles from './common/useReportStyles';

const ChartReportPage = () => {
const [zoomDomain, setZoomDomain] = useState({ start: 'dataMin', end: 'dataMax' });

Check failure on line 23 in src/reports/ChartReportPage.jsx

View workflow job for this annotation

GitHub Actions / build

'zoomDomain' is assigned a value but never used
const handleBrushChange = (range) => { if (range) { setZoomDomain({ start: range.startIndex, end: range.endIndex }); }};

Check failure on line 24 in src/reports/ChartReportPage.jsx

View workflow job for this annotation

GitHub Actions / build

Requires a space before '}'

Check failure on line 25 in src/reports/ChartReportPage.jsx

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed
const classes = useReportStyles();
const theme = useTheme();
const t = useTranslation();
Expand Down Expand Up @@ -161,7 +164,13 @@ const ChartReportPage = () => {
formatter={(value, key) => [value, positionAttributes[key]?.name || key]}
labelFormatter={(value) => formatTime(value, 'seconds')}
/>
<Line type="monotone" dataKey={type} stroke={theme.palette.primary.main} />
<Brush
dataKey={timeType}
height={30}
stroke={theme.palette.primary.main}
onChange={(range) => handleBrushChange(range)}
/>
<Line type="monotone" dataKey={type} stroke={theme.palette.primary.main} dot={false} activeDot={{ r: 6 }} />
</LineChart>
</ResponsiveContainer>
</div>
Expand Down

0 comments on commit d7ca46f

Please sign in to comment.