-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace rectangles in tooltip with circle #3938
Comments
I presume you meant the For instance, for line charts, you can adapt https://github.com/chartjs/Chart.js/blob/master/samples/tooltips/line-customTooltips.html like so https://jsfiddle.net/djgLw47L/ (all I did was add Cheers! |
@singhrasster that's the only place you're going to need to change the drawing code. You can also use the html tooltips as @potatopeelings suggested 😄 |
You can make a custom tooltip and assign a css class to it where height equals width, and the border radius is high enough that it's a circle. You can probably even implement it with dynamic sizes. |
Thank you all for your answers. I am using Chart.js with an app that uses Angular 2. So, its all typescript code for me. I am using the following to set options for the bar chart: public barChartOptions:any = { Can I tweak any of this to replace rectangle with circles? I am using ng2 charts directive so my html looks like: <canvas baseChart" Right now, I am not very clear on how to use in my case. Or, how to create a custom tooltip and assign a css class to it for my case. |
In order to make the tooltip round, set its width, height, and border radius to the same value. So, Will make it fully round. You can then adjust the text stiling to sit right in the middle of the tooltip with another class. You can find examples of tooltips here https://github.com/chartjs/Chart.js/tree/master/samples/tooltips |
I checked out the sample and since its all Javascript, the customTooltips variable is also a JS variable: var customTooltips = function(tooltip) { But, I am using Angular 2 where I am creating chart and settings all its options in a Typescript class. Below is the Typescript code where I am setting options: So, my question is how would I use the customTooltips JS variable (as created in your samples) in my Typescript code to set this custom tooltip? Is that possible? Let me know if I need to explain my question more. |
@singhrasster - TypeScript accepts native JavaScript, so you should be able to just pop in the same code and the CSS rule (I don't know enough of Angular2 to say which is the right place for it though) and make it work. If it doesn't, can you set up a TypeScript CodePen with your setup (Angular2, ng2charts, Chart.js)? |
Closing as answered |
@potatopeelings It would be much simpler to simply have an extra option in tooltip options Something like:
and btw, if one would like in css to convert a square to circle one should use:
Just a suggestion 😃 |
I need to change the rectangular color boxes in the tooltip to circular with a size I want. Since this is not possible using the custom tooltip properties, and if this is not a feature you plan to add, are there any pointers you can give on how I can modify the draw function to achieve this? Will it be too complex?
In file Chart.bundle.js,
Is the section of code inside
if (drawColorBoxes) {
..
..
}
all that need to be modified or it will be more than that? It seemed like fillRect is one of the things that will need to be replaced with something that draws a circle instead. I played a bit with it but couldn't get it working. If this task is simple enough to provide some support/pointers, please let me know. That will be useful for us.
The text was updated successfully, but these errors were encountered: