Search code examples
c#chartsaxis

Add axis name into chart c#


I'm working with winforms using C#.

I use chart and I want to set the titles of the X- and Y-axis in code. I tried

chart1.chartarea(0).axisX.title = "xxx" 

but it does't work and I don't know why.


Solution

  • I am using the charts control on the web and setting the X and Y axis titles are done in the following way.

    I assume the API would be the same for winforms.

    var chartArea = new ChartArea("MyChart");
    ...
    chartArea.AxisX.Title = "xxx";
    chartArea.AxisY.Title = "yyy";