Skip to content

Commit 36f3dbf

Browse files
Offset graph legend so theres no overlap on mobile
1 parent c74f780 commit 36f3dbf

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 : 6,
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)