chartkick 5.1.3 → 5.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60765472a4a878439878da816efbb07ef13ef5e8d13fa05d1b5d17cc35a86fc1
4
- data.tar.gz: 895e11561ff7bc42c3171d43f7c70ac680b68e213133210ddbadd35ddb6e847d
3
+ metadata.gz: '0872574220622fecbfb25770afdfdf1f244df0ba36d768c8e1d49e220120a7a3'
4
+ data.tar.gz: 639bdb33a206445211c2496e14624090fef6a7e0e32dd0466d2a308f88dc8d0e
5
5
  SHA512:
6
- metadata.gz: 3b887e7da63f59a7faa7c7746e685dddc936a349042b90873d53cb08db64b284b809e3a1c89943f5ec0068dbf0fc188ca96555a651b1863198673760f3b5808f
7
- data.tar.gz: aba0da7151b351d6f4bf3ed6b7382d0bb0a2998f06230946a44c2f34d918028eecec0aadff454794565f6f125c113acf56022b081c61cbda4d18fe9528fee1bb
6
+ metadata.gz: 6a6d14dd85b91be1d82843ce6e241be6035bfe8b9f9d75e53ae59e4b9f83db09878c391d4bf3afaa8efca5b5ef397fa9bed27796d1c0963766cf14ac70e5d799
7
+ data.tar.gz: 37f5e87298510df837427db88997c99f86082887f10105ed12bf0f61fb7b30ff96ac65bace73df35048764888483edf40f3de05d5c7e249ae62afffefd79c4dd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 5.1.5 (2025-04-15)
2
+
3
+ - Updated Chart.js to 4.4.9
4
+
5
+ ## 5.1.4 (2025-02-19)
6
+
7
+ - Updated Chart.js to 4.4.8
8
+
1
9
  ## 5.1.3 (2025-02-01)
2
10
 
3
11
  - Updated Chart.js to 4.4.7
@@ -1,3 +1,3 @@
1
1
  module Chartkick
2
- VERSION = "5.1.3"
2
+ VERSION = "5.1.5"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Chart.js v4.4.7
2
+ * Chart.js v4.4.9
3
3
  * https://www.chartjs.org
4
- * (c) 2024 Chart.js Contributors
4
+ * (c) 2025 Chart.js Contributors
5
5
  * Released under the MIT License
6
6
  *
7
7
  * @kurkle/color v0.3.2
@@ -1300,8 +1300,14 @@
1300
1300
  }).pop();
1301
1301
  return result;
1302
1302
  }
1303
+ /**
1304
+ * Verifies that attempting to coerce n to string or number won't throw a TypeError.
1305
+ */
1306
+ function isNonPrimitive(n) {
1307
+ return _typeof$1(n) === 'symbol' || _typeof$1(n) === 'object' && n !== null && !(Symbol.toPrimitive in n || 'toString' in n || 'valueOf' in n);
1308
+ }
1303
1309
  function isNumber(n) {
1304
- return !isNaN(parseFloat(n)) && isFinite(n);
1310
+ return !isNonPrimitive(n) && !isNaN(parseFloat(n)) && isFinite(n);
1305
1311
  }
