Skip to content

Commit

Permalink
shared tooltip - prevent empty tooltip when all values are null - fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Jan 23, 2020
1 parent 379bacd commit 2e4e409
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/modules/tooltip/Labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class Labels {
this.DOMHandling({
i,
t: tIndex,
j,
ttItems,
values: {
val,
Expand Down Expand Up @@ -184,7 +185,7 @@ export default class Labels {
})
}

DOMHandling({ i, t, ttItems, values, seriesName, shared, pColor }) {
DOMHandling({ i, t, j, ttItems, values, seriesName, shared, pColor }) {
const w = this.w
const ttCtx = this.ttCtx

Expand Down Expand Up @@ -264,6 +265,27 @@ export default class Labels {
ttItemsChildren[0].parentNode.style.display =
w.config.tooltip.items.display
}

if (w.globals.stackedSeriesTotals[j] === 0) {
// shared tooltip and all values are null, so we need to hide the x value too
let allYZeroForJ = true
for (let si = 1; si < w.globals.seriesYvalues.length; si++) {
if (
w.globals.seriesYvalues[si][j] !==
w.globals.seriesYvalues[si - 1][j]
) {
allYZeroForJ = false
}
}

if (allYZeroForJ) {
ttCtx.tooltipTitle.style.display = 'none'
} else {
ttCtx.tooltipTitle.style.display = w.config.tooltip.items.display
}
} else {
ttCtx.tooltipTitle.style.display = w.config.tooltip.items.display
}
}
}

Expand Down

0 comments on commit 2e4e409

Please sign in to comment.