ExpertPDF Components: .NET Chart Control

WebChart axis settings

Learn how you can customize the chart axis.

Axis Settings

ExpertChart control offers the possibility to customize the following properties:

- display grid lines
- change axis labels color and font
- change axis line thickness and color
- change axis display range
- change axis tickmarks interval
- change the space between the axis and the edge of the chart

100 100 200 200 110 170 300 140 290 100 60 100 300 160 120 200 120 190 For more information visit www.chartingcontrol.net

Source code

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            WebChart1.DataSource = ExpertChart.Demo.DataSources.GetTestData2();
 
            // display grid lines
            WebChart1.Axis.Y.MajorGridLines.Visible = true;
            WebChart1.Axis.Y.MajorGridLines.Color = Color.Gray;
 
            // change axis labels color and font
            WebChart1.Axis.X.LabelsColor = Color.Green;
            WebChart1.Axis.Y.LabelsColor = Color.Red;
            WebChart1.Axis.Y.LabelsFont = new Font("Verdana", 8);
 
            // change axis line thickness and color
            WebChart1.Axis.Y.Size = 1;
            WebChart1.Axis.Y.Color = Color.Blue;
            WebChart1.Axis.X.Size = 1;
            WebChart1.Axis.X.Color = Color.Blue;
 
            // change axis display range
            WebChart1.Axis.Y.ScaleRange.Type = ExpertChart.ScaleRangeType.UserDefined;
            WebChart1.Axis.Y.ScaleRange.ValueLow = 40;
            WebChart1.Axis.Y.ScaleRange.ValueHigh = 320;
 
            // change axis tickmarks interval
            WebChart1.Axis.Y.Ticks.Type = ExpertChart.TicksType.UserDefined;
            WebChart1.Axis.Y.Ticks.Interval = 20;
 
            // change the space between the axis and the edge of the chart
            WebChart1.Axis.X.Space = 50;
            WebChart1.Axis.Y.Space = 25;
 
        }
    }

Copyright 2008. ExpertComponents.com ChartingControl.NET.