3

I am trying to display labels on top of bars using chart.js. My Y.-Axis has custom labels, like: scaleLabel : "<%= value + '$' %>"

So, my bar chart y.axis would be something like 1000$, 2000$ etc.. When I display lables on top of each bar, the values are displayed as 1000, 2000 etc.. Is there a way to display custom y-axis label on top of each bar?

I am looking something like, instead of 5000, how can i display "5000$" on top of each bar?

1 Answer 1

2

If you have a single dataset set the tooltipTemplate in the options.

If you have several datasets set the multiTooltipTemplate in the options.

var options = {
  scaleLabel : "<%= value + '$' %>",
  // String - Template string for single tooltips
  tooltipTemplate: "<%if (label){%><%=label %>: <%}%><%= value + '$' %>",
  // String - Template string for multiple tooltips
  multiTooltipTemplate: "<%= value + '$' %>",
};

See an example here.

And the documentation here.

Sign up to request clarification or add additional context in comments.

1 Comment

I thought he was asking for the values to display on the bar chart "permanently" (not just on hover). That's what I need. I did upvote, BTW.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.