react-jsx-highstock
Version:
Highcharts (including Highstock) charts built using React components
41 lines • 948 B
JavaScript
import * as React from 'react';
import { useEffect } from 'react';
import { useModifiedProps, useChart } from 'react-jsx-highcharts';
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
const Scrollbar = ({
children,
enabled = true,
...restProps
}) => {
const chart = useChart();
useEffect(() => {
return () => {
try {
updateScrollbar({
enabled: false
}, chart);
} catch {
// ignore as chart might have been already unmounted
}
};
}, []);
const modifiedProps = useModifiedProps({
enabled,
...restProps
});
useEffect(() => {
if (modifiedProps !== false) {
updateScrollbar(modifiedProps, chart);
}
});
if (!children) return null;
return /*#__PURE__*/_jsx(_Fragment, {
children: children
});
};
const updateScrollbar = (config, chart) => {
chart.update({
scrollbar: config
}, true);
};
export default Scrollbar;