UNPKG

@hisptz/react-ui

Version:

A collection of reusable complex DHIS2 react ui components.

62 lines (47 loc) 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.onCSVDownload = onCSVDownload; exports.onFullScreenView = onFullScreenView; exports.onImageDownload = void 0; exports.onPDFDownload = onPDFDownload; exports.onViewAsTable = void 0; exports.setupHighchartsModules = setupHighchartsModules; var _exportData = _interopRequireDefault(require("highcharts/modules/export-data")); var _exporting = _interopRequireDefault(require("highcharts/modules/exporting")); var _fullScreen = _interopRequireDefault(require("highcharts/modules/full-screen")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function setupHighchartsModules(highcharts) { (0, _exporting.default)(highcharts); (0, _exportData.default)(highcharts); (0, _fullScreen.default)(highcharts); } 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(); } function onPDFDownload(chartRef, options) { chartRef === null || chartRef === void 0 ? void 0 : chartRef.chart.exportChart({ type: "application/pdf" }, options !== null && options !== void 0 ? options : {}); } function onCSVDownload(chartRef, options) { chartRef === null || chartRef === void 0 ? void 0 : chartRef.chart.downloadCSV(); } 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 : {}); }; exports.onImageDownload = onImageDownload; 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 } }); }; exports.onViewAsTable = onViewAsTable;