Chart for WinRT > Getting Started > Quick Start > Step 3 of 4: Format the Axes |
In this step, you will add a ChartView object so you can customize the X-Axis.
Add the following code in the Page_Loaded_1 event handler to format the chart axes:
To write the code in Visual Basic:
Visual Basic |
Copy Code
|
---|---|
' set axes titles c1Chart1.View.AxisY.Title = New TextBlock() With {.Text = "Kitchen Electronics"} c1Chart1.View.AxisX.Title = New TextBlock() With {.Text = "Price"} ' set axes bounds c1Chart1.View.AxisX.Min = 0 c1Chart1.View.AxisX.Max = 500 c1Chart1.View.AxisX.MajorUnit = 20 ' Financial formatting c1Chart1.View.AxisX.AnnoFormat = "c" ' axis annotation rotation c1Chart1.View.AxisX.AnnoAngle = "60" |
To write the code in C#:
C# |
Copy Code
|
---|---|
// set axes titles c1Chart1.View.AxisY.Title= new TextBlock() { Text = "Kitchen Electronics" }; c1Chart1.View.AxisX.Title = new TextBlock() { Text = "Price" }; // set axes bounds c1Chart1.View.AxisX.Min = 0; c1Chart1.View.AxisX.Max = 500; c1Chart1.View.AxisX.MajorUnit = 20; // financial formatting c1Chart1.View.AxisX.AnnoFormat = "c"; // axis annotation rotation c1Chart1.View.AxisX.AnnoAngle=60; |
What You've Accomplished
You have successfully formatted the Chart Axes so when you run your application the new format for the axis annotation is applied to the chart.
In the next step you will apply a theme and palette to C1Chart to adjust its appearance.