Repository: chartjs/chartjs-plugin-zoom (js)

Issue:
onZoom callbacks for zoomScale function
When using `zoomScale`, callbacks for zoom (onZoom etc.) are not triggered.

Pull request:
fix: trigger onZoom from zoomScale
fix #775

Patch:
diff --git a/src/core.js b/src/core.js
index d0b3d33..c581a5f 100644
--- a/src/core.js
+++ b/src/core.js
@@ -108,10 +108,13 @@ export function zoomRect(chart, p0, p1, transition = 'none') {
 }
 
 export function zoomScale(chart, scaleId, range, transition = 'none') {
-  storeOriginalScaleLimits(chart, getState(chart));
+  const state = getState(chart);
+  storeOriginalScaleLimits(chart, state);
   const scale = chart.scales[scaleId];
   updateRange(scale, range, undefined, true);
   chart.update(transition);
+
+  call(state.options.zoom?.onZoom, [{chart}]);
 }
 
 export function resetZoom(chart, transition = 'default') {
@@ -130,6 +133,7 @@ export function resetZoom(chart, transition = 'default') {
     delete state.updatedScaleLimits[scale.id];
   });
   chart.update(transition);
+
   call(state.options.zoom.onZoomComplete, [{chart}]);
 }
 


Test patch:
diff --git a/test/specs/api.spec.js b/test/specs/api.spec.js
index 7102591..2b6360f 100644
--- a/test/specs/api.spec.js
+++ b/test/specs/api.spec.js
@@ -240,6 +240,35 @@ describe('api', function() {
     });
   });
 
+  describe('zoomScale', function() {
+    it('should call onZoom', function() {
+      const zoomSpy = jasmine.createSpy('start');
+      const chart = window.acquireChart({
+        type: 'scatter',
+        data: {
+          datasets: [
+            {
+              data: [{x: 1, y: 1}, {x: 10, y: 10}],
+            },
+          ],
+        },
+        options: {
+          plugins: {
+            zoom: {
+              zoom: {
+                onZoom: zoomSpy,
+              }
+            }
+          }
+        }
+      });
+
+      chart.zoomScale('x', {min: 2, max: 10}, 'default');
+
+      expect(zoomSpy).toHaveBeenCalledWith({chart});
+    });
+  });
+
   describe('getInitialScaleBounds', function() {
     it('should provide the correct initial scale bounds regardless of the zoom level', function() {
       const chart = window.acquireChart({