-
Notifications
You must be signed in to change notification settings - Fork 488
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
Moving Datalabel on top of horizontal bar #44
Comments
Can you create a jsfiddle with what you have so far and post a screenshot of what you are trying to achieve? |
@simonbrunel Please find my code and i have no idea regarding fiddle. As Shown in the below image, As of now both my labels and data labels are mixed.. I want my data labels($95,$90) to be moved right side to the labels(sun,mon) dynamically according to the users wish on top of the bar(what i mean is to move data labels like few millimeters away from labels according to user wish).I am able to place it end or starting or middle but i want data label somewhere between start and center on top of the bar and maintain same for all the bars in barchart. Is there any attribute to do that? Please let me know. |
A jsfiddle greatly helps us to experiment or debug your code and save us lot of time trying to figure out what's going on.
No, there is nothing that will do that magically but you could:
formatter: function(value, context) {
var index = context.dataIndex;
var label = context.chart.data.labels[index];
return label + ': $' + value;
} |
@simonbrunel Hi Simon, PFB the fiddlejs . https://jsfiddle.net/anihow/0us7t2wg/3/ In the above code i am trying to move data labels away from the labels on top of the bar but i,m unable to do. I have tried above options but it is restricting the labels font to be exactly same as data labels and i have observed that data labels are moving on basis of bar but i want them to move on basis of labels (Ex: I am trying to move all data labels 5 millimeters away from the labels independent of the bars). can you please help me with this? |
Thanks for the fiddle, I understand what you are trying to achieve but unfortunately there is no easy/clean way to implement that use case. First, you are facing the following issue for which I still don't have a proper solution (so if you want your labels at the start, you need to make your scale start at zero). Then, you can't align vertically and offset horizontally. The only (very limited) workaround I can suggest (jsfiddle):
It's definitely not ideal. |
@simonbrunel Thanks Simon for the prompt response. It works Good for me. Any plan to implement this feature in any of your future releases? |
Sure but I'm not sure what feature needs to be implemented and how? |
Want to know if there is any way to move data label on top of the bar rather than start,center and End.
I want to move data label to move few pixels away from label in horizontal bar chart. Is there any attributes to achieve this?
The text was updated successfully, but these errors were encountered: