Skip to content

Commit 33fee4e

Browse files
authored
Merge pull request #3086 from andrewbaldwin44/task/offset-graph-legend
Web UI: Offset Graph Legend so There's no Overlap on Mobile / Narrow Screens
2 parents f8cea6e + ef91abd commit 33fee4e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: locust/webui/src/components/LineChart/LineChart.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ export default function LineChart<ChartType extends IBaseChartType>({
7373
);
7474
initChart.on('datazoom', onChartZoom(initChart));
7575

76-
const handleChartResize = () => initChart.resize();
76+
const handleChartResize = () => {
77+
initChart.resize();
78+
initChart.setOption({ xAxis: { splitNumber: window.innerWidth < 900 ? 2 : 7 } });
79+
};
7780
window.addEventListener('resize', handleChartResize);
7881

7982
initChart.group = 'swarmCharts';

Diff for: locust/webui/src/components/LineChart/LineChart.utils.ts

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ export const createOptions = <ChartType extends Pick<ICharts, 'time'>>({
114114
type: 'time',
115115
min: (charts.time || [new Date().toISOString()])[0],
116116
startValue: (charts.time || [])[0],
117+
splitNumber: window.innerWidth < 900 ? 2 : 7,
118+
minInterval: 1,
117119
axisLabel: {
118120
formatter: formatTimeAxis,
119121
},
@@ -143,6 +145,9 @@ export const createOptions = <ChartType extends Pick<ICharts, 'time'>>({
143145
},
144146
},
145147
},
148+
legend: {
149+
top: 25,
150+
},
146151
});
147152

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

0 commit comments

Comments
 (0)