@hisptz/react-ui
Version:
A collection of reusable complex DHIS2 react ui components.
36 lines (34 loc) • 1.69 kB
JavaScript
import HighChartsExportCSV from "highcharts/modules/export-data";
import HighChartsExport from "highcharts/modules/exporting";
import HighChartsFullScreen from "highcharts/modules/full-screen";
export function setupHighchartsModules(highcharts) {
HighChartsExport(highcharts);
HighChartsExportCSV(highcharts);
HighChartsFullScreen(highcharts);
}
export function onFullScreenView(chartRef, options) {
var _chartRef$chart;
chartRef === null || chartRef === void 0 ? void 0 : (_chartRef$chart = chartRef.chart) === null || _chartRef$chart === void 0 ? void 0 : _chartRef$chart.fullscreen.toggle();
}
export function onPDFDownload(chartRef, options) {
chartRef === null || chartRef === void 0 ? void 0 : chartRef.chart.exportChart({
type: "application/pdf"
}, options !== null && options !== void 0 ? options : {});
}
export function onCSVDownload(chartRef, options) {
chartRef === null || chartRef === void 0 ? void 0 : chartRef.chart.downloadCSV();
}
export const onImageDownload = (chartRef, type, options) => {
chartRef === null || chartRef === void 0 ? void 0 : chartRef.chart.exportChart({
type: "image/".concat(type)
}, options !== null && options !== void 0 ? options : {});
};
export const onViewAsTable = (chartRef, show) => {
var _chartRef$chart2;
const options = chartRef === null || chartRef === void 0 ? void 0 : chartRef.chart.options;
chartRef === null || chartRef === void 0 ? void 0 : (_chartRef$chart2 = chartRef.chart) === null || _chartRef$chart2 === void 0 ? void 0 : _chartRef$chart2.update({ ...options,
exporting: { ...(options === null || options === void 0 ? void 0 : options.exporting),
showTable: show
}
});
};