chartkick 5.1.2 → 5.1.4

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: c02c167e89a1d4b519eef7efd26bba1cdd94454058d5c1c172263cd338c854da
4
- data.tar.gz: 54537bba9415ee70f1f0b081c5614348c37a75f3220aa114061486b6ee170dda
3
+ metadata.gz: 98a76e20f3a13e13184687cb845f461cfd5ef0e3bd75273922a5da56b97597ab
4
+ data.tar.gz: 6017e645dff4678208f3c57fc682d8343f19063a494a39f9f45788092e123492
5
5
  SHA512:
6
- metadata.gz: e6109c2e24f9dc17e48769d88da714c38e463c49379af85361d4c560e79369208e4b03282ed41be7aab0bc3fd5af29d15ea9af697caf347d8c8b9b76afeb50b1
7
- data.tar.gz: daca8c4bb5c24e889a9feaa542d2088ec8b62b41658179bbbc4ad6afe67e7eecc3e9d956e7dc560596b3c2cae10a286b5304929debfa0db35c6acd0b7ef09dd9
6
+ metadata.gz: 1d8567e2dc6bb53efac3426b4fb8c6bef2b870db845e12fadb28aa0a069b64c8c9edae98e06003d00806959fee51f0de600d358b8620a7e9453654f7def44291
7
+ data.tar.gz: 5150b0d42f154e2ff17722e6af8a3b2798ab4c764ce937a14a83a2f13d44a0fc6f812a45caac77a9e753bd28162046b387d9dee317d2ad27383f1d2deb284394
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 5.1.4 (2025-02-19)
2
+
3
+ - Updated Chart.js to 4.4.8
4
+
5
+ ## 5.1.3 (2025-02-01)
6
+
7
+ - Updated Chart.js to 4.4.7
8
+
1
9
  ## 5.1.2 (2024-10-29)
2
10
 
3
11
  - Updated Chart.js to 4.4.6
data/README.md CHANGED
@@ -20,9 +20,8 @@ gem "chartkick"
20
20
 
21
21
  Then follow the instructions for your JavaScript setup:
22
22
 
