From 80ac2dbf55bd712e869018b9733fc33e94f32d66 Mon Sep 17 00:00:00 2001 From: HendrikThePendric Date: Mon, 14 Oct 2024 12:47:26 +0200 Subject: [PATCH] fix: avoid having to read this.userOptions.customSVGOptions for all viz types --- src/visualizations/config/adapters/dhis_highcharts/chart.js | 6 +++--- .../adapters/dhis_highcharts/customSVGOptions/index.js | 6 ++---- .../config/adapters/dhis_highcharts/exporting.js | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/visualizations/config/adapters/dhis_highcharts/chart.js b/src/visualizations/config/adapters/dhis_highcharts/chart.js index 366fe7052..dc4531d01 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/chart.js +++ b/src/visualizations/config/adapters/dhis_highcharts/chart.js @@ -17,7 +17,7 @@ const DASHBOARD_CHART = { spacingLeft: 5, } -const getEvents = () => ({ +const getEvents = (visType) => ({ events: { load: function () { // Align legend icon with legend text @@ -34,7 +34,7 @@ const getEvents = () => ({ }) } }) - renderCustomSVG.call(this) + renderCustomSVG.call(this, visType) }, }, }) @@ -46,7 +46,7 @@ export default function (layout, el, extraOptions, series) { { renderTo: el || layout.el }, DEFAULT_CHART, extraOptions.dashboard ? DASHBOARD_CHART : undefined, - getEvents(), + getEvents(layout.type), layout.type === VIS_TYPE_SINGLE_VALUE ? { backgroundColor: getSingleValueBackgroundColor( diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js index 7ac3bdbc7..75e76538f 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js +++ b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js @@ -2,10 +2,8 @@ import { VIS_TYPE_SINGLE_VALUE } from '../../../../../modules/visTypes.js' import { getSingleValueCustomSVGOptions } from './singleValue/index.js' import { renderSingleValueSVG } from './singleValue/renderer/renderSingleValueSVG.js' -export function renderCustomSVG() { - const { visualizationType } = this.userOptions.customSVGOptions - - switch (visualizationType) { +export function renderCustomSVG(visType) { + switch (visType) { case VIS_TYPE_SINGLE_VALUE: renderSingleValueSVG.call(this) break diff --git a/src/visualizations/config/adapters/dhis_highcharts/exporting.js b/src/visualizations/config/adapters/dhis_highcharts/exporting.js index c0f5ed2f1..cfea8d52f 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/exporting.js +++ b/src/visualizations/config/adapters/dhis_highcharts/exporting.js @@ -1,12 +1,12 @@ import { VIS_TYPE_SINGLE_VALUE } from '../../../../modules/visTypes.js' import { renderSingleValueSVG } from './customSVGOptions/singleValue/renderer/renderSingleValueSVG.js' -export default function getExporting(layoutType) { +export default function getExporting(visType) { const exporting = { // disable exporting context menu enabled: false, } - switch (layoutType) { + switch (visType) { case VIS_TYPE_SINGLE_VALUE: return { ...exporting,