chartkick 5.1.4 → 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: 98a76e20f3a13e13184687cb845f461cfd5ef0e3bd75273922a5da56b97597ab
4
- data.tar.gz: 6017e645dff4678208f3c57fc682d8343f19063a494a39f9f45788092e123492
3
+ metadata.gz: '0872574220622fecbfb25770afdfdf1f244df0ba36d768c8e1d49e220120a7a3'
4
+ data.tar.gz: 639bdb33a206445211c2496e14624090fef6a7e0e32dd0466d2a308f88dc8d0e
5
5
  SHA512:
6
- metadata.gz: 1d8567e2dc6bb53efac3426b4fb8c6bef2b870db845e12fadb28aa0a069b64c8c9edae98e06003d00806959fee51f0de600d358b8620a7e9453654f7def44291
7
- data.tar.gz: 5150b0d42f154e2ff17722e6af8a3b2798ab4c764ce937a14a83a2f13d44a0fc6f812a45caac77a9e753bd28162046b387d9dee317d2ad27383f1d2deb284394
6
+ metadata.gz: 6a6d14dd85b91be1d82843ce6e241be6035bfe8b9f9d75e53ae59e4b9f83db09878c391d4bf3afaa8efca5b5ef397fa9bed27796d1c0963766cf14ac70e5d799
7
+ data.tar.gz: 37f5e87298510df837427db88997c99f86082887f10105ed12bf0f61fb7b30ff96ac65bace73df35048764888483edf40f3de05d5c7e249ae62afffefd79c4dd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 5.1.5 (2025-04-15)
2
+
3
+ - Updated Chart.js to 4.4.9
4
+
1
5
  ## 5.1.4 (2025-02-19)
2
6
 
3
7
  - Updated Chart.js to 4.4.8
@@ -1,3 +1,3 @@
1
1
  module Chartkick
2
- VERSION = "5.1.4"
2
+ VERSION = "5.1.5"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Chart.js v4.4.8
2
+ * Chart.js v4.4.9
3
3
  * https://www.chartjs.org
4
4
  * (c) 2025 Chart.js Contributors
5
5
  * Released under the MIT License
@@ -4047,6 +4047,35 @@
4047
4047
  };
4048
4048
  return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
4049
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
+ }
4050
4079
 
4051
4080
  var Animator = /*#__PURE__*/function () {
4052
4081
  function Animator() {
@@ -10432,7 +10461,7 @@
10432
10461
  }
10433
10462
  return false;
10434
10463
  }
10435
- var version = "4.4.8";
10464
+ var version = "4.4.9";
10436
10465
  var KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];
10437
10466
  function positionIsHorizontal(position, axis) {
10438
10467
  return position === 'top' || position === 'bottom' || KNOWN_POSITIONS.indexOf(position) === -1 && axis === 'x';
@@ -10494,22 +10523,6 @@
10494
10523
  }
10495
10524
  return e;
10496
10525
  }
