Skip to content

Commit

Permalink
fix: avoid crash in DV with some chart types DHIS2-15882 (#1582)
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo authored Sep 28, 2023
1 parent f3a6f3b commit f6c89e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/visualizations/config/adapters/dhis_highcharts/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const getEvents = () => ({
if (item.legendSymbol) {
item.legendSymbol.attr({
translateY:
-((item.legendItem.getBBox().height * 0.75) / 4) +
-(
(item.legendItem.label.getBBox().height *
0.75) /
4
) +
item.legendSymbol.r / 2,
})
}
Expand Down
11 changes: 7 additions & 4 deletions src/visualizations/config/generators/highcharts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ function drawLegendSymbolWrap() {
H.seriesTypes.column.prototype,
'drawLegendSymbol',
function (proceed, legend, item) {
const legendItem = item.legendItem

if (this.options.legendSet?.legends?.length) {
const ys = legend.baseline - legend.symbolHeight + 1, // y start
x = legend.symbolWidth / 2 > 8 ? legend.symbolWidth / 2 : 8, // x start
Expand All @@ -32,7 +34,7 @@ function drawLegendSymbolWrap() {
.attr({
fill: legends[legends.length >= 5 ? 1 : 0].color,
})
.add(this.legendGroup)
.add(legendItem.group)
this.chart.renderer
.path(['M', x, ye, 'A', 1, 1, 0, 0, 0, x, ys, 'V', ye])
.attr({
Expand All @@ -42,13 +44,14 @@ function drawLegendSymbolWrap() {
: legends.length - 1
].color,
})
.add(this.legendGroup)
.add(legendItem.group)
} else {
var options = legend.options,
symbolHeight = legend.symbolHeight,
square = options.squareSymbol,
symbolWidth = square ? symbolHeight : legend.symbolWidth
item.legendSymbol = this.chart.renderer

legendItem.symbol = this.chart.renderer
.rect(
square ? (legend.symbolWidth - symbolHeight) / 2 : 0,
legend.baseline - symbolHeight + 1,
Expand All @@ -60,7 +63,7 @@ function drawLegendSymbolWrap() {
.attr({
zIndex: 3,
})
.add(item.legendGroup)
.add(legendItem.group)
}
}
)
Expand Down

0 comments on commit f6c89e1

Please sign in to comment.