1306
1312
  function almostWhole(x, epsilon) {
1307
1313
  var rounded = Math.round(x);
@@ -1631,7 +1637,9 @@
1631
1637
  var count = pointCount;
1632
1638
  if (meta._sorted) {
1633
1639
  var iScale = meta.iScale,
1640
+ vScale = meta.vScale,
1634
1641
  _parsed = meta._parsed;
1642
+ var spanGaps = meta.dataset ? meta.dataset.options ? meta.dataset.options.spanGaps : null : null;
1635
1643
  var axis = iScale.axis;
1636
1644
  var _iScale$getUserBounds = iScale.getUserBounds(),
1637
1645
  min = _iScale$getUserBounds.min,
@@ -1639,18 +1647,32 @@
1639
1647
  minDefined = _iScale$getUserBounds.minDefined,
1640
1648
  maxDefined = _iScale$getUserBounds.maxDefined;
1641
1649
  if (minDefined) {
1642
- start = _limitValue(Math.min(
1650
+ start = Math.min(
1643
1651
  // @ts-expect-error Need to type _parsed
1644
1652
  _lookupByKey(_parsed, axis, min).lo,
1645
1653
  // @ts-expect-error Need to fix types on _lookupByKey
1646
- animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo), 0, pointCount - 1);
1654
+ animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo);
1655
+ if (spanGaps) {
1656
+ var distanceToDefinedLo = _parsed.slice(0, start + 1).reverse().findIndex(function (point) {
1657
+ return !isNullOrUndef(point[vScale.axis]);
1658
+ });
1659
+ start -= Math.max(0, distanceToDefinedLo);
1660
+ }
1661
+ start = _limitValue(start, 0, pointCount - 1);
1647
1662
  }
1648
1663
  if (maxDefined) {
1649
- count = _limitValue(Math.max(
1664
+ var end = Math.max(
1650
1665
  // @ts-expect-error Need to type _parsed
1651
1666
  _lookupByKey(_parsed, iScale.axis, max, true).hi + 1,
1652
1667
  // @ts-expect-error Need to fix types on _lookupByKey
1653
- animationsDisabled ? 0 : _lookupByKey(points, axis, iScale.getPixelForValue(max), true).hi + 1), start, pointCount) - start;
1668
+ animationsDisabled ? 0 : _lookupByKey(points, axis, iScale.getPixelForValue(max), true).hi + 1);
1669
+ if (spanGaps) {
1670
+ var distanceToDefinedHi = _parsed.slice(end - 1).findIndex(function (point) {
1671
+ return !isNullOrUndef(point[vScale.axis]);
1672
+ });
1673
+ end += Math.max(0, distanceToDefinedHi);
1674
+ }
1675
+ count = _limitValue(end, start, pointCount) - start;
1654
1676
  } else {
1655
1677
  count = pointCount - start;
1656
1678
  }
@@ -3360,14 +3382,8 @@
3360
3382
  }
3361
3383
 
3362
3384
  /**
3363
- * Note: typedefs are auto-exported, so use a made-up `dom` namespace where
3364
- * necessary to avoid duplicates with `export * from './helpers`; see
3365
- * https://github.com/microsoft/TypeScript/issues/46011
3366
- * @typedef { import('../core/core.controller.js').default } dom.Chart
3367
- * @typedef { import('../../types').ChartEvent } ChartEvent
3368
- */ /**
3369
- * @private
3370
- */
3385
+ * @private
3386
+ */
3371
3387
  function _isDomSupported() {
3372
3388
  return typeof window !== 'undefined' && typeof document !== 'undefined';
3373
3389
  }
@@ -4031,6 +4047,35 @@
4031
4047
  };
4032
4048
  return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
4033
4049
  }
4050
+ function getSizeForArea(scale, chartArea, field) {
4051
+ return scale.options.clip ? scale[field] : chartArea[field];
4052
+ }
4053
+ function getDatasetArea(meta, chartArea) {
4054
+ var xScale = meta.xScale,
4055
+ yScale = meta.yScale;
4056
+ if (xScale && yScale) {
4057
+ return {
4058
+ left: getSizeForArea(xScale, chartArea, 'left'),
4059
+ right: getSizeForArea(xScale, chartArea, 'right'),
4060
+ top: getSizeForArea(yScale, chartArea, 'top'),
4061
+ bottom: getSizeForArea(yScale, chartArea, 'bottom')
4062
+ };
4063
+ }
4064
+ return chartArea;
4065
+ }
4066
+ function getDatasetClipArea(chart, meta) {
4067
+ var clip = meta._clip;
4068
+ if (clip.disabled) {
4069
+ return false;
4070
+ }
4071
+ var area = getDatasetArea(meta, chart.chartArea);
4072
+ return {
4073
+ left: clip.left === false ? 0 : area.left - (clip.left === true ? 0 : clip.left),
4074
+ right: clip.right === false ? chart.width : area.right + (clip.right === true ? 0 : clip.right),
4075
+ top: clip.top === false ? 0 : area.top - (clip.top === true ? 0 : clip.top),
4076
+ bottom: clip.bottom === false ? chart.height : area.bottom + (clip.bottom === true ? 0 : clip.bottom)
4077
+ };
4078
+ }
4034
4079
 
