Skip to content

Commit 8625c7a

Browse files
author
Maximilian
committed
Added Graphic Help screen
1 parent 7d836a0 commit 8625c7a

10 files changed

Lines changed: 135 additions & 0 deletions

File tree

‎opensilex-front/front/src/components/visualization/DataVisuGraphic.vue‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<n-button v-if="isZoomed" size="small" @click="resetZoom()">
55
{{ t("DataVisuGraphic.resetZoom") }}
66
</n-button>
7+
<HelpButton label="DataVisuGraphic.help" :small="true" @click="showHelp()"></HelpButton>
78
<n-dropdown
89
trigger="click"
910
placement="bottom-end"
@@ -49,6 +50,13 @@
4950
@onCreate="emit('eventCreated')"
5051
></EventForm>
5152
<AnnotationModalForm ref="annotationForm" @onCreate="onAnnotationFormCreated"></AnnotationModalForm>
53+
54+
<Modal ref="helpModal" modalSize="lg">
55+
<template #header>
56+
<h4>{{ t("DataVisuGraphic.help") }}</h4>
57+
</template>
58+
<DataVisuHelp></DataVisuHelp>
59+
</Modal>
5260
</div>
5361
</template>
5462

@@ -59,6 +67,9 @@ import {DropdownOption, NButton, NDropdown, NEmpty} from "naive-ui";
5967
import DataVisuDetails from "@/components/visualization/DataVisuDetails.vue";
6068
import EventForm from "@/components/events/form/EventForm.vue";
6169
import AnnotationModalForm from "@/components/annotations/list/form/AnnotationModalForm.vue";
70+
import HelpButton from "@/components/common/buttons/HelpButton.vue";
71+
import Modal from "@/components/common/views/Modal.vue";
72+
import DataVisuHelp from "@/components/visualization/DataVisuHelp.vue";
6273
import type {DataGetSearchDTO, EventGetDTO} from "opensilex-core/index";
6374
import type {DataVisuEvent, DataVisuPoint, DataVisuSerie} from "@/components/visualization/DataVisuTypes";
6475
import * as echarts from "echarts/core";
@@ -165,6 +176,7 @@ const chartContainer = useTemplateRef<HTMLDivElement>("chartContainer");
165176
const details = useTemplateRef<InstanceType<typeof DataVisuDetails>>("details");
166177
const eventForm = useTemplateRef<InstanceType<typeof EventForm>>("eventForm");
167178
const annotationForm = useTemplateRef<InstanceType<typeof AnnotationModalForm>>("annotationForm");
179+
const helpModal = useTemplateRef<InstanceType<typeof Modal>>("helpModal");
168180
//#endregion
169181
170182
//#region Data & Computed
@@ -841,6 +853,16 @@ function resetZoom(): void {
841853
chart?.dispatchAction({type: "dataZoom", start: 0, end: 100});
842854
}
843855
856+
/**
857+
* Displays the help of the graphic. Its modal is a modal of the page, not visible in fullscreen
858+
*/
859+
async function showHelp(): Promise<void> {
860+
if (document.fullscreenElement) {
861+
await document.exitFullscreen();
862+
}
863+
helpModal.value?.show();
864+
}
865+
844866
/**
845867
* Puts the component (header included, so the menu stays usable) in fullscreen, or exits the fullscreen. The details
846868
* of a clicked element are hidden in fullscreen, as in the former graphics.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<template>
2+
<!-- The content is our own markdown files, not user input -->
3+
<div class="markdown-content" v-html="renderedHelp"></div>
4+
</template>
5+
6+
<script setup lang="ts">
7+
import {computed, ComputedRef} from "vue";
8+
import {useI18n} from "vue-i18n";
9+
import {Marked, Token, Tokens} from "marked";
10+
import DataVisuHelpEN from "@/components/visualization/doc/DataVisuHelpEN.md?raw";
11+
import DataVisuHelpFR from "@/components/visualization/doc/DataVisuHelpFR.md?raw";
12+
13+
/**
14+
* Help of the DataVisuGraphic: its interactions (click, right-click, zoom, menu), in the current language.
15+
*
16+
* The markdown files reference their screenshots as `![description](./name.png)`, next to them in the doc folder.
17+
*/
18+
19+
//#region Private
20+
//#region Plugins & services
21+
const {locale} = useI18n();
22+
23+
/**
24+
* URL of each screenshot of the doc folder, by its path in the markdown. The markdown is read as raw text, so Vite
25+
* doesn't resolve its image paths by itself.
26+
*/
27+
const screenshotUrls: Map<string, string> = new Map(
28+
Object.entries(import.meta.glob<string>("./doc/*.png", {eager: true, query: "?url", import: "default"}))
29+
.map(([path, url]: [string, string]) => [path.replace("./doc/", "./"), url])
30+
);
31+
32+
/**
33+
* Own instance of marked, so that the image paths are only replaced in this help, not in the other markdown pages
34+
*/
35+
const helpMarked: Marked = new Marked({walkTokens: resolveScreenshot});
36+
//#endregion
37+
38+
//#region Data & Computed
39+
const renderedHelp: ComputedRef<string> = computed<string>(() =>
40+
helpMarked.parse(locale.value === "fr" ? DataVisuHelpFR : DataVisuHelpEN, {async: false}) as string
41+
);
42+
//#endregion
43+
44+
//#region Methods
45+
/**
46+
* Called by marked on each piece of the parsed markdown, before it is rendered as HTML: gives the images the real URL
47+
* of their screenshot
48+
*/
49+
function resolveScreenshot(token: Token): void {
50+
if (token.type === "image") {
51+
const image: Tokens.Image = token as Tokens.Image;
52+
image.href = screenshotUrls.get(image.href) ?? image.href;
53+
}
54+
}
55+
//#endregion
56+
//#endregion
57+
</script>
58+
59+
<style scoped lang="scss">
60+
/* Screenshots of any size: never wider than the modal, proportions kept, framed to stand out from the white modal */
61+
.markdown-content :deep(img) {
62+
display: block;
63+
max-width: 100%;
64+
height: auto;
65+
margin: 8px auto 24px;
66+
border: 1px solid #e0e0e6;
67+
border-radius: 4px;
68+
}
69+
</style>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# HELP
2+
3+
**Data contextual menu**
4+
- Click on a data point or event flag to see information.
5+
- Right click on a data point to see the contextual menu: add an event or annotate the data.
6+
- Click on an image pin ("I", red when the image is annotated) to display the image above the graphic.
7+
8+
![Details of a clicked data point and its contextual menu](./clickEnglish.png)
9+
10+
**Zoom**
11+
- Click and drag horizontally on the graphic, over the period you want to zoom on: the graphic then only displays this period.
12+
- Use the mouse wheel to zoom in and out.
13+
- Click on "Reset zoom" to display the whole period again.
14+
15+
**Contextual menu**
16+
- A graphical contextual menu (☰) allows to:
17+
- choose a chart line (by default) or a scatter plot view.
18+
- a fullscreen mode.
19+
- download an image from the charts.
20+
21+
![Menu of the graphic](./contextEnglish.png)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# AIDE
2+
3+
**Menu contextuel de donnée**
4+
- Faire un clic sur un point ou sur un événement pour voir les informations associées.
5+
- Faire un clic droit sur le point de la donnée pour voir le menu contextuel : ajouter un événement ou annoter la donnée.
6+
- Faire un clic sur l'épingle d'une image (« I », rouge quand l'image est annotée) pour afficher l'image au-dessus du graphique.
7+
8+
![Détails d'un point cliqué et son menu contextuel](./clickFrench.png)
9+
10+
**Zoom**
11+
- Cliquer et faire glisser horizontalement sur le graphique, au-dessus de la période sur laquelle zoomer : le graphique n'affiche alors plus que cette période.
12+
- Utiliser la molette de la souris pour zoomer et dézoomer.
13+
- Cliquer sur « Réinitialiser le zoom » pour afficher de nouveau toute la période.
14+
15+
**Menu contextuel**
16+
- Un menu contextuel (☰) de la représentation graphique permet de :
17+
- choisir le mode courbe (par défaut) ou nuage de points.
18+
- d'afficher en plein écran.
19+
- de télécharger une image.
20+
21+
![Menu du graphique](./contextFrench.png)
82.9 KB
Loading
78.3 KB
Loading
16.1 KB
Loading
16.9 KB
Loading

‎opensilex-front/front/src/lang/message-en.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,7 @@
18291829
"fullscreen": "Fullscreen",
18301830
"download": "Download image",
18311831
"resetZoom": "Reset zoom",
1832+
"help": "Help on the graphic",
18321833
"name": "Name",
18331834
"eventBegin": "Begin",
18341835
"eventEnd": "End",

‎opensilex-front/front/src/lang/message-fr.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,7 @@
18871887
"fullscreen": "Plein écran",
18881888
"download": "Télécharger l'image",
18891889
"resetZoom": "Réinitialiser le zoom",
1890+
"help": "Aide du graphique",
18901891
"name": "Nom",
18911892
"eventBegin": "Début",
18921893
"eventEnd": "Fin",

0 commit comments

Comments
 (0)