Skip to content

Commit

Permalink
fix: avoid crash in DV with some chart types (DHIS2-15882) [24.x] (#1651
Browse files Browse the repository at this point in the history
)

* fix: avoid crash in DV with some chart types DHIS2-15882 (#1582)

* fix: upgrade highcharts to be compatible with code change

---------

Co-authored-by: Edoardo Sabadelli <[email protected]>
  • Loading branch information
jenniferarnesen and edoardo authored Apr 3, 2024
1 parent 85f45eb commit 68907d2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"classnames": "^2.3.1",
"d2-utilizr": "^0.2.16",
"d3-color": "^1.2.3",
"highcharts": "^10.2.0",
"highcharts": "^10.3.3",
"lodash": "^4.17.21",
"mathjs": "^9.4.2",
"react-beautiful-dnd": "^10.1.1",
Expand Down
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
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10517,10 +10517,10 @@ hex-color-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==

highcharts@^10.2.0:
version "10.2.0"
resolved "https://registry.yarnpkg.com/highcharts/-/highcharts-10.2.0.tgz#646b1c80fb4add9e35e5813bd87419ccdf1fc6b7"
integrity sha512-MvLo4dzR2Vo7Y85dsqJ07uabBXSSIRKRRdW4l9IGP55h2jYWNm/m9JBszVVxySH5Lda6g+Ins9NdGppZJpjNCA==
highcharts@^10.3.3:
version "10.3.3"
resolved "https://registry.yarnpkg.com/highcharts/-/highcharts-10.3.3.tgz#b8acca24f2d4b1f2f726540734166e59e07b35c4"
integrity sha512-r7wgUPQI9tr3jFDn3XT36qsNwEIZYcfgz4mkKEA6E4nn5p86y+u1EZjazIG4TRkl5/gmGRtkBUiZW81g029RIw==

highlight.js@^10.1.1, highlight.js@~10.5.0:
version "10.5.0"
Expand Down

0 comments on commit 68907d2

Please sign in to comment.