@hisptz/react-ui
Version:
A collection of reusable complex DHIS2 react ui components.
43 lines (39 loc) • 1.04 kB
JavaScript
import { uid } from "@hisptz/dhis2-utils";
import HighCharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import React, { forwardRef, useRef } from "react";
import ChartDownloadMenu from "./components/DownloadMenu";
import { useChart } from "./hooks/useChart";
import "./styles/custom-highchart.css";
export * from "./services/export";
export { ChartDownloadMenu };
function ChartAnalytics(_ref, ref) {
let {
analytics,
config,
containerProps
} = _ref;
const id = useRef("".concat(uid(), "-chart-item"));
const {
chart
} = useChart({
id: id.current,
analytics,
config
});
if (!chart) {
return null;
}
return /*#__PURE__*/React.createElement(HighchartsReact, {
immutable: true,
ref: ref,
containerProps: {
id: id.current,
...(containerProps !== null && containerProps !== void 0 ? containerProps : {})
},
highcharts: HighCharts,
options: { ...chart
}
});
}
export default /*#__PURE__*/forwardRef(ChartAnalytics);