23
- - [Importmap](#importmap) (Rails 7 default)
24
- - [esbuild, rollup.js, or Webpack](#esbuild-rollupjs-or-webpack)
25
- - [Webpacker](#webpacker) (Rails 6 default)
23
+ - [Importmap](#importmap) (Rails 7+ default)
24
+ - [Bun, esbuild, rollup.js, or Webpack](#bun-esbuild-rollupjs-or-webpack)
26
25
  - [Sprockets](#sprockets)
27
26
 
28
27
  This sets up Chartkick with [Chart.js](https://www.chartjs.org/). For other charting libraries and frameworks, see [these instructions](#additional-charting-libraries).
@@ -43,11 +42,13 @@ import "chartkick"
43
42
  import "Chart.bundle"
44
43
  ```
45
44
 
46
- ### esbuild, rollup.js, or Webpack
45
+ ### Bun, esbuild, rollup.js, or Webpack
47
46
 
48
47
  Run:
49
48
 
50
49
  ```sh
50
+ bun add chartkick chart.js
51
+ # or
51
52
  yarn add chartkick chart.js
52
53
  ```
53
54
 
@@ -57,22 +58,6 @@ And in `app/javascript/application.js`, add:
57
58
  import "chartkick/chart.js"
58
59
  ```
59
60
 
60
- Note: For rollup.js, this requires `format: "iife"` in `rollup.config.js`.
61
-
62
- ### Webpacker
63
-
64
- Run:
65
-
66
- ```sh
67
- yarn add chartkick chart.js
68
- ```
69
-
70
- And in `app/javascript/packs/application.js`, add:
71
-
72
- ```js
73
- import "chartkick/chart.js"
74
- ```
75
-
76
61
  ### Sprockets
77
62
 
78
63
  In `app/assets/javascripts/application.js`, add:
@@ -140,8 +125,8 @@ Multiple series
140
125
 
141
126
  ```erb
142
127
  <%= line_chart [
143
- {name: "Workout", data: {"2021-01-01" => 3, "2021-01-02" => 4}},
144
- {name: "Call parents", data: {"2021-01-01" => 5, "2021-01-02" => 3}}
128
+ {name: "Workout", data: {"2025-01-01" => 3, "2025-01-02" => 4}},
129
+ {name: "Call parents", data: {"2025-01-01" => 5, "2025-01-02" => 3}}
145
130
  ] %>
146
131
  ```
147
132
 
@@ -158,13 +143,13 @@ Data can be a hash, array, or URL.
158
143
  #### Hash
159
144
 
160
145
  ```erb
161
- <%= line_chart({"2021-01-01" => 2, "2021-01-02" => 3}) %>
146
+ <%= line_chart({"2025-01-01" => 2, "2025-01-02" => 3}) %>
162
147
  ```
163
148
 
164
149
  #### Array
165
150
 
166
151
  ```erb
167
- <%= line_chart [["2021-01-01", 2], ["2021-01-02", 3]] %>
152
+ <%= line_chart [["2025-01-01", 2], ["2025-01-02", 3]] %>
168
153
  ```
169
154
 
170
155
  #### URL
@@ -210,7 +195,7 @@ Min and max values
210
195
  Min and max for x-axis - *Chart.js*
211
196
 
212
197
  ```erb
213
- <%= line_chart data, xmin: "2021-01-01", xmax: "2022-01-01" %>
198
+ <%= line_chart data, xmin: "2025-01-01", xmax: "2025-02-01" %>
214
199
  ```
215
200
 
216
201
  Colors
@@ -452,7 +437,7 @@ In your layout or views, add:
452
437
  <%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" %>
453
438
  ```
454
439
 
455
- For Importmap (Rails 7 default), in `config/importmap.rb`, add:
440
+ For Importmap (Rails 7+ default), in `config/importmap.rb`, add:
456
441
 
457
442
  ```ruby
458
443
  pin "chartkick", to: "chartkick.js"
@@ -464,9 +449,11 @@ And in `app/javascript/application.js`, add:
464
449
  import "chartkick"
465
450
  ```
466
451
 
467
- For Webpacker (Rails 6 default), run:
452
+ For Bun, esbuild, rollup.js, or Webpack, run:
468
453
 
469
454
  ```sh
455
+ bun add chartkick
456
+ # or
470
457
  yarn add chartkick
471
458
  ```
472
459
 
@@ -492,7 +479,7 @@ before your charts.
492
479
 
493
480
  ### Highcharts
494
481
 
495
- For Importmap (Rails 7 default), run:
482
+ For Importmap (Rails 7+ default), run:
496
483
 
497
484
  ```sh
498
485
  bin/importmap pin highcharts --download
@@ -513,9 +500,11 @@ import Highcharts from "highcharts"
513
500
  window.Highcharts = Highcharts
514
501
  ```
515
502
 
516
- For Webpacker (Rails 6 default), run:
503
+ For Bun, esbuild, rollup.js, or Webpack, run:
517
504
 
518
505
  ```sh
506
+ bun add chartkick highcharts
507
+ # or
519
508
  yarn add chartkick highcharts
520
509
  ```
521
510
 
@@ -525,7 +514,7 @@ And in `app/javascript/packs/application.js`, add:
525
514
  import "chartkick/highcharts"
526
515
  ```
527
516
 
528
- For Sprockets, download [highcharts.js](https://code.highcharts.com/highcharts.js) into `vendor/assets/javascripts` (or use `yarn add highcharts` in Rails 5.1+), and in `app/assets/javascripts/application.js`, add:
517
+ For Sprockets, download [highcharts.js](https://code.highcharts.com/highcharts.js) into `vendor/assets/javascripts` (or use `yarn add highcharts`), and in `app/assets/javascripts/application.js`, add:
529
518
 
530
519
  ```js
531
520
  //= require chartkick
@@ -643,24 +632,6 @@ Check out [how to configure CSP](https://github.com/ankane/chartkick/blob/master
643
632
  - [Make Easy Graphs and Charts on Rails with Chartkick](https://www.sitepoint.com/make-easy-graphs-and-charts-on-rails-with-chartkick/)
644
633
  - [Practical Graphs on Rails: Chartkick in Practice](https://www.sitepoint.com/graphs-on-rails-chartkick-in-practice/)
645
634
 
646
- ## Upgrading
647
-
648
- ### 5.0
649
-
650
- If you use Importmap or Sprockets, update the gem and you’re good to go!
651
-
652
- If you use esbuild, Webpack, or Webpacker, run:
653
-
654
- ```sh
655
- yarn upgrade chartkick --latest
656
- ```
657
-
658
- If you use Chart.js with esbuild, Webpack, or Webpacker, also run:
659
-
660
- ```sh
661
- yarn upgrade chart.js --latest
662
- ```
663
-
664
635
  ## History
665
636
 
666
637
  View the [changelog](https://github.com/ankane/chartkick/blob/master/CHANGELOG.md)
@@ -1,3 +1,3 @@
1
1
  module Chartkick
2
- VERSION = "5.1.2"
2
+ VERSION = "5.1.4"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Chart.js v4.4.6
2
+ * Chart.js v4.4.8
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
@@ -222,10 +222,10 @@
222
222
  for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf$1(t)););
223
223
  return t;
224
224
  }
225
- function _superPropGet(t, e, o, r) {
226
- var p = _get(_getPrototypeOf$1(1 & r ? t.prototype : t), e, o);
225
+ function _superPropGet(t, o, e, r) {
226
+ var p = _get(_getPrototypeOf$1(1 & r ? t.prototype : t), o, e);
227
227
  return 2 & r && "function" == typeof p ? function (t) {
228
- return p.apply(o, t);
228
+ return p.apply(e, t);
229
229
  } : p;
230
230
  }
231
231
  function _toConsumableArray(r) {
@@ -944,7 +944,7 @@
944
944
  * @since 2.7.0
945
945
  */
946
946
  function isNullOrUndef(value) {
947
- return value === null || typeof value === 'undefined';
947
+ return value === null || value === undefined;
948
948
  }
949
949
  /**
950
950
  * Returns true if `value` is an array (including typed arrays), else returns false.
@@ -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
  }
@@ -7081,10 +7097,24 @@
7081
7097
  data = metaset.data,
7082
7098
  _sorted = metaset._sorted;
7083
7099
  var iScale = controller._cachedMeta.iScale;
7100
+ var spanGaps = metaset.dataset ? metaset.dataset.options ? metaset.dataset.options.spanGaps : null : null;
7084
7101
  if (iScale && axis === iScale.axis && axis !== 'r' && _sorted && data.length) {
7085
7102
  var lookupMethod = iScale._reversePixels ? _rlookupByKey : _lookupByKey;
7086
7103
  if (!intersect) {
7087
- return lookupMethod(data, axis, value);
7104
+ var result = lookupMethod(data, axis, value);
7105
+ if (spanGaps) {
7106
+ var vScale = controller._cachedMeta.vScale;
7107
+ var _parsed = metaset._parsed;
7108
+ var distanceToDefinedLo = _parsed.slice(0, result.lo + 1).reverse().findIndex(function (point) {
7109
+ return !isNullOrUndef(point[vScale.axis]);
7110
+ });
7111
+ result.lo -= Math.max(0, distanceToDefinedLo);
7112
+ var distanceToDefinedHi = _parsed.slice(result.hi).findIndex(function (point) {
7113
+ return !isNullOrUndef(point[vScale.axis]);
7114
+ });
7115
+ result.hi += Math.max(0, distanceToDefinedHi);
7116
+ }
7117
+ return result;
7088
7118
  } else if (controller._sharedOptions) {
7089
7119
  var el = data[0];
7090
7120
  var range = typeof el.getRange === 'function' && el.getRange(axis);
@@ -10402,7 +10432,7 @@
10402
10432
  }
10403
10433
  return false;
10404
10434
  }
10405
- var version = "4.4.6";
10435
+ var version = "4.4.8";
10406
10436
  var KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];
10407
10437
  function positionIsHorizontal(position, axis) {
10408
10438
  return position === 'top' || position === 'bottom' || KNOWN_POSITIONS.indexOf(position) === -1 && axis === 'x';
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.2
4
+ version: 5.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-10-30 00:00:00.000000000 Z
10
+ date: 2025-02-19 00:00:00.000000000 Z
12
11
  dependencies: []
13
- description:
14
12
  email: andrew@ankane.org
15
13
  executables: []
16
14
  extensions: []
@@ -37,7 +35,6 @@ homepage: https://chartkick.com
37
35
  licenses:
38
36
  - MIT
39
37
  metadata: {}
40
- post_install_message:
41
38
  rdoc_options: []
42
39
  require_paths:
43
40
  - lib
@@ -52,8 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
49
  - !ruby/object:Gem::Version
53
50
  version: '0'
54
51
  requirements: []
55
- rubygems_version: 3.5.16
56
- signing_key:
52
+ rubygems_version: 3.6.2
57
53
  specification_version: 4
58
54
  summary: Create beautiful JavaScript charts with one line of Ruby
59
55
  test_files: []