10497
- function getSizeForArea(scale, chartArea, field) {
10498
- return scale.options.clip ? scale[field] : chartArea[field];
10499
- }
10500
- function getDatasetArea(meta, chartArea) {
10501
- var xScale = meta.xScale,
10502
- yScale = meta.yScale;
10503
- if (xScale && yScale) {
10504
- return {
10505
- left: getSizeForArea(xScale, chartArea, 'left'),
10506
- right: getSizeForArea(xScale, chartArea, 'right'),
10507
- top: getSizeForArea(yScale, chartArea, 'top'),
10508
- bottom: getSizeForArea(yScale, chartArea, 'bottom')
10509
- };
10510
- }
10511
- return chartArea;
10512
- }
10513
10526
  var Chart = /*#__PURE__*/function () {
10514
10527
  function Chart(item, userConfig) {
10515
10528
  var _this12 = this;
@@ -11099,27 +11112,20 @@
11099
11112
  key: "_drawDataset",
11100
11113
  value: function _drawDataset(meta) {
11101
11114
  var ctx = this.ctx;
11102
- var clip = meta._clip;
11103
- var useClip = !clip.disabled;
11104
- var area = getDatasetArea(meta, this.chartArea);
11105
11115
  var args = {
11106
11116
  meta: meta,
11107
11117
  index: meta.index,
11108
11118
  cancelable: true
11109
11119
  };
11120
+ var clip = getDatasetClipArea(this, meta);
11110
11121
  if (this.notifyPlugins('beforeDatasetDraw', args) === false) {
11111
11122
  return;
11112
11123
  }
11113
- if (useClip) {
11114
- clipArea(ctx, {
11115
- left: clip.left === false ? 0 : area.left - clip.left,
11116
- right: clip.right === false ? this.width : area.right + clip.right,
11117
- top: clip.top === false ? 0 : area.top - clip.top,
11118
- bottom: clip.bottom === false ? this.height : area.bottom + clip.bottom
11119
- });
11124
+ if (clip) {
11125
+ clipArea(ctx, clip);
11120
11126
  }
11121
11127
  meta.controller.draw();
11122
- if (useClip) {
11128
+ if (clip) {
11123
11129
  unclipArea(ctx);
11124
11130
  }
11125
11131
  args.cancelable = false;
@@ -13241,7 +13247,9 @@
13241
13247
  }
13242
13248
  function _drawfill(ctx, source, area) {
13243
13249
  var target = _getTarget(source);
13244
- var line = source.line,
13250
+ var chart = source.chart,
13251
+ index = source.index,
13252
+ line = source.line,
13245
13253
  scale = source.scale,
13246
13254
  axis = source.axis;
13247
13255
  var lineOpts = line.options;
@@ -13252,6 +13260,8 @@
13252
13260
  above = _ref9$above === void 0 ? color : _ref9$above,
13253
13261
  _ref9$below = _ref9.below,
13254
13262
  below = _ref9$below === void 0 ? color : _ref9$below;
13263
+ var meta = chart.getDatasetMeta(index);
13264
+ var clip = getDatasetClipArea(chart, meta);
13255
13265
  if (target && line.points.length) {
13256
13266
  clipArea(ctx, area);
13257
13267
  doFill(ctx, {
@@ -13261,7 +13271,8 @@
13261
13271
  below: below,
13262
13272
  area: area,
13263
13273
  scale: scale,
13264
- axis: axis
13274
+ axis: axis,
13275
+ clip: clip
13265
13276
  });
13266
13277
  unclipArea(ctx);
13267
13278
  }
@@ -13272,7 +13283,8 @@
13272
13283
  above = cfg.above,
13273
13284
  below = cfg.below,
13274
13285
  area = cfg.area,
13275
- scale = cfg.scale;
13286
+ scale = cfg.scale,
13287
+ clip = cfg.clip;
13276
13288
  var property = line._loop ? 'angle' : cfg.axis;
13277
13289
  ctx.save();
13278
13290
  if (property === 'x' && below !== above) {
@@ -13282,7 +13294,8 @@
13282
13294
  target: target,
13283
13295
  color: above,
13284
13296
  scale: scale,
13285
- property: property
13297
+ property: property,
13298
+ clip: clip
13286
13299
  });
13287
13300
  ctx.restore();
13288
13301
  ctx.save();
@@ -13293,7 +13306,8 @@
13293
13306
  target: target,
13294
13307
  color: below,
13295
13308
  scale: scale,
13296
- property: property
13309
+ property: property,
13310
+ clip: clip
13297
13311
  });
13298
13312
  ctx.restore();
13299
13313
  }
@@ -13342,7 +13356,8 @@
13342
13356
  target = cfg.target,
13343
13357
  property = cfg.property,
13344
13358
  color = cfg.color,
13345
- scale = cfg.scale;
13359
+ scale = cfg.scale,
13360
+ clip = cfg.clip;
13346
13361
  var segments = _segments(line, target, property);
13347
13362
  var _iterator22 = _createForOfIteratorHelper$1(segments),
13348
13363
  _step22;
@@ -13360,7 +13375,7 @@
13360
13375
  var notShape = target !== true;
13361
13376
  ctx.save();
13362
13377
  ctx.fillStyle = backgroundColor;
13363
- clipBounds(ctx, scale, notShape && _getBounds(property, start, end));
13378
+ clipBounds(ctx, scale, clip, notShape && _getBounds(property, start, end));
13364
13379
  ctx.beginPath();
13365
13380
  var lineLoop = !!line.pathSegment(ctx, src);
13366
13381
  var loop = void 0;
@@ -13389,17 +13404,33 @@
13389
13404
  _iterator22.f();
13390
13405
  }
13391
13406
  }
13392
- function clipBounds(ctx, scale, bounds) {
13393
- var _scale$chart$chartAre = scale.chart.chartArea,
13394
- top = _scale$chart$chartAre.top,
13395
- bottom = _scale$chart$chartAre.bottom;
13407
+ function clipBounds(ctx, scale, clip, bounds) {
13408
+ var chartArea = scale.chart.chartArea;
13396
13409
  var _ref10 = bounds || {},
13397
13410
  property = _ref10.property,
13398
13411
  start = _ref10.start,
13399
13412
  end = _ref10.end;
13400
- 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
+ }
13401
13426
  ctx.beginPath();
13402
- 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);
13403
13434
  ctx.clip();
13404
13435
  }
13405
13436
  }
@@ -17344,6 +17375,7 @@
17344
17375
  fontString: fontString,
17345
17376
  formatNumber: formatNumber,
17346
17377
  getAngleFromPoint: getAngleFromPoint,
17378
+ getDatasetClipArea: getDatasetClipArea,
17347
17379
  getHoverColor: getHoverColor,
17348
17380
  getMaximumSize: getMaximumSize,
17349
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.4
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-19 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: []