Skip to content

Commit

Permalink
fix: radar clashing axis titles (#618)
Browse files Browse the repository at this point in the history
* fix: add textAlign for radar X axis title

* refactor: use default as base for radar
  • Loading branch information
martinkrulltott authored Sep 22, 2020
1 parent 888bf49 commit c875950
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import getAxisTitle from '../getAxisTitle'
import getCategories from '../getCategories'
import getYearOnYear from './yearOnYear'
import getTwoCategory from './twoCategory'
import getRadar from './radar'
import {
VIS_TYPE_GAUGE,
VIS_TYPE_YEAR_OVER_YEAR_LINE,
VIS_TYPE_YEAR_OVER_YEAR_COLUMN,
VIS_TYPE_PIE,
isTwoCategoryChartType,
VIS_TYPE_RADAR,
isTwoCategoryChartType,
} from '../../../../../modules/visTypes'
import {
FONT_STYLE_HORIZONTAL_AXIS_TITLE,
Expand All @@ -32,7 +34,7 @@ export const getLabelsStyle = fontStyle => fontStyle ? {
},
} : {}

const getDefault = (store, layout) =>
export const getDefault = (store, layout) =>
objectClean({
categories: getCategories(store.data[0].metaData, layout.rows[0].dimension),
title: getAxisTitle(layout.domainAxisLabel, layout.fontStyle[FONT_STYLE_HORIZONTAL_AXIS_TITLE], FONT_STYLE_HORIZONTAL_AXIS_TITLE, layout.type),
Expand All @@ -54,6 +56,9 @@ export default function(store, layout, extraOptions) {
case VIS_TYPE_YEAR_OVER_YEAR_COLUMN:
xAxis = [getYearOnYear(store, layout, extraOptions)]
break
case VIS_TYPE_RADAR:
xAxis = [getRadar(store, layout)]
break
default:
xAxis = [getDefault(store, layout)]
}
Expand Down
13 changes: 13 additions & 0 deletions src/visualizations/config/adapters/dhis_highcharts/xAxis/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import isString from 'd2-utilizr/lib/isString'
import { FONT_STYLE_HORIZONTAL_AXIS_TITLE, FONT_STYLE_OPTION_TEXT_ALIGN, TEXT_ALIGN_CENTER } from '../../../../../modules/fontStyle'
import { getDefault } from './'

export default (store, layout) => {
const config = getDefault(store, layout)

if (isString(layout.domainAxisLabel) && config.title && layout.fontStyle[FONT_STYLE_HORIZONTAL_AXIS_TITLE][FONT_STYLE_OPTION_TEXT_ALIGN] === TEXT_ALIGN_CENTER) {
config.title.textAlign = 'right'
}

return config
}

0 comments on commit c875950

Please sign in to comment.