ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  X axis scale
Posted by Dermot on Jan-08-2019 07:59
Can I change the x-axis scale after I plot the chart on a scatter layer.

For example my data range on x is 0-10.
Initiall I set the xAxis as

this.XY.xAxis().setAutoScale(.05, .05, 0);

After the chart is plotted, the user wants to change to 0-20 [maybe to make a comparison with another chart].

Can I simply call

this.XY.xAxis().setLinearScale(0, 20);

How do I refresh the chart to use the updated axis settings.


  Re: X axis scale
Posted by Peter Kwan on Jan-09-2019 03:27
Hi Dermot,

Once a chart is plotted, you can only add simple lines, shapes and text on top, usually used for programmable track cursors. The axis scale or data layers cannot be changed.

For user configurable charts, the usual method is to use variables to represent all parameters that are configurable by the user. You can have a user interface like a "property sheet" to allow the user to configure the parameters. There is a drawChart subroutine that draws the chart based on the parameters. No matter which parameter is changed, the code just calls drawChart to update the display.

The "Interactive Finance Chart" sample code is an example of a chart with a lot of user configurable parameters. No matter what the user has changed, the code just calls drawChart to update the display.

For your particular case, you may set up two variables (min_x_value and max_x_value) and has a user interface to allow the user to set those values. The initial value can be both 0, and the charting code can treat it to mean auto-scaling. So it is like:

void drawChart()
    XYChart c = new XYChart(.....);

    if (min_x_scale != max_x_scale)
        c.xAxis().setLinearScale(min_x_scale, max_x_scale);


Hope this can help.

Peter Kwan