Charts-kt manages zooming and panning of the visuals.

This is not a "GPU" transformation: it's not just the visuals that are zoomed or panned, but the whole chart that is refreshed, and everything is recomputed.

Enabling zoom and pan

To enable zoom and pan you have access to these properties of a the chart config:

//run highlight-only
chart(data) {

	config {
		events {
	    zoomMode = ZoomMode.XY              // enable zooming on X and Y directions
	    panMode = PanMode.None              // disable panning
		}
	}

	(...)
}

Note that this enables or disables user interactions, however, you can always "force" them by code with chart.zoom() or chart.pan().

The chart's zoom information

Your Chart contains a public Zoom instance that holds your "zoom information".

Zoom ratio

This Zoom contains 2 DirectedZoom classes, one for each direction, and each of these classes stores the ratio and the offset of your zoom.

The more you zoom-in, the higher your ratio, a chart.zoom.xZoom.ratio of 2.0 for example means that your actual chart X-axis is two times larger than the initial one.

Zoom offset

When you move your chart around, the offset is updated to reflect this panning.

But when you zoom in and out, the offset is also updated so the visual elements you are zooming on stay on screen just where you expect them to be.

The zoom event

The ZoomEvent data class contains all changes that reflect a zooming action.

The zoom origin (zoomOriginX, zoomOriginY) is relative to the main charting zone:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9f7b3603-40d1-4e08-bd1c-7182449d322b/Untitled.png

For example if you zoom-in at the top-right corner the zoomOriginX value is 100% and the

zoomOriginY value is 0%.