@@ -232,10 +232,16 @@ function selectDatapoint(datapoint, index) {
232232
233233const dataTooltipSlot = ref (null );
234234const useCustomFormat = ref (false );
235+ const selectedIndex = ref (null );
235236
236237function useTooltip ({ datapoint, seriesIndex }) {
238+ if (! FINAL_CONFIG .value .style .tooltip .show ) {
239+ return
240+ }
241+
237242 dataTooltipSlot .value = { datapoint, seriesIndex, config: FINAL_CONFIG .value , series: absoluteDataset .value };
238243 isTooltip .value = true ;
244+ selectedIndex .value = seriesIndex;
239245 const customFormat = FINAL_CONFIG .value .style .tooltip .customFormat ;
240246
241247 if (isFunction (customFormat)) {
@@ -320,12 +326,16 @@ function useTooltip({ datapoint, seriesIndex }) {
320326 </defs >
321327 <g clip-path =" url(#stackPill)" v-if =" total > 0" >
322328 <rect
323- :x =" 0"
324- :y =" 0"
325- :height =" svg.height"
326- :width =" drawableDataset.map(ds => ds.width).reduce((a, b) => a + b, 0)"
329+ v-for =" (rect, i) in drawableDataset" :key =" `stack_underlayer_${i}`"
330+ :x =" rect.start"
331+ :y =" 0"
332+ :width =" rect.width"
333+ :height =" svg.height"
327334 :fill =" FINAL_CONFIG.style.bar.gradient.underlayerColor"
328335 :class =" {'animated': !isLoading}"
336+ :style =" {
337+ opacity: (selectedIndex !== null && FINAL_CONFIG.style.tooltip.show) ? selectedIndex === i ? 1 : 0.5 : 1
338+ }"
329339 />
330340 <rect
331341 v-for =" (rect, i) in drawableDataset" :key =" `stack_${i}`"
@@ -337,10 +347,13 @@ function useTooltip({ datapoint, seriesIndex }) {
337347 :stroke =" FINAL_CONFIG.style.backgroundColor"
338348 stroke-linecap =" round"
339349 :class =" {'animated': !isLoading}"
350+ :style =" {
351+ opacity: (selectedIndex !== null && FINAL_CONFIG.style.tooltip.show) ? selectedIndex === i ? 1 : 0.5 : 1
352+ }"
340353 />
341354 <!-- TOOLTIP TRAPS -->
342355 <rect
343- v-for =" (rect, i) in drawableDataset" :key =" `stack_ ${i}`"
356+ v-for =" (rect, i) in drawableDataset" :key =" `stack_trap_ ${i}`"
344357 @click =" () => selectDatapoint(rect, i)"
345358 :x =" rect.start"
346359 :y =" 0"
@@ -350,7 +363,7 @@ function useTooltip({ datapoint, seriesIndex }) {
350363 stroke =" none"
351364 :class =" {'animated': !isLoading}"
352365 @mouseenter =" () => useTooltip({ datapoint: rect, seriesIndex: i })"
353- @mouseleave =" isTooltip = false"
366+ @mouseleave =" isTooltip = false; selectedIndex = null "
354367 />
355368 </g >
356369 <rect v-else
0 commit comments