hyperprop-charting-library 0.1.47 → 0.1.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2511,6 +2511,16 @@ function createChart(element, options = {}) {
2511
2511
  emitViewportChange();
2512
2512
  draw();
2513
2513
  };
2514
+ const zoomXFromAxis = (factor) => {
2515
+ if (!drawState) {
2516
+ return;
2517
+ }
2518
+ if (followLatest) {
2519
+ zoomXToLatest(factor);
2520
+ return;
2521
+ }
2522
+ zoomX(factor, drawState.chartLeft + drawState.chartWidth / 2);
2523
+ };
2514
2524
  const zoomY = (factor, anchorY) => {
2515
2525
  if (!drawState || data.length === 0) {
2516
2526
  return;
@@ -3034,7 +3044,7 @@ function createChart(element, options = {}) {
3034
3044
  setCrosshairPoint(null);
3035
3045
  } else if (dragMode === "x-axis") {
3036
3046
  canvas.style.cursor = "ew-resize";
3037
- zoomXToLatest(Math.exp(deltaX * 6e-3));
3047
+ zoomXFromAxis(Math.exp(deltaX * 6e-3));
3038
3048
  setCrosshairPoint(null);
3039
3049
  } else if (dragMode === "y-axis") {
3040
3050
  canvas.style.cursor = "ns-resize";
@@ -3145,7 +3155,7 @@ function createChart(element, options = {}) {
3145
3155
  return;
3146
3156
  }
3147
3157
  if (region === "x-axis") {
3148
- zoomXToLatest(factor);
3158
+ zoomXFromAxis(factor);
3149
3159
  return;
3150
3160
  }
3151
3161
  zoomX(factor, point.x);
@@ -2487,6 +2487,16 @@ function createChart(element, options = {}) {
2487
2487
  emitViewportChange();
2488
2488
  draw();
2489
2489
  };
2490
+ const zoomXFromAxis = (factor) => {
2491
+ if (!drawState) {
2492
+ return;
2493
+ }
2494
+ if (followLatest) {
2495
+ zoomXToLatest(factor);
2496
+ return;
2497
+ }
2498
+ zoomX(factor, drawState.chartLeft + drawState.chartWidth / 2);
2499
+ };
2490
2500
  const zoomY = (factor, anchorY) => {
2491
2501
  if (!drawState || data.length === 0) {
2492
2502
  return;
@@ -3010,7 +3020,7 @@ function createChart(element, options = {}) {
3010
3020
  setCrosshairPoint(null);
3011
3021
  } else if (dragMode === "x-axis") {
3012
3022
  canvas.style.cursor = "ew-resize";
3013
- zoomXToLatest(Math.exp(deltaX * 6e-3));
3023
+ zoomXFromAxis(Math.exp(deltaX * 6e-3));
3014
3024
  setCrosshairPoint(null);
3015
3025
  } else if (dragMode === "y-axis") {
3016
3026
  canvas.style.cursor = "ns-resize";
@@ -3121,7 +3131,7 @@ function createChart(element, options = {}) {
3121
3131
  return;
3122
3132
  }
3123
3133
  if (region === "x-axis") {
3124
- zoomXToLatest(factor);
3134
+ zoomXFromAxis(factor);
3125
3135
  return;
3126
3136
  }
3127
3137
  zoomX(factor, point.x);
package/dist/index.cjs CHANGED
@@ -2511,6 +2511,16 @@ function createChart(element, options = {}) {
2511
2511
  emitViewportChange();
2512
2512
  draw();
2513
2513
  };
2514
+ const zoomXFromAxis = (factor) => {
2515
+ if (!drawState) {
2516
+ return;
2517
+ }
2518
+ if (followLatest) {
2519
+ zoomXToLatest(factor);
2520
+ return;
2521
+ }
2522
+ zoomX(factor, drawState.chartLeft + drawState.chartWidth / 2);
2523
+ };
2514
2524
  const zoomY = (factor, anchorY) => {
2515
2525
  if (!drawState || data.length === 0) {
2516
2526
  return;
@@ -3034,7 +3044,7 @@ function createChart(element, options = {}) {
3034
3044
  setCrosshairPoint(null);
3035
3045
  } else if (dragMode === "x-axis") {
3036
3046
  canvas.style.cursor = "ew-resize";
3037
- zoomXToLatest(Math.exp(deltaX * 6e-3));
3047
+ zoomXFromAxis(Math.exp(deltaX * 6e-3));
3038
3048
  setCrosshairPoint(null);
3039
3049
  } else if (dragMode === "y-axis") {
3040
3050
  canvas.style.cursor = "ns-resize";
@@ -3145,7 +3155,7 @@ function createChart(element, options = {}) {
3145
3155
  return;
3146
3156
  }
3147
3157
  if (region === "x-axis") {
3148
- zoomXToLatest(factor);
3158
+ zoomXFromAxis(factor);
3149
3159
  return;
3150
3160
  }
3151
3161
  zoomX(factor, point.x);
package/dist/index.js CHANGED
@@ -2487,6 +2487,16 @@ function createChart(element, options = {}) {
2487
2487
  emitViewportChange();
2488
2488
  draw();
2489
2489
  };
2490
+ const zoomXFromAxis = (factor) => {
2491
+ if (!drawState) {
2492
+ return;
2493
+ }
2494
+ if (followLatest) {
2495
+ zoomXToLatest(factor);
2496
+ return;
2497
+ }
2498
+ zoomX(factor, drawState.chartLeft + drawState.chartWidth / 2);
2499
+ };
2490
2500
  const zoomY = (factor, anchorY) => {
2491
2501
  if (!drawState || data.length === 0) {
2492
2502
  return;
@@ -3010,7 +3020,7 @@ function createChart(element, options = {}) {
3010
3020
  setCrosshairPoint(null);
3011
3021
  } else if (dragMode === "x-axis") {
3012
3022
  canvas.style.cursor = "ew-resize";
3013
- zoomXToLatest(Math.exp(deltaX * 6e-3));
3023
+ zoomXFromAxis(Math.exp(deltaX * 6e-3));
3014
3024
  setCrosshairPoint(null);
3015
3025
  } else if (dragMode === "y-axis") {
3016
3026
  canvas.style.cursor = "ns-resize";
@@ -3121,7 +3131,7 @@ function createChart(element, options = {}) {
3121
3131
  return;
3122
3132
  }
3123
3133
  if (region === "x-axis") {
3124
- zoomXToLatest(factor);
3134
+ zoomXFromAxis(factor);
3125
3135
  return;
3126
3136
  }
3127
3137
  zoomX(factor, point.x);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.47",
3
+ "version": "0.1.48",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",