Script to change a chart's x axis title

Hi


I'm trying to change the title of the x axis in a chart via a script. I have set it via the user interface as you can see in the screenshot below.



I want to now change it via script based on the user selection.


I tried

chart1.control.xAxis.title = "YTD "18";
chart1.control.invalidate();

but this didn't work.


What am I missing here?

Since you can have multiple axes, you have to indicate which one it is. I assume you are only using one, so try changing the first line to:


chart1.control.xAxes[0].title = "YTD ''18";

Thanks Elia, with only one axis then xAxis is the same as xAxes[1].


This was a case of user error - I was looking at the wrong chart :(