hansmaad / chartist-plugin-zoom

Zoom Plugin for Chartist.js
Do What The F*ck You Want To Public License
17 stars 15 forks source link

Added noClipY option #17

Open SleepProgger opened 5 years ago

SleepProgger commented 5 years ago

This PR adds an option to only clip the x axis which is a common requirement when working with line graphs.

I had to move getRect into the plugin function to be able to access options and chartRect. To keep it consistent i moved all the other functions outside also into the plugin. An alternative would be to do the work in each event callback, but tbh. i don't see any real problem with the functions being inside the plugin.

SleepProgger commented 5 years ago

Additionally i added an autoscale y axis feature where axisY.highLow is set to the largest/lowest y value which will be displayed. The corresponding option autoZoomY supports boolean values to enable both lower and upper bounds scaling and objects like {high: boolean, low: boolean} to enable only upper or lower bounds scaling.

Demo here: https://jsfiddle.net/k5ov3f7u/5/