Skip to content

Commit

Permalink
rename hideEmptyShared to hideEmptySeries
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Oct 22, 2023
1 parent 41e293e commit e48c51e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 42 deletions.
5 changes: 1 addition & 4 deletions src/charts/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,7 @@ class Line {
let stackSeries =
w.config.chart.stacked &&
(!this.w.config.chart.stackOnlyBar ||
(this.w.config.series[realIndex] &&
this.w.config.series[realIndex].type &&
(this.w.config.series[realIndex].type === 'bar' ||
this.w.config.series[realIndex].type === '')))
this.w.config.series[realIndex]?.type === 'bar')

for (let j = 0; j < iterations; j++) {
const isNull =
Expand Down
7 changes: 3 additions & 4 deletions src/modules/Range.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,17 +555,16 @@ class Range {
stackedNegs[group][j] = 0
}
let stackSeries =
!this.w.config.chart.stackOnlyBar ||
(gl.series[i] && gl.series[i].type && gl.series[i].type === 'bar')
!this.w.config.chart.stackOnlyBar || gl.series?.[i]?.type === 'bar'

if (stackSeries) {
if (gl.series[i][j] !== null && Utils.isNumber(gl.series[i][j])) {
gl.series[i][j] > 0
? (stackedPoss[group][j] += parseFloat(gl.series[i][j]) + 0.0001)
? (stackedPoss[group][j] +=
parseFloat(gl.series[i][j]) + 0.0001)
: (stackedNegs[group][j] += parseFloat(gl.series[i][j]))
}
}

}
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/modules/settings/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ export default class Options {
enabled: true,
enabledOnSeries: undefined,
shared: true,
hideEmptyShared: true,
hideEmptySeries: true,
followCursor: false, // when disabled, the tooltip will show on top of the series instead of mouse position
intersect: false, // when enabled, tooltip will only show when user directly hovers over point
inverseOrder: false,
Expand Down
67 changes: 34 additions & 33 deletions src/modules/tooltip/Labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class Labels {

let values = this.getValuesToPrint({
i,
j
j,
})

this.printLabels({
Expand All @@ -37,7 +37,7 @@ export default class Labels {
values,
ttItems,
shared,
e
e,
})

// Re-calculate tooltip dimensions now that we have drawn the text
Expand Down Expand Up @@ -78,15 +78,15 @@ export default class Labels {
fn: f.yLbTitleFormatter,
index: i,
seriesIndex: i,
j
j,
})

if (w.config.chart.type === 'treemap') {
seriesName = f.yLbTitleFormatter(String(w.config.series[i].data[j].x), {
series: w.globals.series,
seriesIndex: i,
dataPointIndex: j,
w
w,
})
}

Expand All @@ -100,22 +100,22 @@ export default class Labels {
series: w.globals.seriesRangeStart,
seriesIndex: index,
dataPointIndex: j,
w
w,
}) +
' - ' +
f.yLbFormatter(w.globals.seriesRangeEnd?.[index]?.[j], {
series: w.globals.seriesRangeEnd,
seriesIndex: index,
dataPointIndex: j,
w
w,
})
)
}
return f.yLbFormatter(w.globals.series[index][j], {
series: w.globals.series,
seriesIndex: index,
dataPointIndex: j,
w
w,
})
}
if (shared) {
Expand All @@ -125,7 +125,7 @@ export default class Labels {
fn: f.yLbTitleFormatter,
index: tIndex,
seriesIndex: i,
j
j,
})
pColor = w.globals.colors[tIndex]

Expand All @@ -137,8 +137,8 @@ export default class Labels {
val: f.yLbFormatter(goal.value, {
seriesIndex: tIndex,
dataPointIndex: j,
w
})
w,
}),
}
})
}
Expand All @@ -161,8 +161,8 @@ export default class Labels {
val: f.yLbFormatter(goal.value, {
seriesIndex: i,
dataPointIndex: j,
w
})
w,
}),
}
})
}
Expand All @@ -174,7 +174,7 @@ export default class Labels {
val = f.yLbFormatter(w.globals.series[i], {
...w,
seriesIndex: i,
dataPointIndex: i
dataPointIndex: i,
})
}

