This is a migrated thread and some comments may be shown as answers.

RadChartView formatting a linear axis as currency?

3 Answers 353 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Rich
Top achievements
Rank 2
Rich asked on 18 Jun 2020, 08:17 PM

Not sure if this is the right place to post, as I am not seeing any specific category for Charts(except the defunct one)

The issue:  I'm building my forst RadChartView based on a simple  query for "Vendor", and "Amount"

Amount, is a decimal in the database, and I'd like to have the Y axis display the values in currency format.

 

I'm not finding how to do this..?

 

Many thanks,

Rich

 

3 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 19 Jun 2020, 01:21 PM

Hello Rich,

In order to set some custom format to the Y-axis, you should access it and set its LabelFormat property. The following article demonstrates how you can access the Linear axis: https://docs.telerik.com/devtools/winforms/controls/chartview/axes/linear.

Since I am not sure which series you choose to use in your application I prepared an example with LineSeries that plots one categorical (X-axis) and one numerical axis (Y-axis). Please refer to the following code snippet:

public RadForm1()
{
    InitializeComponent();
    DataTable table = new DataTable();
    table.Columns.Add("Value", typeof(double));
    table.Columns.Add("Vendor", typeof(string));
    table.Rows.Add(305.50, "Sams");
    table.Rows.Add(380.80, "AliExpress");
    table.Rows.Add(550.50, "Alibaba");
    table.Rows.Add(120.00, "Marshal");
    table.Rows.Add(100.90, "Oysho");

    LineSeries lineSeries = new LineSeries();
    this.radChartView1.Series.Add(lineSeries);
    lineSeries.DataSource = table;
    lineSeries.ValueMember = "Value";
    lineSeries.CategoryMember = "Vendor";

    LinearAxis verticalAxis = lineSeries.VerticalAxis as LinearAxis;
    verticalAxis.LabelFormat = "{0:C}";
}

I hope this helps. Should you have further questions do not hesitate to contact me.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Rich
Top achievements
Rank 2
answered on 19 Jun 2020, 03:10 PM

Howdy, & thanks for the reply.

I'm happy to report that I've fixed the issue.

I ended up simply plugging in your format string, into the  "Format String" of the "Linear Axis", under "Property Pages"

It's funny how easy it was: all I needed was the format string..

If I had explained in greater detail what I already had running, you would have likely proposed the same thing, I'm sure..

Thanks again!

Rich

 

0
Nadya | Tech Support Engineer
Telerik team
answered on 22 Jun 2020, 02:38 PM

Hi Rich,

I am glad that you managed to found out the right solution for achieving your goal. If you have any further questions, I will be glad to help.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Rich
Top achievements
Rank 2
Answers by
Nadya | Tech Support Engineer
Telerik team
Rich
Top achievements
Rank 2
Share this question
or