airblade/chartjs-ror

How can I apply i18n on the tooltip value

Closed this issue · 2 comments

I'm showing the different currency dynamically.

I want to change the dollar sign format at run time,

How could I hack it ? currently, i have some setting in the following

THanks so much

line_chart chart_data, {animation: false, responsive: true, maintainAspectRatio: false,bezierCurve: false}

I do this to format numbers in my tooltips:

Coffeescript:

Chart.helpers.formatNumber = (value) ->
  # Adds thousand separators (commas).
  value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")

View:

line_chart chart_data, {
  multiTooltipTemplate: "<%= Chart.helpers.formatNumber(value) %>"
}

You could add a currency symbol at the start of the template option value.

Hopefully you can adjust that as you need.

This has gone quiet so I'll close it. I'm happy to re-open it if you're still having trouble.