Expand All @@ -188,11 +188,11 @@ export default class Labels {
goalVals,
xVal,
xAxisTTVal,
zVal
zVal,
},
seriesName,
shared,
pColor
pColor,
})
}
}
Expand Down Expand Up @@ -224,21 +224,21 @@ export default class Labels {
if (w.globals.yLabelFormatters[0]) {
yLbFormatter = w.globals.yLabelFormatters[0]
} else {
yLbFormatter = function(label) {
yLbFormatter = function (label) {
return label
}
}
}

if (typeof yLbTitleFormatter !== 'function') {
yLbTitleFormatter = function(label) {
yLbTitleFormatter = function (label) {
return label
}
}

return {
yLbFormatter,
yLbTitleFormatter
yLbTitleFormatter,
}
}

Expand All @@ -248,7 +248,7 @@ export default class Labels {
series: w.globals.series,
seriesIndex,
dataPointIndex: j,
w
w,
})
}

Expand Down Expand Up @@ -359,15 +359,17 @@ export default class Labels {

if (shared && ttItemsChildren[0]) {
// hide when no Val or series collapsed
if (w.config.tooltip.hideEmptyShared) {
let ttItemMarker = ttItems[t].querySelector('.apexcharts-tooltip-marker');
let ttItemText = ttItems[t].querySelector('.apexcharts-tooltip-text');
if (w.config.tooltip.hideEmptySeries) {
let ttItemMarker = ttItems[t].querySelector(
'.apexcharts-tooltip-marker'
)
let ttItemText = ttItems[t].querySelector('.apexcharts-tooltip-text')
if (parseFloat(val) == 0) {
ttItemMarker.style.display = 'none';
ttItemText.style.display = 'none';
ttItemMarker.style.display = 'none'
ttItemText.style.display = 'none'
} else {
ttItemMarker.style.display = 'block';
ttItemText.style.display = 'block';
ttItemMarker.style.display = 'block'
ttItemText.style.display = 'block'
}
}
if (
Expand Down Expand Up @@ -418,7 +420,7 @@ export default class Labels {
series: w.globals.series,
seriesIndex: i,
dataPointIndex: j,
w
w,
}

let zFormatter = w.globals.ttZFormatter
Expand All @@ -430,9 +432,8 @@ export default class Labels {
xVal = filteredSeriesX[i][j]
if (filteredSeriesX[i].length === 0) {
// a series (possibly the first one) might be collapsed, so get the next active index
const firstActiveSeriesIndex = this.tooltipUtil.getFirstActiveXArray(
filteredSeriesX
)
const firstActiveSeriesIndex =
this.tooltipUtil.getFirstActiveXArray(filteredSeriesX)
xVal = filteredSeriesX[firstActiveSeriesIndex][j]
}
} else {
Expand All @@ -452,7 +453,7 @@ export default class Labels {
{
i: undefined,
dateFormatter: new DateTime(this.ctx).formatDate,
w: this.w
w: this.w,
}
)
} else {
Expand Down Expand Up @@ -485,7 +486,7 @@ export default class Labels {
val: Array.isArray(val) ? val.join(' ') : val,
xVal: Array.isArray(xVal) ? xVal.join(' ') : xVal,
xAxisTTVal: Array.isArray(xAxisTTVal) ? xAxisTTVal.join(' ') : xAxisTTVal,
zVal
zVal,
}
}

Expand All @@ -505,7 +506,7 @@ export default class Labels {
dataPointIndex: j,
y1,
y2,
w
w,
})
}
}
2 changes: 2 additions & 0 deletions types/apexcharts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type ApexChart = {
}
stacked?: boolean
stackType?: 'normal' | '100%'
stackOnlyBar?: boolean;
toolbar?: {
show?: boolean
offsetX?: number
Expand Down Expand Up @@ -941,6 +942,7 @@ type ApexTooltip = {
fillSeriesColor?: boolean
theme?: string
cssClass?: string
hideEmptySeries?: boolean
style?: {
fontSize?: string
fontFamily?: string
Expand Down

0 comments on commit e48c51e

Please sign in to comment.