You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 30, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 30, 2025. It is now read-only.
Hello, thanks for reporting the issue. Barcharts should be supported and work with tooltips, but maybe there's a bug.
Could you post some example code that doesn't work?
Thanks for providing an example. I'm currently heavily occupied with projects for university. Maybe I can find a few spare hours in the next few weeks, but I can't guarantee it. Starting in March, I've got more resources to fix issues on GitHub.
In the meantime maybe @stklcode can help you out, as he authored the most recent pull request #20.
Otherwise if the issue is severe for you, I would recommend to downgrading to an older versions of chartist.
I found a workaround for anyone else who's trying to do this. I'm using chartist in VueJS but I don't think it matters, it's just javascript.
Here's my code:
this.chart.on('draw',(data)=>{if(data.type==='bar'){// Add mouseover event listener to the bar or pointdata.element._node.onmouseover=()=>{// Find the tooltip div and add the 'tooltip-show' classconsttooltip=document.querySelector('.chartist-tooltip');if(tooltip){tooltip.classList.add('tooltip-show');// Create a new span element for the tooltip valueconstvalueSpan=document.createElement('span');valueSpan.classList.add('chartist-tooltip-value');// Set the text of the span to the value of the bar or pointvalueSpan.textContent=' '+data.value.y+'kW';// Append the span to the tooltip divtooltip.appendChild(valueSpan);// Get the bounding box of the bar or pointconstbbox=data.element._node.getBoundingClientRect();// Set the position of the tooltip to the top of the bar or pointtooltip.style.left=(bbox.left+bbox.right)/2-tooltip.offsetWidth/2+'px';// Centres the tooltip horizontallytooltip.style.top=bbox.top-tooltip.offsetHeight-15+'px';// I needed to raise this by 15px to stop overlap. It should hover over the top of the bar (or segment, if it's a stacked bar chart)}};// Add mouseout event listener to the bar or pointdata.element._node.onmouseout=()=>{// Find the tooltip div and remove the 'tooltip-show' classconsttooltip=document.querySelector('.chartist-tooltip');if(tooltip){tooltip.classList.remove('tooltip-show');// Remove the tooltip value spanconstvalueSpan=tooltip.querySelector('.chartist-tooltip-value');if(valueSpan){tooltip.removeChild(valueSpan);}}}
You can also add a span element for the meta value in the same way.
Activity
lukbukkit commentedon Jan 23, 2023
Hello, thanks for reporting the issue. Barcharts should be supported and work with tooltips, but maybe there's a bug.
Could you post some example code that doesn't work?
DGollings commentedon Jan 23, 2023
Hi,
Created one here
Although for whatever reason enabling linechart breaks everything. But the barchart doesn't work so I guess that's a good enough example
Anyway, 'proof' LineChart works locally (excuse the bad/mismatched styling, just dropped the code in a random project)
lukbukkit commentedon Jan 26, 2023
Thanks for providing an example. I'm currently heavily occupied with projects for university. Maybe I can find a few spare hours in the next few weeks, but I can't guarantee it. Starting in March, I've got more resources to fix issues on GitHub.
In the meantime maybe @stklcode can help you out, as he authored the most recent pull request #20.
Otherwise if the issue is severe for you, I would recommend to downgrading to an older versions of chartist.
stklcode commentedon Jan 27, 2023
At the current state there is no real modular integration. I don't know why it actually works for line charts the way it's integrated in the example.
Non-Modular integration for BarCharts works fine, e.g. using the very same chart from the example:
https://stackblitz.com/edit/js-cnnsqb?file=package.json,index.html,index.js
Jonas096 commentedon Mar 26, 2024
Is there any updates to this issue? We are facing this issue after upgrading chartist.
lukbukkit commentedon Mar 30, 2024
Hi, @Jonas096. As of now, there are no updates on this issue. Currently, I don't have the capacity to work on the issue. I'm sorry about that.
Jonas096 commentedon Apr 2, 2024
@lukbukkit thanks for the answer.
emilyDZC commentedon Apr 30, 2024
I found a workaround for anyone else who's trying to do this. I'm using chartist in VueJS but I don't think it matters, it's just javascript.
Here's my code:
You can also add a span element for the meta value in the same way.