From 3065022f7d6a1886e44454ef1759e1aff6b55264 Mon Sep 17 00:00:00 2001 From: HendrikThePendric Date: Mon, 21 Oct 2024 15:59:37 +0200 Subject: [PATCH] refactor: restructure chart, event and customSVGOptions dirs --- .../config/adapters/dhis_highcharts/chart.js | 63 ------------------- .../adapters/dhis_highcharts/chart/default.js | 27 ++++++++ .../adapters/dhis_highcharts/chart/index.js | 12 ++++ .../dhis_highcharts/chart/singleValue.js | 19 ++++++ .../dhis_highcharts/customSVGOptions/index.js | 15 +---- .../config/getSingleValueCustomSVGOptions.js | 27 -------- .../getSingleValueBackgroundColor.js | 2 +- .../getSingleValueFormattedValue.js | 4 +- .../{config => }/getSingleValueLegendColor.js | 2 +- .../{config => }/getSingleValueSubtext.js | 0 .../{config => }/getSingleValueTextColor.js | 4 +- .../{config => }/getSingleValueTitleColor.js | 4 +- .../customSVGOptions/singleValue/index.js | 30 ++++++++- .../adapters/dhis_highcharts/events/index.js | 23 +++++++ .../events/loadCustomSVG/index.js | 12 ++++ .../singleValue}/addIconElement.js | 0 .../checkIfFitsWithinContainer.js | 0 .../singleValue}/computeLayoutRect.js | 0 .../singleValue}/computeSpacingTop.js | 0 .../loadCustomSVG/singleValue}/constants.js | 0 .../singleValue}/getAvailableSpace.js | 0 .../loadCustomSVG/singleValue/index.js} | 2 +- .../singleValue}/positionElements.js | 0 .../loadCustomSVG/singleValue}/styles.js | 0 .../adapters/dhis_highcharts/exporting.js | 4 +- .../config/adapters/dhis_highcharts/index.js | 4 +- .../dhis_highcharts/subtitle/singleValue.js | 2 +- .../dhis_highcharts/title/singleValue.js | 2 +- 28 files changed, 137 insertions(+), 121 deletions(-) delete mode 100644 src/visualizations/config/adapters/dhis_highcharts/chart.js create mode 100644 src/visualizations/config/adapters/dhis_highcharts/chart/default.js create mode 100644 src/visualizations/config/adapters/dhis_highcharts/chart/index.js create mode 100644 src/visualizations/config/adapters/dhis_highcharts/chart/singleValue.js delete mode 100644 src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueCustomSVGOptions.js rename src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/{config => }/getSingleValueBackgroundColor.js (82%) rename src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/{config => }/getSingleValueFormattedValue.js (82%) rename src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/{config => }/getSingleValueLegendColor.js (92%) rename src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/{config => }/getSingleValueSubtext.js (100%) rename src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/{config => }/getSingleValueTextColor.js (76%) rename src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/{config => }/getSingleValueTitleColor.js (83%) create mode 100644 src/visualizations/config/adapters/dhis_highcharts/events/index.js create mode 100644 src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/index.js rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer => events/loadCustomSVG/singleValue}/addIconElement.js (100%) rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer => events/loadCustomSVG/singleValue}/checkIfFitsWithinContainer.js (100%) rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer => events/loadCustomSVG/singleValue}/computeLayoutRect.js (100%) rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer => events/loadCustomSVG/singleValue}/computeSpacingTop.js (100%) rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer => events/loadCustomSVG/singleValue}/constants.js (100%) rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer => events/loadCustomSVG/singleValue}/getAvailableSpace.js (100%) rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer/renderSingleValueSVG.js => events/loadCustomSVG/singleValue/index.js} (97%) rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer => events/loadCustomSVG/singleValue}/positionElements.js (100%) rename src/visualizations/config/adapters/dhis_highcharts/{customSVGOptions/singleValue/renderer => events/loadCustomSVG/singleValue}/styles.js (100%) diff --git a/src/visualizations/config/adapters/dhis_highcharts/chart.js b/src/visualizations/config/adapters/dhis_highcharts/chart.js deleted file mode 100644 index dc4531d01..000000000 --- a/src/visualizations/config/adapters/dhis_highcharts/chart.js +++ /dev/null @@ -1,63 +0,0 @@ -import { VIS_TYPE_SINGLE_VALUE } from '../../../../modules/visTypes.js' -import { renderCustomSVG } from './customSVGOptions/index.js' -import { getSingleValueBackgroundColor } from './customSVGOptions/singleValue/index.js' -import getType from './type.js' - -const DEFAULT_CHART = { - spacingTop: 20, - style: { - fontFamily: 'Roboto,Helvetica Neue,Helvetica,Arial,sans-serif', - }, -} - -const DASHBOARD_CHART = { - spacingTop: 0, - spacingRight: 5, - spacingBottom: 2, - spacingLeft: 5, -} - -const getEvents = (visType) => ({ - events: { - load: function () { - // Align legend icon with legend text - this.legend.allItems.forEach((item) => { - if (item.legendSymbol) { - item.legendSymbol.attr({ - translateY: - -( - (item.legendItem.label.getBBox().height * - 0.75) / - 4 - ) + - item.legendSymbol.r / 2, - }) - } - }) - renderCustomSVG.call(this, visType) - }, - }, -}) - -export default function (layout, el, extraOptions, series) { - return Object.assign( - {}, - getType(layout.type), - { renderTo: el || layout.el }, - DEFAULT_CHART, - extraOptions.dashboard ? DASHBOARD_CHART : undefined, - getEvents(layout.type), - layout.type === VIS_TYPE_SINGLE_VALUE - ? { - backgroundColor: getSingleValueBackgroundColor( - layout.legend, - extraOptions.legendSets, - series[0] - ), - } - : undefined, - layout.type === VIS_TYPE_SINGLE_VALUE && extraOptions.dashboard - ? { spacingTop: 7 } - : undefined - ) -} diff --git a/src/visualizations/config/adapters/dhis_highcharts/chart/default.js b/src/visualizations/config/adapters/dhis_highcharts/chart/default.js new file mode 100644 index 000000000..9d4af9829 --- /dev/null +++ b/src/visualizations/config/adapters/dhis_highcharts/chart/default.js @@ -0,0 +1,27 @@ +import { getEvents } from '../events/index.js' +import getType from '../type.js' + +const DEFAULT_CHART = { + spacingTop: 20, + style: { + fontFamily: 'Roboto,Helvetica Neue,Helvetica,Arial,sans-serif', + }, +} + +const DASHBOARD_CHART = { + spacingTop: 0, + spacingRight: 5, + spacingBottom: 2, + spacingLeft: 5, +} + +export default function getDefaultChart(layout, el, extraOptions) { + return Object.assign( + {}, + getType(layout.type), + { renderTo: el || layout.el }, + DEFAULT_CHART, + extraOptions.dashboard ? DASHBOARD_CHART : undefined, + getEvents(layout.type) + ) +} diff --git a/src/visualizations/config/adapters/dhis_highcharts/chart/index.js b/src/visualizations/config/adapters/dhis_highcharts/chart/index.js new file mode 100644 index 000000000..c6010e016 --- /dev/null +++ b/src/visualizations/config/adapters/dhis_highcharts/chart/index.js @@ -0,0 +1,12 @@ +import { VIS_TYPE_SINGLE_VALUE } from '../../../../../modules/visTypes.js' +import getDefaultChart from './default.js' +import getSingleValueChart from './singleValue.js' + +export default function getChart(layout, el, extraOptions, series) { + switch (layout.type) { + case VIS_TYPE_SINGLE_VALUE: + return getSingleValueChart(layout, el, extraOptions, series) + default: + return getDefaultChart(layout, el, extraOptions) + } +} diff --git a/src/visualizations/config/adapters/dhis_highcharts/chart/singleValue.js b/src/visualizations/config/adapters/dhis_highcharts/chart/singleValue.js new file mode 100644 index 000000000..43a6f66a2 --- /dev/null +++ b/src/visualizations/config/adapters/dhis_highcharts/chart/singleValue.js @@ -0,0 +1,19 @@ +import { getSingleValueBackgroundColor } from '../customSVGOptions/singleValue/getSingleValueBackgroundColor.js' +import getDefaultChart from './default.js' + +export default function getSingleValueChart(layout, el, extraOptions, series) { + const chart = { + ...getDefaultChart(layout, el, extraOptions), + backgroundColor: getSingleValueBackgroundColor( + layout.legend, + extraOptions.legendSets, + series[0] + ), + } + + if (extraOptions.dashboard) { + chart.spacingTop = 7 + } + + return chart +} diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js index 75e76538f..ef5b18509 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js +++ b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/index.js @@ -1,18 +1,7 @@ import { VIS_TYPE_SINGLE_VALUE } from '../../../../../modules/visTypes.js' -import { getSingleValueCustomSVGOptions } from './singleValue/index.js' -import { renderSingleValueSVG } from './singleValue/renderer/renderSingleValueSVG.js' +import getSingleValueCustomSVGOptions from './singleValue/index.js' -export function renderCustomSVG(visType) { - switch (visType) { - case VIS_TYPE_SINGLE_VALUE: - renderSingleValueSVG.call(this) - break - default: - break - } -} - -export function getCustomSVGOptions({ +export default function getCustomSVGOptions({ extraConfig, layout, extraOptions, diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueCustomSVGOptions.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueCustomSVGOptions.js deleted file mode 100644 index 76d748525..000000000 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueCustomSVGOptions.js +++ /dev/null @@ -1,27 +0,0 @@ -import { colors } from '@dhis2/ui' -import { getSingleValueFormattedValue } from './getSingleValueFormattedValue.js' -import { getSingleValueSubtext } from './getSingleValueSubtext.js' -import { getSingleValueTextColor } from './getSingleValueTextColor.js' - -export function getSingleValueCustomSVGOptions({ - layout, - extraOptions, - metaData, - series, -}) { - const { dashboard, icon } = extraOptions - const value = series[0] - return { - value, - fontColor: getSingleValueTextColor( - colors.grey900, - value, - layout.legend, - extraOptions.legendSets - ), - formattedValue: getSingleValueFormattedValue(value, layout, metaData), - icon, - dashboard, - subText: getSingleValueSubtext(metaData), - } -} diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueBackgroundColor.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueBackgroundColor.js similarity index 82% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueBackgroundColor.js rename to src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueBackgroundColor.js index 8ab54896f..650c895a5 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueBackgroundColor.js +++ b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueBackgroundColor.js @@ -1,4 +1,4 @@ -import { LEGEND_DISPLAY_STYLE_FILL } from '../../../../../../../modules/legends.js' +import { LEGEND_DISPLAY_STYLE_FILL } from '../../../../../../modules/legends.js' import { getSingleValueLegendColor } from './getSingleValueLegendColor.js' export function getSingleValueBackgroundColor( diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueFormattedValue.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueFormattedValue.js similarity index 82% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueFormattedValue.js rename to src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueFormattedValue.js index 01f3aad09..f0b91dee3 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueFormattedValue.js +++ b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueFormattedValue.js @@ -1,5 +1,5 @@ -import { renderValue } from '../../../../../../../modules/renderValue.js' -import { VALUE_TYPE_TEXT } from '../../../../../../../modules/valueTypes.js' +import { renderValue } from '../../../../../../modules/renderValue.js' +import { VALUE_TYPE_TEXT } from '../../../../../../modules/valueTypes.js' export const INDICATOR_FACTOR_100 = 100 diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueLegendColor.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueLegendColor.js similarity index 92% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueLegendColor.js rename to src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueLegendColor.js index 3e2067cad..9f042fc4d 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueLegendColor.js +++ b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueLegendColor.js @@ -1,4 +1,4 @@ -import { getColorByValueFromLegendSet } from '../../../../../../../modules/legends.js' +import { getColorByValueFromLegendSet } from '../../../../../../modules/legends.js' export function getSingleValueLegendColor(legendOptions, legendSets, value) { const legendSet = legendOptions && legendSets[0] diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueSubtext.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueSubtext.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueSubtext.js rename to src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueSubtext.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueTextColor.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTextColor.js similarity index 76% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueTextColor.js rename to src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTextColor.js index d792a957e..2f3eb0da0 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueTextColor.js +++ b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTextColor.js @@ -1,6 +1,6 @@ import { colors } from '@dhis2/ui' -import { LEGEND_DISPLAY_STYLE_TEXT } from '../../../../../../../modules/legends.js' -import { shouldUseContrastColor } from '../../../../../../util/shouldUseContrastColor.js' +import { LEGEND_DISPLAY_STYLE_TEXT } from '../../../../../../modules/legends.js' +import { shouldUseContrastColor } from '../../../../../util/shouldUseContrastColor.js' import { getSingleValueLegendColor } from './getSingleValueLegendColor.js' export function getSingleValueTextColor( diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueTitleColor.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTitleColor.js similarity index 83% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueTitleColor.js rename to src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTitleColor.js index 0310347cb..bf4f0672b 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueTitleColor.js +++ b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/getSingleValueTitleColor.js @@ -1,6 +1,6 @@ import { colors } from '@dhis2/ui' -import { LEGEND_DISPLAY_STYLE_FILL } from '../../../../../../../modules/legends.js' -import { shouldUseContrastColor } from '../../../../../../util/shouldUseContrastColor.js' +import { LEGEND_DISPLAY_STYLE_FILL } from '../../../../../../modules/legends.js' +import { shouldUseContrastColor } from '../../../../../util/shouldUseContrastColor.js' import { getSingleValueLegendColor } from './getSingleValueLegendColor.js' export function getSingleValueTitleColor( diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/index.js b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/index.js index adcb9194e..bb0ff56f1 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/index.js +++ b/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/index.js @@ -1,3 +1,27 @@ -export { getSingleValueCustomSVGOptions } from './config/getSingleValueCustomSVGOptions.js' -export { getSingleValueBackgroundColor } from './config/getSingleValueBackgroundColor.js' -export { getSingleValueTitleColor } from './config/getSingleValueTitleColor.js' +import { colors } from '@dhis2/ui' +import { getSingleValueFormattedValue } from './getSingleValueFormattedValue.js' +import { getSingleValueSubtext } from './getSingleValueSubtext.js' +import { getSingleValueTextColor } from './getSingleValueTextColor.js' + +export default function getSingleValueCustomSVGOptions({ + layout, + extraOptions, + metaData, + series, +}) { + const { dashboard, icon } = extraOptions + const value = series[0] + return { + value, + fontColor: getSingleValueTextColor( + colors.grey900, + value, + layout.legend, + extraOptions.legendSets + ), + formattedValue: getSingleValueFormattedValue(value, layout, metaData), + icon, + dashboard, + subText: getSingleValueSubtext(metaData), + } +} diff --git a/src/visualizations/config/adapters/dhis_highcharts/events/index.js b/src/visualizations/config/adapters/dhis_highcharts/events/index.js new file mode 100644 index 000000000..4f8bf0904 --- /dev/null +++ b/src/visualizations/config/adapters/dhis_highcharts/events/index.js @@ -0,0 +1,23 @@ +import loadCustomSVG from './loadCustomSVG/index.js' + +export const getEvents = (visType) => ({ + events: { + load: function () { + // Align legend icon with legend text + this.legend.allItems.forEach((item) => { + if (item.legendSymbol) { + item.legendSymbol.attr({ + translateY: + -( + (item.legendItem.label.getBBox().height * + 0.75) / + 4 + ) + + item.legendSymbol.r / 2, + }) + } + }) + loadCustomSVG.call(this, visType) + }, + }, +}) diff --git a/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/index.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/index.js new file mode 100644 index 000000000..6e01df566 --- /dev/null +++ b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/index.js @@ -0,0 +1,12 @@ +import { VIS_TYPE_SINGLE_VALUE } from '../../../../../../modules/visTypes.js' +import loadSingleValueSVG from './singleValue/index.js' + +export default function loadCustomSVG(visType) { + switch (visType) { + case VIS_TYPE_SINGLE_VALUE: + loadSingleValueSVG.call(this) + break + default: + break + } +} diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/addIconElement.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/addIconElement.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/addIconElement.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/addIconElement.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/checkIfFitsWithinContainer.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/checkIfFitsWithinContainer.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/checkIfFitsWithinContainer.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/checkIfFitsWithinContainer.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/computeLayoutRect.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/computeLayoutRect.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/computeLayoutRect.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/computeLayoutRect.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/computeSpacingTop.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/computeSpacingTop.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/computeSpacingTop.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/computeSpacingTop.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/constants.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/constants.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/constants.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/constants.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/getAvailableSpace.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/getAvailableSpace.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/getAvailableSpace.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/getAvailableSpace.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/renderSingleValueSVG.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/index.js similarity index 97% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/renderSingleValueSVG.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/index.js index 806d1e627..84cc83e7d 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/renderSingleValueSVG.js +++ b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/index.js @@ -4,7 +4,7 @@ import { getAvailableSpace } from './getAvailableSpace.js' import { positionElements } from './positionElements.js' import { DynamicStyles } from './styles.js' -export function renderSingleValueSVG() { +export default function loadSingleValueSVG() { const { formattedValue, icon, subText, fontColor } = this.userOptions.customSVGOptions const dynamicStyles = new DynamicStyles(this.userOptions?.isPdfExport) diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/positionElements.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/positionElements.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/positionElements.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/positionElements.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/styles.js b/src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/styles.js similarity index 100% rename from src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/renderer/styles.js rename to src/visualizations/config/adapters/dhis_highcharts/events/loadCustomSVG/singleValue/styles.js diff --git a/src/visualizations/config/adapters/dhis_highcharts/exporting.js b/src/visualizations/config/adapters/dhis_highcharts/exporting.js index cfea8d52f..032a9c689 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/exporting.js +++ b/src/visualizations/config/adapters/dhis_highcharts/exporting.js @@ -1,5 +1,5 @@ import { VIS_TYPE_SINGLE_VALUE } from '../../../../modules/visTypes.js' -import { renderSingleValueSVG } from './customSVGOptions/singleValue/renderer/renderSingleValueSVG.js' +import loadSingleValueSVG from './events/loadCustomSVG/singleValue/index.js' export default function getExporting(visType) { const exporting = { @@ -13,7 +13,7 @@ export default function getExporting(visType) { chartOptions: { chart: { events: { - load: renderSingleValueSVG, + load: loadSingleValueSVG, }, }, }, diff --git a/src/visualizations/config/adapters/dhis_highcharts/index.js b/src/visualizations/config/adapters/dhis_highcharts/index.js index 0f5f11713..1c6b428e9 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/index.js +++ b/src/visualizations/config/adapters/dhis_highcharts/index.js @@ -14,8 +14,8 @@ import { } from '../../../../modules/visTypes.js' import { defaultMultiAxisTheme1 } from '../../../util/colors/themes.js' import addTrendLines, { isRegressionIneligible } from './addTrendLines.js' -import getChart from './chart.js' -import { getCustomSVGOptions } from './customSVGOptions/index.js' +import getChart from './chart/index.js' +import getCustomSVGOptions from './customSVGOptions/index.js' import getExporting from './exporting.js' import getScatterData from './getScatterData.js' import getSortedConfig from './getSortedConfig.js' diff --git a/src/visualizations/config/adapters/dhis_highcharts/subtitle/singleValue.js b/src/visualizations/config/adapters/dhis_highcharts/subtitle/singleValue.js index b7f37ba93..922f142cf 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/subtitle/singleValue.js +++ b/src/visualizations/config/adapters/dhis_highcharts/subtitle/singleValue.js @@ -1,5 +1,5 @@ import getFilterText from '../../../../util/getFilterText.js' -export { getSingleValueTitleColor as getSingleValueSubtitleColor } from '../customSVGOptions/singleValue/index.js' +export { getSingleValueTitleColor as getSingleValueSubtitleColor } from '../customSVGOptions/singleValue/getSingleValueTitleColor.js' export default function getSingleValueSubtitle(layout, metaData) { if (layout.hideSubtitle || 1 === 0) { diff --git a/src/visualizations/config/adapters/dhis_highcharts/title/singleValue.js b/src/visualizations/config/adapters/dhis_highcharts/title/singleValue.js index ab3ceb375..fdf5d891a 100644 --- a/src/visualizations/config/adapters/dhis_highcharts/title/singleValue.js +++ b/src/visualizations/config/adapters/dhis_highcharts/title/singleValue.js @@ -1,5 +1,5 @@ import getFilterText from '../../../../util/getFilterText.js' -export { getSingleValueTitleColor } from '../customSVGOptions/singleValue/index.js' +export { getSingleValueTitleColor } from '../customSVGOptions/singleValue/getSingleValueTitleColor.js' export function getSingleValueTitleText(layout, metaData) { if (layout.hideTitle) {