Skip to content

Web UI: Offset Graph Legend so There's no Overlap on Mobile / Narrow Screens #3086

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

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion locust/webui/src/components/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export default function LineChart<ChartType extends IBaseChartType>({
);
initChart.on('datazoom', onChartZoom(initChart));

const handleChartResize = () => initChart.resize();
const handleChartResize = () => {
initChart.resize();
initChart.setOption({ xAxis: { splitNumber: window.innerWidth < 900 ? 2 : 7 } });
};
window.addEventListener('resize', handleChartResize);

initChart.group = 'swarmCharts';
Expand Down
5 changes: 5 additions & 0 deletions locust/webui/src/components/LineChart/LineChart.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export const createOptions = <ChartType extends Pick<ICharts, 'time'>>({
type: 'time',
min: (charts.time || [new Date().toISOString()])[0],
startValue: (charts.time || [])[0],
splitNumber: window.innerWidth < 900 ? 2 : 7,
minInterval: 1,
axisLabel: {
formatter: formatTimeAxis,
},
Expand Down Expand Up @@ -143,6 +145,9 @@ export const createOptions = <ChartType extends Pick<ICharts, 'time'>>({
},
},
},
legend: {
top: 25,
},
});

export const createMarkLine = <ChartType extends Pick<ICharts, 'markers'>>(charts: ChartType) => ({
Expand Down