# Reacting to changes of axis limits

In Kontrast you can plot arrays of data, for example to visualize a
function. To generate the data, you explicitly need to evaluate the
function in a certain value range. A viewer of the interactive
visualization, however, can arbitrarily change the axis limits. To
draw a plot independent of the axis limits, you must
update

the data according to the new limits.

The following examples show how to implement this method by utilizing
the event handlers of the `min`

and
`max`

properties of axes.

The first example is simple: In the callback function the line segment
is updated when the axes limits are changed. You may notice that the
line can be cut

at the graph edges when you zoom out of the
graph very quickly. To avoid this, the plot line can be drawn not only
in the exact limits of each axes but also a little outside, too (see
the comment in the source of this file).

The second example is a more meaningful case. This is a graph of the function

For such function this technique may be useful. If you view this
example on a device with a mouse, try Ctrl + Mouse wheel

to only enlarge the horizontal axis.

The code is almost same as the first example. The difference is that
the segments (`xArray`

) are newly calculated according to
the new range, because this is a curve instead of a line (segment).

A more elaborate case using this technique is shown in Example: Interactive data updates.