Origin Version: Origin 8.5.1 SR2 b315
Operating System: Windows 7 Enterprise SP1
I am having trouble centering the y axis label.
In my code I loop over each layer and set the axis scales and text.
1) I tried to center the y axis using the following:
LT_execute("yl.y = layer.y.from + (layer.y.to - layer.y.from) / 2;");
It did not work when I executed the code.
However, if I set a break point and run through it, then it centers correctly.
2) I have also tried centering the label using this code:
GraphObject grYL = layer.GraphObjects("YL");
grYL.Y = layer.Y.From + ( (layer.Y.To - layer.Y.From) / 2.0 );
It acts the same way as my first method.
3) Next I tried setting the y position outside of the loop using this code:
LT_execute("int lLayerCount = 0; doc -e LW { if( lLayerCount != 18 ){ yl.y = layer.y.from + ( (layer.y.to - layer.y.from) / 2 ); } lLayerCount++; }");
It too did not work unless a break point was set.
4) The only way I have gotten the labels to center correctly is to set the script in the template's Programming Control to the following:
yl.y = layer.y.from + ( layer.y.to - layer.y.from ) / 2;
yl.x = layer.x.from - ( layer.x.to - layer.x.from )*0.7 - yl.dx;
But if I use this method then the users won't be able to move the labels on their own or will have to delete the labels' script. (I had to set the x position because otherwise the labels were positioned at the left side of the page.)
What am I doing wrong?