diff --git a/viz-lib/src/visualizations/chart/plotly/index.ts b/viz-lib/src/visualizations/chart/plotly/index.ts index f39d61677..b4cd3e834 100644 --- a/viz-lib/src/visualizations/chart/plotly/index.ts +++ b/viz-lib/src/visualizations/chart/plotly/index.ts @@ -8,9 +8,30 @@ import updateAxes from "./updateAxes"; import updateChartSize from "./updateChartSize"; import { prepareCustomChartData, createCustomChartRenderer } from "./customChartUtils"; +const rangeSliderIcon = { + 'width': 400, + 'height': 400, + 'path': 'M50 180h300a20 20 0 0 1 0 40H50a20 20 0 0 1 0-40z M160 200a40 40 0 1 0 -80 0a40 40 0 1 0 80 0 M320 200a40 40 0 1 0 -80 0a40 40 0 1 0 80 0', +}; + Plotly.setPlotConfig({ modeBarButtonsToRemove: ["sendDataToCloud"], - modeBarButtonsToAdd: ["togglespikelines", "v1hovermode"], + modeBarButtonsToAdd: ["togglespikelines", "v1hovermode", + { + name: 'toggleRangeslider', + title: 'Toggle rangeslider', + icon: rangeSliderIcon, + click: function(gd: any) { + if(gd?.layout?.xaxis) { + let newRangeslider: any = {}; + if (gd.layout.xaxis?.rangeslider) { + newRangeslider = null; + } + (Plotly.relayout as any)(gd, 'xaxis.rangeslider', newRangeslider); + } + } + }, + ], locale: window.navigator.language, });