chartkick 4.0.4 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e28ff576b7b488cc3ca1add95bf96832461189f5b085816e67d9923fdf13494
4
- data.tar.gz: 282c01fdc0d199d4dd9d17a0aa887a67a0d8ce52df584a46d172e636496ad25e
3
+ metadata.gz: fc72b4105d5e863040aec42ff49f32623f8fa3c74488b8ecdf5bb80d465653b3
4
+ data.tar.gz: 1e17d23367ad1ab3dd619d654e36f3f7cf179ed67f16164c22262460720627d7
5
5
  SHA512:
6
- metadata.gz: 3a450c12a1973131b412d99525d400d2910e63e24edb93cb6ce27670dc6a1eaf70e13dfec9829a67cae6afcf4e77737eea2c442232c00bdd3c5d5e7b126a1a93
7
- data.tar.gz: 3d59060b8e7dd24f3239dccc0b7079a66e3d1351a1e565e948e46faa2a2b28a462ee6d91b99602a334f91861ea2cf3a77419bf0c86677a83c278b4f97ef3d4fb
6
+ metadata.gz: cadb32e90ef25fa335d00410e753d28770f9ad245be0cd7d6b42e8de3fb984f8cb821f75d8cf61f0521fe25134110b6e3d5ff21c22fe8a54d441bb00b82ada54
7
+ data.tar.gz: 1a10102ebd8b97a6b4b27572c9efd825f75cdcb8353ab75505924c72e3424481f1220a0a7960dacba29b997e48af8f1d812c1a9d5cd5672d8faad8d6465fa401
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 4.1.2 (2021-11-06)
2
+
3
+ - Removed automatic pinning for `importmap-rails` (still experimental)
4
+
5
+ ## 4.1.1 (2021-11-06)
6
+
7
+ - Updated Chartkick.js to 4.1.1
8
+ - Updated Chart.js to 3.6.0
9
+
10
+ ## 4.1.0 (2021-10-23)
11
+
12
+ - Added support for Turbo
13
+ - Added experimental support for `importmap-rails`
14
+ - Updated Chartkick.js to 4.1.0
15
+
16
+ ## 4.0.5 (2021-07-07)
17
+
18
+ - Updated Chartkick.js to 4.0.5
19
+ - Updated Chart.js to 3.4.1
20
+
1
21
  ## 4.0.4 (2021-05-01)
2
22
 
3
23
  - Updated Chartkick.js to 4.0.4
data/README.md CHANGED
@@ -39,6 +39,20 @@ For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
39
39
  //= require Chart.bundle
40
40
  ```
41
41
 
42
+ For Rails 7 / Importmap (experimental), in `config/importmap.rb`, add:
43
+
44
+ ```ruby
45
+ pin "chartkick", to: "chartkick.js"
46
+ pin "Chart.bundle", to: "Chart.bundle.js"
47
+ ```
48
+
49
+ And in `app/javascript/application.js`, add:
50
+
51
+ ```js
52
+ import "chartkick"
53
+ import "Chart.bundle"
54
+ ```
55
+
42
56
  This sets up Chartkick with [Chart.js](https://www.chartjs.org/). For other charting libraries, see [detailed instructions](#installation).
43
57
 
44
58
  ## Charts
@@ -98,9 +112,10 @@ Timeline - *Google Charts*
98
112
  Multiple series
99
113
 
100
114
  ```erb
101
- <%= line_chart @goals.map { |goal|
102
- {name: goal.name, data: goal.feats.group_by_week(:created_at).count}
103
- } %>
115
+ <%= line_chart [
116
+ {name: "Workout", data: {"2021-01-01" => 3, "2021-01-02" => 4}},
117
+ {name: "Call parents", data: {"2021-01-01" => 5, "2021-01-02" => 3}}
118
+ ] %>
104
119
  ```
105
120
 
106
121
  or
@@ -109,7 +124,23 @@ or
109
124
  <%= line_chart Feat.group(:goal_id).group_by_week(:created_at).count %>
110
125
  ```
111
126
 
112
- ### Say Goodbye To Timeouts
127
+ ## Data
128
+
129
+ Data can be a hash, array, or URL.
130
+
131
+ #### Hash
132
+
133
+ ```erb
134
+ <%= line_chart({"2021-01-01" => 2, "2021-01-02" => 3}) %>
135
+ ```
136
+
137
+ #### Array
138
+
139
+ ```erb
140
+ <%= line_chart [["2021-01-01", 2], ["2021-01-02", 3]] %>
141
+ ```
142
+
143
+ #### URL
113
144
 
114
145
  Make your pages load super fast and stop worrying about timeouts. Give each chart its own endpoint.
115
146
 
@@ -133,7 +164,7 @@ For multiple series, add `chart_json` at the end.
133
164
  render json: Task.group(:goal_id).group_by_day(:completed_at).count.chart_json
