Make Y axis display dollar amounts


#1

How would I go about getting the Y axis to display dollar amounts in the format of $1,234.56 ? Currently it displays that same number in the style of 1234.5.

This is in C# btw. Thanks.


#2

Hi Architekt,

There are two ways to format the axis labels: for simple formatting you can use the labelFormatString property, which provides a string for use byNSString’s stringWithFormat: method (or NSDateFormatter for date axes); for more complex formatting such as currencies, we recommend using the labelFormatter property as follows in Xamarin.iOS:

        SChartTickLabelFormatter formatter = SChartTickLabelFormatter.NumberFormatter;
        NSNumberFormatter numberFormatter = (NSNumberFormatter)formatter.Formatter;
        numberFormatter.NumberStyle = NSNumberFormatterStyle.Currency;

        chart.YAxis = new SChartNumberAxis { 
            Title = "Price (USD)",
            LabelFormatter = formatter
        };

I hope that helps.

Kind regards,

Alison