@dhis2/analytics 27.0.1 → 28.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/__demo__/ScatterPlotPdfExport.stories.js +46 -0
- package/build/cjs/__demo__/SingleValue.stories.js +34 -2
- package/build/cjs/__fixtures__/scatterPlotData.js +863 -0
- package/build/cjs/components/FileMenu/__tests__/utils.spec.js +18 -91
- package/build/cjs/components/FileMenu/utils.js +5 -29
- package/build/cjs/locales/ar/translations.json +3 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueBackgroundColor.js +2 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/addIconElement.js +2 -2
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/index.js +13 -16
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/positionElements.js +2 -5
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/styles.js +13 -2
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/exporting.js +33 -17
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/index.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/title/index.js +2 -1
- package/build/cjs/visualizations/config/generators/highcharts/index.js +30 -16
- package/build/cjs/visualizations/util/colors/colorSets.js +1 -2
- package/build/es/__demo__/ScatterPlotPdfExport.stories.js +37 -0
- package/build/es/__demo__/SingleValue.stories.js +35 -3
- package/build/es/__fixtures__/scatterPlotData.js +857 -0
- package/build/es/components/FileMenu/__tests__/utils.spec.js +18 -91
- package/build/es/components/FileMenu/utils.js +6 -30
- package/build/es/locales/ar/translations.json +3 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueBackgroundColor.js +2 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/addIconElement.js +2 -2
- package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/index.js +13 -16
- package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/positionElements.js +2 -5
- package/build/es/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/styles.js +13 -2
- package/build/es/visualizations/config/adapters/dhis_highcharts/exporting.js +33 -17
- package/build/es/visualizations/config/adapters/dhis_highcharts/index.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/title/index.js +2 -1
- package/build/es/visualizations/config/generators/highcharts/index.js +30 -16
- package/build/es/visualizations/util/colors/colorSets.js +1 -2
- package/package.json +4 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _scatterPlotData = require("../__fixtures__/scatterPlotData.js");
|
|
9
|
+
var _index = require("../index.js");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
var _default = exports.default = {
|
|
13
|
+
title: 'ScatterPlot'
|
|
14
|
+
};
|
|
15
|
+
const Default = () => {
|
|
16
|
+
const ref = (0, _react.useRef)(null);
|
|
17
|
+
const [chart, setChart] = (0, _react.useState)(null);
|
|
18
|
+
const exportToPdf = (0, _react.useCallback)(() => {
|
|
19
|
+
chart.update({
|
|
20
|
+
exporting: {
|
|
21
|
+
chartOptions: {
|
|
22
|
+
isPdfExport: true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
chart.exportChartLocal({
|
|
27
|
+
filename: 'PDF export',
|
|
28
|
+
type: 'application/pdf'
|
|
29
|
+
});
|
|
30
|
+
}, [chart]);
|
|
31
|
+
(0, _react.useEffect)(() => {
|
|
32
|
+
const obj = (0, _index.createVisualization)(_scatterPlotData.responses, _scatterPlotData.visualization, ref.current, _scatterPlotData.extraOptions, undefined, undefined, 'highcharts');
|
|
33
|
+
setChart(obj.visualization);
|
|
34
|
+
}, []);
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, chart && /*#__PURE__*/_react.default.createElement("button", {
|
|
36
|
+
onClick: exportToPdf
|
|
37
|
+
}, "Export PDF"), /*#__PURE__*/_react.default.createElement("div", {
|
|
38
|
+
style: {
|
|
39
|
+
width: 800,
|
|
40
|
+
height: 800,
|
|
41
|
+
border: '2px solid magenta'
|
|
42
|
+
},
|
|
43
|
+
ref: ref
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
exports.Default = Default;
|
|
@@ -593,6 +593,7 @@ const Default = () => {
|
|
|
593
593
|
const [dashboard, setDashboard] = (0, _react.useState)(false);
|
|
594
594
|
const [showIcon, setShowIcon] = (0, _react.useState)(true);
|
|
595
595
|
const [indicatorType, setIndicatorType] = (0, _react.useState)('plain');
|
|
596
|
+
const [exportAsPdf, setExportAsPdf] = (0, _react.useState)(true);
|
|
596
597
|
const [width, setWidth] = (0, _react.useState)(constainerStyleBase.width);
|
|
597
598
|
const [height, setHeight] = (0, _react.useState)(constainerStyleBase.height);
|
|
598
599
|
const containerStyle = (0, _react.useMemo)(() => ({
|
|
@@ -600,6 +601,31 @@ const Default = () => {
|
|
|
600
601
|
width,
|
|
601
602
|
height
|
|
602
603
|
}), [width, height]);
|
|
604
|
+
const downloadOffline = (0, _react.useCallback)(() => {
|
|
605
|
+
if (newChartRef.current) {
|
|
606
|
+
const currentBackgroundColor = newChartRef.current.userOptions.chart.backgroundColor;
|
|
607
|
+
newChartRef.current.update({
|
|
608
|
+
exporting: {
|
|
609
|
+
chartOptions: {
|
|
610
|
+
isPdfExport: exportAsPdf
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
newChartRef.current.exportChartLocal({
|
|
615
|
+
sourceHeight: 768,
|
|
616
|
+
sourceWidth: 1024,
|
|
617
|
+
scale: 1,
|
|
618
|
+
fallbackToExportServer: false,
|
|
619
|
+
filename: 'testOfflineDownload',
|
|
620
|
+
showExportInProgress: true,
|
|
621
|
+
type: exportAsPdf ? 'application/pdf' : 'image/png'
|
|
622
|
+
}, {
|
|
623
|
+
chart: {
|
|
624
|
+
backgroundColor: currentBackgroundColor === 'transparent' ? '#ffffff' : currentBackgroundColor
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
}, [exportAsPdf]);
|
|
603
629
|
(0, _react.useEffect)(() => {
|
|
604
630
|
if (newContainerRef.current) {
|
|
605
631
|
requestAnimationFrame(() => {
|
|
@@ -660,13 +686,19 @@ const Default = () => {
|
|
|
660
686
|
checked: showIcon,
|
|
661
687
|
onChange: () => setShowIcon(!showIcon),
|
|
662
688
|
type: "checkbox"
|
|
663
|
-
}), "\xA0Show icon"), /*#__PURE__*/_react.default.createElement("label", null, "Indicator type
|
|
689
|
+
}), "\xA0Show icon"), /*#__PURE__*/_react.default.createElement("label", null, "Indicator type", ' ', /*#__PURE__*/_react.default.createElement("select", {
|
|
664
690
|
onChange: event => setIndicatorType(event.target.value)
|
|
665
691
|
}, indicatorTypes.map((type, index) => {
|
|
666
692
|
return /*#__PURE__*/_react.default.createElement("option", {
|
|
667
693
|
key: index
|
|
668
694
|
}, type);
|
|
669
|
-
})))
|
|
695
|
+
}))), /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("input", {
|
|
696
|
+
checked: exportAsPdf,
|
|
697
|
+
onChange: () => setExportAsPdf(!exportAsPdf),
|
|
698
|
+
type: "checkbox"
|
|
699
|
+
}), ' ', "Export as PDF"), /*#__PURE__*/_react.default.createElement("button", {
|
|
700
|
+
onClick: downloadOffline
|
|
701
|
+
}, "Download offline")), /*#__PURE__*/_react.default.createElement("div", {
|
|
670
702
|
style: {
|
|
671
703
|
display: 'flex',
|
|
672
704
|
gap: 12
|