From 6e0187acca92e244c36e73e0ba10f9df2bbb481e Mon Sep 17 00:00:00 2001
From: AlasDiablo <25723276+AlasDiablo@users.noreply.github.com>
Date: Wed, 20 Mar 2024 13:17:21 +0100
Subject: [PATCH 1/5] feat: add an options to open a chart in fullscreen
---
.../utils/components/ZoomableFormat.js | 70 +++++++++++++++++++
.../vega-component/VegaComponent.js | 23 +++---
.../vega-lite-component/VegaLiteComponent.js | 21 +++---
3 files changed, 95 insertions(+), 19 deletions(-)
create mode 100644 src/app/js/formats/utils/components/ZoomableFormat.js
diff --git a/src/app/js/formats/utils/components/ZoomableFormat.js b/src/app/js/formats/utils/components/ZoomableFormat.js
new file mode 100644
index 000000000..3a0778ce0
--- /dev/null
+++ b/src/app/js/formats/utils/components/ZoomableFormat.js
@@ -0,0 +1,70 @@
+import React, { useState } from 'react';
+import PropTypes from 'prop-types';
+import Button from '@mui/material/Button';
+import Dialog from '@mui/material/Dialog';
+import IconButton from '@mui/material/IconButton';
+import CloseIcon from '@mui/icons-material/Close';
+import DialogContent from '@mui/material/DialogContent';
+import OpenInFullIcon from '@mui/icons-material/OpenInFull';
+
+const ZoomableFormat = ({ children }) => {
+ const [open, setOpen] = useState(false);
+
+ const handleClickOpen = () => {
+ setOpen(true);
+ };
+ const handleClose = () => {
+ setOpen(false);
+ };
+
+ return (
+ <>
+
+ {children}
+
+
+
+
+ >
+ );
+};
+
+ZoomableFormat.propTypes = {
+ children: PropTypes.node.isRequired,
+};
+
+export default ZoomableFormat;
diff --git a/src/app/js/formats/utils/components/vega-component/VegaComponent.js b/src/app/js/formats/utils/components/vega-component/VegaComponent.js
index 808277b92..9afc5b3a4 100644
--- a/src/app/js/formats/utils/components/vega-component/VegaComponent.js
+++ b/src/app/js/formats/utils/components/vega-component/VegaComponent.js
@@ -9,6 +9,7 @@ import {
VEGA_DATA_INJECT_TYPE_B,
} from '../../chartsUtils';
import { ASPECT_RATIO_16_9, ASPECT_RATIOS } from '../../aspectRatio';
+import ZoomableFormat from '../ZoomableFormat';
/**
* small component use to handle vega lite display
@@ -43,7 +44,7 @@ function CustomActionVega(props) {
switch (props.injectType) {
case VEGA_DATA_INJECT_TYPE_A:
- spec.data.forEach(e => {
+ spec.data.forEach((e) => {
if (e.name === 'table') {
e.values = props.data.values;
}
@@ -54,14 +55,14 @@ function CustomActionVega(props) {
let data = {
values: [],
};
- props.data.values.forEach(e => {
+ props.data.values.forEach((e) => {
data.values.push({
origin: e.source,
destination: e.target,
count: e.weight,
});
});
- spec.data.forEach(e => {
+ spec.data.forEach((e) => {
if (e.name === 'routes' || e.name === 'link_data') {
e.values = data.values;
}
@@ -73,12 +74,14 @@ function CustomActionVega(props) {
}
return (
-
+
+
+
);
}
@@ -103,7 +106,7 @@ CustomActionVega.propTypes = {
* @param state application state
* @returns {{user: *}} user state
*/
-const mapStateToProps = state => {
+const mapStateToProps = (state) => {
return {
user: state.user,
};
diff --git a/src/app/js/formats/utils/components/vega-lite-component/VegaLiteComponent.js b/src/app/js/formats/utils/components/vega-lite-component/VegaLiteComponent.js
index 778578ab5..c99133bc1 100644
--- a/src/app/js/formats/utils/components/vega-lite-component/VegaLiteComponent.js
+++ b/src/app/js/formats/utils/components/vega-lite-component/VegaLiteComponent.js
@@ -10,6 +10,7 @@ import {
VEGA_LITE_DATA_INJECT_TYPE_C,
} from '../../chartsUtils';
import { ASPECT_RATIO_16_9, ASPECT_RATIOS } from '../../aspectRatio';
+import ZoomableFormat from '../ZoomableFormat';
/**
* small component use to handle vega lite display
@@ -47,14 +48,14 @@ function CustomActionVegaLite({ aspectRatio, user, spec, data, injectType }) {
specWithData.data = data;
break;
case VEGA_LITE_DATA_INJECT_TYPE_B:
- specWithData.transform.forEach(e => {
+ specWithData.transform.forEach((e) => {
if (e.lookup === 'id') {
e.from.data.values = data.values;
}
});
break;
case VEGA_LITE_DATA_INJECT_TYPE_C:
- specWithData.transform.forEach(e => {
+ specWithData.transform.forEach((e) => {
if (e.lookup === 'properties.HASC_2') {
e.from.data.values = data.values;
}
@@ -65,12 +66,14 @@ function CustomActionVegaLite({ aspectRatio, user, spec, data, injectType }) {
}
return (
-
+
+
+
);
}
@@ -95,7 +98,7 @@ CustomActionVegaLite.propTypes = {
* @param state application state
* @returns {{user: *}} user state
*/
-const mapStateToProps = state => {
+const mapStateToProps = (state) => {
return {
user: state.user,
};
From a640ce0bcf25fbd82f693d82b1410de6722b5dca Mon Sep 17 00:00:00 2001
From: AlasDiablo <25723276+AlasDiablo@users.noreply.github.com>
Date: Wed, 20 Mar 2024 13:28:25 +0100
Subject: [PATCH 2/5] feat: add a tooltip
---
src/app/custom/translations.tsv | 1 +
.../utils/components/ZoomableFormat.js | 31 +++++++++++--------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/src/app/custom/translations.tsv b/src/app/custom/translations.tsv
index f74d0346c..3051880ab 100644
--- a/src/app/custom/translations.tsv
+++ b/src/app/custom/translations.tsv
@@ -1072,3 +1072,4 @@
"import" "Import" "Importer"
"import_successful" "Import completed successfully" "Import réalisé avec succès"
"import_error" "Error during import" "Erreur lors de l'import"
+"fullscreen" "View in full screen" "Mettre en plein écran"
diff --git a/src/app/js/formats/utils/components/ZoomableFormat.js b/src/app/js/formats/utils/components/ZoomableFormat.js
index 3a0778ce0..92d31669d 100644
--- a/src/app/js/formats/utils/components/ZoomableFormat.js
+++ b/src/app/js/formats/utils/components/ZoomableFormat.js
@@ -1,13 +1,15 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
-import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import IconButton from '@mui/material/IconButton';
import CloseIcon from '@mui/icons-material/Close';
import DialogContent from '@mui/material/DialogContent';
import OpenInFullIcon from '@mui/icons-material/OpenInFull';
+import Tooltip from '@mui/material/Tooltip';
+import translate from 'redux-polyglot/translate';
+import { polyglot as polyglotPropTypes } from '../../../propTypes';
-const ZoomableFormat = ({ children }) => {
+const ZoomableFormat = ({ children, p }) => {
const [open, setOpen] = useState(false);
const handleClickOpen = () => {
@@ -21,16 +23,18 @@ const ZoomableFormat = ({ children }) => {
<>
{children}
-
+
+
+
+
+