-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates app.vue and mixins to Vue 3 Composition API (#153)
* Updates RequestHandling and WidgetHandling to composables and util functions * Updates DashboardHandling to a composable * Implements further utils and composables * Updates app.vue to composition API * Adds basic repository and registry clients
- Loading branch information
Showing
16 changed files
with
1,544 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useConceptDescriptionHandling } from '@/composables/ConceptDescriptionHandling'; | ||
|
||
export function useChartHandling() { | ||
const { unitSuffix } = useConceptDescriptionHandling(); | ||
|
||
function prepareYValueTooltip(chartData: any, yVariables: any) { | ||
return chartData.map((_series: any, index: number) => { | ||
// Use optional chaining and nullish coalescing to simplify the retrieval of the unit | ||
let unit = ''; | ||
if (yVariables[index]) { | ||
unit = unitSuffix(yVariables[index]); | ||
} | ||
return { | ||
formatter: (value: any) => `${value} ${unit}`, | ||
}; | ||
}); | ||
} | ||
|
||
function prepareLegend(yVariables: any) { | ||
return { | ||
formatter: (seriesName: any, opts: any) => { | ||
let unit = ''; | ||
const index = opts.seriesIndex; | ||
|
||
// check if the yVariable exists | ||
if (yVariables.length > index) { | ||
// check if the yVariable has an unit (embeddedDataSpecification) -> take the first one (TODO: make this more generic in the future) | ||
if (yVariables[index]) { | ||
unit = '[' + unitSuffix(yVariables[index]) + ']'; | ||
} | ||
} | ||
return seriesName + ' ' + unit; | ||
}, | ||
}; | ||
} | ||
|
||
return { | ||
prepareYValueTooltip, | ||
prepareLegend, | ||
}; | ||
} |
Oops, something went wrong.