BookmarkSubscribeRSS Feed

Reading a Graph's Axis Settings

My apologies for what I'm sure is a trivial question, but I can't see it. I can create an empty graph with a couple of lines of script, and change the axis settings to anything I want afterwards: the script below illustrates this if I run the following, then uncomment the second line and rerun it:

gb = graph box(XScale(100, 800), YScale(1000, 2000));

// gb[AxisBox(2)] << min(200) << max(900);

nw = new window("My Window", gb);

But how do I determine what the current settings are if I don't actually know them? That situation could arise if I've pulled one or both axes up or down a bit, and then want to redraw the chart with the new lower and upper limits - which is actually what I'm trying to do at the moment.

Many thanks

Re: Reading a Graph's Axis Settings

Hi Dave

There is a SET but no GET for axis ranges. However, you can (in v9 at least) return the script of the axis into a variable, convert it to a string and then use pattern matching to locate the required information.

Re: Reading a Graph's Axis Settings

Hi Stig - yes of course: many thanks! When all else fails, get hold of the script that created it, break it up and extract the bit you want: I remember now suggesting something very similar in another context just a few weeks ago. I'd better add some examples of how to do it to my personal help file before I forget it yet again :)

Re: Reading a Graph's Axis Settings

Note to development - whilst this technique allows us to react to a user changing the axis scale, we can't react until the next time the script is required to do something. What we really need are OnChange event handlers, along the lines of the OnClose that has been introduced for tables. The ability to react to changes to either the axis range or (more importantly for many apps) the frame box size would be a great help!

Re: Reading a Graph's Axis Settings

Good point. In this instance I want to apply the same axis and/or frame size changes on the chart I'm looking at to several other charts which are on different tabs within the same window, so that all the charts are always exactly synchronised in terms of what they're showing for both data range and size of chart. However, since simply clicking on another tab doesn't actually "do" anything to trigger the resetting of all the other axes, I've hidden the tabs themselves (tab box << show tabs(0)) and instead supplied the user with a set of radio buttons to select the tab they want. Doing it that way enables me to run a short script from the radio box which updates all the axis settings and frame sizes of all the charts before the tab is actually changed. This works very nicely - the effect is that the user is blissfully unaware that he's no longer looking at the same chart, even though the actual data being displayed in it isn't quite the same - but were it not possible to hide the tabs, I might have had a problem achieving that effect.