4035
4080
  var Animator = /*#__PURE__*/function () {
4036
4081
  function Animator() {
@@ -7081,10 +7126,24 @@
7081
7126
  data = metaset.data,
7082
7127
  _sorted = metaset._sorted;
7083
7128
  var iScale = controller._cachedMeta.iScale;
7129
+ var spanGaps = metaset.dataset ? metaset.dataset.options ? metaset.dataset.options.spanGaps : null : null;
7084
7130
  if (iScale && axis === iScale.axis && axis !== 'r' && _sorted && data.length) {
7085
7131
  var lookupMethod = iScale._reversePixels ? _rlookupByKey : _lookupByKey;
7086
7132
  if (!intersect) {
7087
- return lookupMethod(data, axis, value);
7133
+ var result = lookupMethod(data, axis, value);
7134
+ if (spanGaps) {
7135
+ var vScale = controller._cachedMeta.vScale;
7136
+ var _parsed = metaset._parsed;
7137
+ var distanceToDefinedLo = _parsed.slice(0, result.lo + 1).reverse().findIndex(function (point) {
7138
+ return !isNullOrUndef(point[vScale.axis]);
7139
+ });
7140
+ result.lo -= Math.max(0, distanceToDefinedLo);
7141
+ var distanceToDefinedHi = _parsed.slice(result.hi).findIndex(function (point) {
7142
+ return !isNullOrUndef(point[vScale.axis]);
7143
+ });
7144
+ result.hi += Math.max(0, distanceToDefinedHi);
7145
+ }
7146
+ return result;
7088
7147
  } else if (controller._sharedOptions) {
7089
7148
  var el = data[0];
7090
7149
  var range = typeof el.getRange === 'function' && el.getRange(axis);
@@ -10402,7 +10461,7 @@
10402
10461
  }
10403
10462
  return false;
10404
10463
  }
10405
- var version = "4.4.7";
10464
+ var version = "4.4.9";
10406
10465
  var KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];
10407
10466
  function positionIsHorizontal(position, axis) {
10408
10467
  return position === 'top' || position === 'bottom' || KNOWN_POSITIONS.indexOf(position) === -1 && axis === 'x';
@@ -10464,22 +10523,6 @@
10464
10523
  }
10465
10524
  return e;
10466
10525
  }
10467
- function getSizeForArea(scale, chartArea, field) {
10468
- return scale.options.clip ? scale[field] : chartArea[field];
10469
- }
10470
- function getDatasetArea(meta, chartArea) {
10471
- var xScale = meta.xScale,
10472
- yScale = meta.yScale;
10473
- if (xScale && yScale) {
10474
- return {
10475
- left: getSizeForArea(xScale, chartArea, 'left'),
10476
- right: getSizeForArea(xScale, chartArea, 'right'),
10477
- top: getSizeForArea(yScale, chartArea, 'top'),
10478
- bottom: getSizeForArea(yScale, chartArea, 'bottom')
10479
- };
10480
- }
10481
- return chartArea;
10482
- }
10483
10526
  var Chart = /*#__PURE__*/function () {
10484
10527
  function Chart(item, userConfig) {
10485
10528
  var _this12 = this;
@@ -11069,27 +11112,20 @@
11069
11112
  key: "_drawDataset",
11070
11113
  value: function _drawDataset(meta) {
11071
11114
  var ctx = this.ctx;
11072
- var clip = meta._clip;
11073
- var useClip = !clip.disabled;
11074
- var area = getDatasetArea(meta, this.chartArea);
11075
11115
  var args = {
11076
11116
  meta: meta,
11077
11117
  index: meta.index,
11078
11118
  cancelable: true
11079
11119
  };
11120
+ var clip = getDatasetClipArea(this, meta);
11080
11121
  if (this.notifyPlugins('beforeDatasetDraw', args) === false) {
11081
11122
  return;
11082
11123
  }
11083
- if (useClip) {
11084
- clipArea(ctx, {
11085
- left: clip.left === false ? 0 : area.left - clip.left,
11086
- right: clip.right === false ? this.width : area.right + clip.right,
11087
- top: clip.top === false ? 0 : area.top - clip.top,
11088
- bottom: clip.bottom === false ? this.height : area.bottom + clip.bottom
11089
- });
11124
+ if (clip) {
11125
+ clipArea(ctx, clip);
11090
11126
  }
11091
11127
  meta.controller.draw();
11092
- if (useClip) {
11128
+ if (clip) {
11093
11129
  unclipArea(ctx);
11094
11130
  }
11095
11131
  args.cancelable = false;
@@ -13211,7 +13247,9 @@
13211
13247
  }
13212
13248
  function _drawfill(ctx, source, area) {
13213
13249
  var target = _getTarget(source);
13214
- var line = source.line,
13250
+ var chart = source.chart,
13251
+ index = source.index,
13252
+ line = source.line,
13215
13253
  scale = source.scale,
13216
13254
  axis = source.axis;
13217
13255
  var lineOpts = line.options;
@@ -13222,6 +13260,8 @@
13222
13260
  above = _ref9$above === void 0 ? color : _ref9$above,
13223
13261
  _ref9$below = _ref9.below,
13224
13262
  below = _ref9$below === void 0 ? color : _ref9$below;
13263
+ var meta = chart.getDatasetMeta(index);
13264
+ var clip = getDatasetClipArea(chart, meta);
13225
13265
  if (target && line.points.length) {
13226
13266
  clipArea(ctx, area);
13227
13267
  doFill(ctx, {
@@ -13231,7 +13271,8 @@
13231
13271
  below: below,
13232
13272
  area: area,
13233
13273
  scale: scale,
13234
- axis: axis
13274
+ axis: axis,
13275
+ clip: clip
13235
13276
  });
13236
13277
  unclipArea(ctx);
13237
13278
  }
@@ -13242,7 +13283,8 @@
13242
13283
  above = cfg.above,
13243
13284
  below = cfg.below,
13244
13285
  area = cfg.area,
13245
- scale = cfg.scale;
13286
+ scale = cfg.scale,
13287
+ clip = cfg.clip;
13246
13288
  var property = line._loop ? 'angle' : cfg.axis;
13247
13289
  ctx.save();
13248
13290
  if (property === 'x' && below !== above) {
@@ -13252,7 +13294,8 @@
13252
13294
  target: target,
13253
13295
  color: above,
13254
13296
  scale: scale,
13255
- property: property
13297
+ property: property,
13298
+ clip: clip
13256
13299
  });
13257
13300
  ctx.restore();
13258
13301
  ctx.save();
@@ -13263,7 +13306,8 @@
13263
13306
  target: target,
13264
13307
  color: below,
13265
13308
  scale: scale,
13266
- property: property
13309
+ property: property,
13310
+ clip: clip
13267
13311
  });
13268
13312
  ctx.restore();
13269
13313
  }
@@ -13312,7 +13356,8 @@
13312
13356
  target = cfg.target,
13313
13357
  property = cfg.property,
13314
13358
  color = cfg.color,
13315
- scale = cfg.scale;
13359
+ scale = cfg.scale,
13360
+ clip = cfg.clip;
13316
13361
  var segments = _segments(line, target, property);
13317
13362
  var _iterator22 = _createForOfIteratorHelper$1(segments),
13318
13363
  _step22;
@@ -13330,7 +13375,7 @@
13330
13375
  var notShape = target !== true;
13331
13376
  ctx.save();
13332
13377
  ctx.fillStyle = backgroundColor;
13333
- clipBounds(ctx, scale, notShape && _getBounds(property, start, end));
13378
+ clipBounds(ctx, scale, clip, notShape && _getBounds(property, start, end));
13334
13379
  ctx.beginPath();
13335
13380
  var lineLoop = !!line.pathSegment(ctx, src);
13336
13381
  var loop = void 0;
@@ -13359,17 +13404,33 @@
13359
13404
  _iterator22.f();
13360
13405
  }
