score:1
Accepted answer
This button has limited styling options, but you can replace it by a custom one in simple steps:
- Overwrite method which is responsible for showing the default button.
Highcharts.Chart.prototype.showResetZoom = function () {};
- Add and position a custom button with linked
chart.zoomOut
method called on click:
const App = () => {
const chartComponent = useRef(null);
const [isZoomed, setIsZoomed] = useState(false);
const [options] = useState({
chart: {
zoomType: "x",
events: {
selection: function (e) {
if (e.resetSelection) {
setIsZoomed(false);
} else {
setIsZoomed(true);
}
}
}
},
...
});
const resetZoom = () => {
if (chartComponent && chartComponent.current) {
chartComponent.current.chart.zoomOut();
}
};
return (
<div style={{ position: "relative" }}>
<HighchartsReact
ref={chartComponent}
highcharts={Highcharts}
options={options}
/>
{isZoomed && (
<Button
style={{ position: "absolute", top: 50, right: 10 }}
onClick={resetZoom}
color="primary"
>
Reset zoom
</Button>
)}
</div>
);
};
Live demo: https://codesandbox.io/s/highcharts-react-demo-forked-ssqk9?file=/demo.jsx
API Reference: https://api.highcharts.com/class-reference/Highcharts.Chart#zoomOut
Source: stackoverflow.com
Related Query
- Styling HighCharts reset Zoom button with Material UI button
- Highcharts chart click event fired on click of the reset zoom button (bug?)
- highcharts how to catch and insert logic in click reset zoom button event
- highcharts reset zoom button
- highcharts how to override reset zoom button event
- Highcharts - Hide the Reset zoom button always
- highcharts hide zoom reset button, call zoom reset programmatically
- Styling bar colors in Highcharts with a gradient issue
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- Programmatically draw rect and line in Highcharts with zoom
- Highcharts - Global configuration with common code and unique data & Headings
- How to export CSV and XLS with external button in Highcharts
- HighCharts - Set Max and Min values in zoom reset
- passing formatting JavaScript code to HighCharts with JSON
- Highcharts zoom on 2 charts - Reset zoom issue
- How to change Highcharts graph with HTML radio button input (JS/jQuery)
- I want to update my series dynamically on highcharts with a click & also bring it to the original way by clicking on an other button (#previous)
- Highcharts - Reset zoom in synchronised charts
- Highcharts series visibility with csv data source
- resetting chart title on zoom button click in highcharts
- Is there any panning facility working with zoom for highcharts
- Toggle Highcharts plotLine with button
- How to have multiple highcharts with different series data in vuejs without repeating code
- highcharts destroy selected group annotation with button
- Styling issues with Highcharts JS
- Changing highcharts crosshairs position with clicking button
- Highcharts - show markers on zoom event (selection) and hide on reset zoom. Is it possible?
- Toggle button visibility on iframe fullscreen with highcharts
- Why code of Horizonal line(y-axis) on a single in Highcharts get applied to all other charts integrated with Webdatarocks
- Highcharts cloud issue with data source when duplicating chart
More Query from same tag
- URL Link in Tooltip
- How to use specific version of external library in jsfiddle?
- Set a minimal default range for a column chart in Highcharts
- Handle touch event on Apple - Highcharts
- why I am getting undefined value in angular js
- Highcharts line chart doesn't render when sql returns more than 121 rows
- Highcharts in the Rails Assest Pipeline not Loading
- Highchart pie-basic
- highcharts. How to shade the area between two vertical lines?
- How to add secondary y-axis to highcharts
- Set backgroundColor on half of the highchart area?
- Highcharts column range dataLabels reversed
- Set line opacity in highchart line chart
- How to create a stacked chart with cumulative line using Highchart.js
- Remove month from the axisX in highcharts.js
- Looking for a line chart drill down to area chart using Highcharts
- X-Axis date fromatting in highcharts
- Highcharts view data table is showing incorrect data
- highcharts: the way to call afterPrint
- Format styles based on some conditions in highcharts
- Highcharts - Possible to change the text zoom to other wording?
- Dotted lines in highcharts.net
- How to access legendSymbols and change their shape in HighCharts
- Benchmarking HighCharts, D3 and Canvas plotting
- Highcharts, how to change hover bg color for series with multiple columns (categories)
- How to make rectangular legend in highcharts?
- Highcharts gem not working
- display two charts with IE
- Dynamic hover color in highmap
- FusionCharts Failed to draw different chart on same data source