mattosaurus / ChartJSCore

Implementation of Chart.js for use with .NET Core.
GNU General Public License v3.0
116 stars 34 forks source link

Formatting Y axis as currency #4

Closed FBueckert closed 7 years ago

FBueckert commented 7 years ago

I've been playing around with your implementation, and I'm quite enjoying how it works with Chart.js.

I'm running into a problem, though; I want to format my values as currency, but I can only add Doubles as values. It seems like the common chart.js solution is to prepend the values with a currency symbol, as it's just string values. How can I replicate this in ChartJSCore?

mattosaurus commented 7 years ago

Hi @FBueckert, I'm on holiday at the moment so won't be able to look into this until next week. From memory I think double is the only accepted datatype I could get working for this but that there is a prepend or currency flag available somewhere in chart.js. Will get back to you next week on my return.

mattosaurus commented 7 years ago

Hi @FBueckert, I've had a look at this and it's possible to do using the Callback to prefix the label value with the desired currency symbol. I've had to update the package to 1.1.2 as this value was being output in quotes rather than unquoted as needed.

Please see the updated line chart example here, lines 134 to 157.

FBueckert commented 7 years ago

Excellent! Thanks for the update. It's appreciated.