13361
13406
  }
13362
- function clipBounds(ctx, scale, bounds) {
13363
- var _scale$chart$chartAre = scale.chart.chartArea,
13364
- top = _scale$chart$chartAre.top,
13365
- bottom = _scale$chart$chartAre.bottom;
13407
+ function clipBounds(ctx, scale, clip, bounds) {
13408
+ var chartArea = scale.chart.chartArea;
13366
13409
  var _ref10 = bounds || {},
13367
13410
  property = _ref10.property,
13368
13411
  start = _ref10.start,
13369
13412
  end = _ref10.end;
13370
- if (property === 'x') {
13413
+ if (property === 'x' || property === 'y') {
13414
+ var left, top, right, bottom;
13415
+ if (property === 'x') {
13416
+ left = start;
13417
+ top = chartArea.top;
13418
+ right = end;
13419
+ bottom = chartArea.bottom;
13420
+ } else {
13421
+ left = chartArea.left;
13422
+ top = start;
13423
+ right = chartArea.right;
13424
+ bottom = end;
13425
+ }
13371
13426
  ctx.beginPath();
13372
- ctx.rect(start, top, end - start, bottom - top);
13427
+ if (clip) {
13428
+ left = Math.max(left, clip.left);
13429
+ right = Math.min(right, clip.right);
13430
+ top = Math.max(top, clip.top);
13431
+ bottom = Math.min(bottom, clip.bottom);
13432
+ }
13433
+ ctx.rect(left, top, right - left, bottom - top);
13373
13434
  ctx.clip();
13374
13435
  }
13375
13436
  }
@@ -17314,6 +17375,7 @@
17314
17375
  fontString: fontString,
17315
17376
  formatNumber: formatNumber,
17316
17377
  getAngleFromPoint: getAngleFromPoint,
17378
+ getDatasetClipArea: getDatasetClipArea,
17317
17379
  getHoverColor: getHoverColor,
17318
17380
  getMaximumSize: getMaximumSize,
17319
17381
  getRelativePosition: getRelativePosition,
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.3
4
+ version: 5.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-01 00:00:00.000000000 Z
10
+ date: 2025-04-15 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  email: andrew@ankane.org
13
13
  executables: []