diff --git a/fittrackee_client/src/components/Workout/WorkoutChart.vue b/fittrackee_client/src/components/Workout/WorkoutChart/index.vue
similarity index 88%
rename from fittrackee_client/src/components/Workout/WorkoutChart.vue
rename to fittrackee_client/src/components/Workout/WorkoutChart/index.vue
index 54f477ad..9ed7a09e 100644
--- a/fittrackee_client/src/components/Workout/WorkoutChart.vue
+++ b/fittrackee_client/src/components/Workout/WorkoutChart/index.vue
@@ -23,6 +23,7 @@
{{ $t('workouts.DURATION') }}
+
{
+ const legendContainer = document.getElementById(id)
+ if (legendContainer) {
+ let listContainer = legendContainer.querySelector('ul')
+ if (!listContainer) {
+ listContainer = document.createElement('ul')
+ legendContainer.appendChild(listContainer)
+ }
+ return listContainer
+ }
+ throw new Error('No legend container')
+}
+
+export const htmlLegendPlugin = {
+ id: 'htmlLegend',
+ afterUpdate(
+ chart: Chart,
+ args: Record,
+ options: Record
+ ): void {
+ const ul = getOrCreateLegendList(options.containerID)
+ while (ul.firstChild) {
+ ul.firstChild.remove()
+ }
+
+ const legendItems = chart.options.plugins?.legend?.labels?.generateLabels
+ ? chart.options.plugins?.legend?.labels?.generateLabels(chart)
+ : []
+
+ legendItems.forEach((item: LegendItem) => {
+ const li = document.createElement('li')
+ li.onclick = () => {
+ chart.setDatasetVisibility(
+ item.datasetIndex,
+ !chart.isDatasetVisible(item.datasetIndex)
+ )
+ chart.update()
+ }
+
+ const checkBox = document.createElement('input')
+ if (checkBox) {
+ checkBox.type = 'checkbox'
+ checkBox.id = item.text
+ checkBox.checked = !item.hidden
+ }
+
+ const text = document.createTextNode(item.text)
+
+ const boxSpan = document.createElement('span')
+ if (boxSpan) {
+ boxSpan.style.background = `${item.fillStyle}`
+ boxSpan.style.borderColor = `${item.strokeStyle}`
+ }
+
+ li.appendChild(checkBox)
+ li.appendChild(text)
+ li.appendChild(boxSpan)
+ ul.appendChild(li)
+ })
+ },
+}
diff --git a/fittrackee_client/src/views/workouts/Workout.vue b/fittrackee_client/src/views/workouts/Workout.vue
index 4743185e..d717470d 100644
--- a/fittrackee_client/src/views/workouts/Workout.vue
+++ b/fittrackee_client/src/views/workouts/Workout.vue
@@ -52,7 +52,7 @@
import { useRoute } from 'vue-router'
import NotFound from '@/components/Common/NotFound.vue'
- import WorkoutChart from '@/components/Workout/WorkoutChart.vue'
+ import WorkoutChart from '@/components/Workout/WorkoutChart/index.vue'
import WorkoutDetail from '@/components/Workout/WorkoutDetail/index.vue'
import WorkoutNotes from '@/components/Workout/WorkoutNotes.vue'
import WorkoutSegments from '@/components/Workout/WorkoutSegments.vue'