134
165
  ```
135
166
 
136
- ### Options
167
+ ## Options
137
168
 
138
169
  Id, width, and height
139
170
 
@@ -330,30 +361,6 @@ For Padrino, use `yield_content` instead of `yield`.
330
361
 
331
362
  This is great for including all of your JavaScript at the bottom of the page.
332
363
 
333
- ### Data
334
-
335
- Pass data as a hash or array
336
-
337
- ```erb
338
- <%= pie_chart({"Football" => 10, "Basketball" => 5}) %>
339
- <%= pie_chart [["Football", 10], ["Basketball", 5]] %>
340
- ```
341
-
342
- For multiple series, use the format
343
-
344
- ```erb
345
- <%= line_chart [
346
- {name: "Series A", data: series_a},
347
- {name: "Series B", data: series_b}
348
- ] %>
349
- ```
350
-
351
- Times can be a time or a string (strings are parsed)
352
-
353
- ```erb
354
- <%= line_chart({20.day.ago => 5, "2021-05-07 00:00:00 UTC" => 7}) %>
355
- ```
356
-
357
364
  ### Multiple Series
358
365
 
359
366
  You can pass a few options with a series:
@@ -440,6 +447,20 @@ For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
440
447
  //= require Chart.bundle
441
448
  ```
442
449
 
450
+ For Rails 7 / Importmap (experimental), in `config/importmap.rb`, add:
451
+
452
+ ```ruby
453
+ pin "chartkick", to: "chartkick.js"
454
+ pin "Chart.bundle", to: "Chart.bundle.js"
455
+ ```
456
+
457
+ And in `app/javascript/application.js`, add:
458
+
459
+ ```js
460
+ import "chartkick"
461
+ import "Chart.bundle"
462
+ ```
463
+
443
464
  ### Google Charts
444
465
 
445
466
  In your layout or views, add:
@@ -466,6 +487,18 @@ For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
466
487
  //= require chartkick
467
488
  ```
468
489
 
490
+ For Rails 7 / Importmap (experimental), in `config/importmap.rb`, add:
491
+
492
+ ```ruby
493
+ pin "chartkick", to: "chartkick.js"
494
+ ```
495
+
496
+ And in `app/javascript/application.js`, add:
497
+
498
+ ```js
499
+ import "chartkick"
500
+ ```
501
+
469
502
  To specify a language or Google Maps API key, use:
470
503
 
471
504
  ```js
@@ -495,6 +528,27 @@ For Rails 5 / Sprockets, download [highcharts.js](https://code.highcharts.com/hi
495
528
  //= require highcharts
496
529
  ```
497
530
 
531
+ For Rails 7 / Importmap (experimental), in `config/importmap.rb`, add:
532
+
533
+ ```ruby
534
+ pin "chartkick", to: "chartkick.js"
535
+ ```
536
+
537
+ And run:
538
+
539
+ ```sh
540
+ bin/importmap pin highcharts --download
541
+ ```
542
+
543
+ And in `app/javascript/application.js`, add:
544
+
545
+ ```js
546
+ import "chartkick"
547
+ import Highcharts from "highcharts"
548
+
549
+ window.Highcharts = Highcharts
550
+ ```
551
+
498
552
  ### Sinatra and Padrino
499
553
 
500
554
  Download [chartkick.js](https://raw.githubusercontent.com/ankane/chartkick/master/vendor/assets/javascripts/chartkick.js) and include it manually.
@@ -1,5 +1,13 @@
1
1
  module Chartkick
2
2
  class Engine < ::Rails::Engine
3
3
  # for assets
4
+
5
+ # for importmap
6
+ if defined?(Importmap)
7
+ initializer "chartkick.importmap", after: "importmap" do |app|
8
+ app.config.assets.precompile << "chartkick.js"
9
+ app.config.assets.precompile << "Chart.bundle.js"
10
+ end
11
+ end
4
12
  end
5
13
  end
@@ -117,6 +117,7 @@ module Chartkick
117
117
  <script#{nonce_html}>
118
118
  (function() {
119
119
  if (document.documentElement.hasAttribute("data-turbolinks-preview")) return;
120
+ if (document.documentElement.hasAttribute("data-turbo-preview")) return;
120
121
 
121
122
  var createChart = function() { #{createjs} };
122
123
  if ("Chartkick" in window) {
@@ -1,3 +1,3 @@
1
1
  module Chartkick
2
- VERSION = "4.0.4"
2
+ VERSION = "4.1.2"
3
3
  end
@@ -1,20 +1,21 @@
1
- Copyright (C) 2020 Sasha Koss and Lesha Koss
2
-
3
- # License
4
-
5
- date-fns is licensed under the [MIT license](http://kossnocorp.mit-license.org).
6
- Read more about MIT at [TLDRLegal](https://tldrlegal.com/license/mit-license).
7
-
8
- ---
9
-
10
- Text from http://kossnocorp.mit-license.org
11
-
12
- The MIT License (MIT)
13
-
14
- Copyright © 2021 Sasha Koss
15
-
16
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
17
-
18
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Sasha Koss and Lesha Koss https://kossnocorp.mit-license.org
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.