Skip to content

Commit

Permalink
Remove scroll to zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbaldwin44 committed Aug 30, 2024
1 parent aea9d63 commit 30e1541
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion locust/webui/src/components/LineChart/LineChart.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface ILineChart<ChartType> {
}

export interface ILineChartZoomEvent {
batch?: { start: number; end: number }[];
batch?: { start: number; startValue: number; end: number }[];
}

export interface ILineChartMarkers {
Expand Down
20 changes: 3 additions & 17 deletions locust/webui/src/components/LineChart/LineChart.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ export const createOptions = <ChartType extends Pick<ICharts, 'time'>>({
scatterplot,
}: ILineChart<ChartType>) => ({
title: { text: title },
dataZoom: [
{
type: 'inside',
start: 0,
end: 100,
},
],
tooltip: {
trigger: 'axis',
formatter: (params?: ILineChartTooltipFormatterParams[] | null) => {
Expand Down Expand Up @@ -138,11 +131,11 @@ export const createOptions = <ChartType extends Pick<ICharts, 'time'>>({
right: 10,
feature: {
dataZoom: {
show: true,
title: {
zoom: 'Zoom Select',
back: 'Zoom Reset',
},
yAxisIndex: false,
},
saveAsImage: {
name: title.replace(/\s+/g, '_').toLowerCase() + '_' + new Date().getTime() / 1000,
Expand Down Expand Up @@ -176,21 +169,14 @@ export const onChartZoom = (chart: ECharts) => (datazoom: unknown) => {
return;
}

const [{ start, end }] = batch;
const isZoomed = start > 0 && end < 100;
const [{ start, startValue, end }] = batch;
const isZoomed = (start > 0 && end <= 100) || startValue > 0;

chart.setOption({
dataZoom: [
{
type: 'inside',
start,
end,
},
{
type: 'slider',
show: isZoomed,
start,
end,
},
],
});
Expand Down

0 comments on commit 30e1541

Please sign in to comment.