chartkick 4.0.5 → 4.1.3

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: ecf49f61e1962e1952df47113fea621bafe1bb423e50903ce98e1b6213c3c9cb
4
- data.tar.gz: 29167dca418215178ea525061dc3113d186a53076ce77472241f54e99edc4b13
3
+ metadata.gz: 89ed1824ceea10158a8321a32e75daeb96dcb1eaeea839dc6f4eddd1de97cd88
4
+ data.tar.gz: 8c4a6ff2477b7314cec55237fbcfafe7e0b95efb4890a50925edb4eb095bb468
5
5
  SHA512:
6
- metadata.gz: 4ba35050af1933c7d343125a291a515e26f6ae143b081d6346e0e709b920d299ff44a0f262559b1b358d778154b2a103132b751f9c37a905c5e789776bafca17
7
- data.tar.gz: 3a3f5d3c57e7af61bcfc7b86d5888b4f2124b5e07fa86256eb7eb6298125b14c5a6293e926802ea3ac2d45a48fdf5fd222a2c47ba9ffb08209f8dc5768ad6000
6
+ metadata.gz: 5f6bedf2f1e49a194cdede42c1fb80d7dbf02a0d26955f0c0248b625736efc52269c966b3c8a50a0f3ba8bc5782bc7ad6843195a123fe6e9211026255305c825
7
+ data.tar.gz: 341942cf99eaf9a262d13b0abc8ca00898d88a2ac688a269bf932e6d0e365592a1ccca0f46bbc9e4ebca9fffcb9991853a8c4ea82448e73fe04b1847f12d5bd4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## 4.1.3 (2022-01-15)
2
+
3
+ - Support for `importmap-rails` is no longer experimental
4
+ - Updated Chart.js to 3.7.0
5
+ - Fixed asset precompilation error with `importmap-rails`
6
+
7
+ ## 4.1.2 (2021-11-06)
8
+
9
+ - Removed automatic pinning for `importmap-rails` (still experimental)
10
+
11
+ ## 4.1.1 (2021-11-06)
12
+
13
+ - Updated Chartkick.js to 4.1.1
14
+ - Updated Chart.js to 3.6.0
15
+
16
+ ## 4.1.0 (2021-10-23)
17
+
18
+ - Added support for Turbo
19
+ - Added experimental support for `importmap-rails`
20
+ - Updated Chartkick.js to 4.1.0
21
+
1
22
  ## 4.0.5 (2021-07-07)
2
23
 
3
24
  - Updated Chartkick.js to 4.0.5
data/README.md CHANGED
@@ -20,7 +20,33 @@ Add this line to your application’s Gemfile:
20
20
  gem "chartkick"
21
21
  ```
22
22
 
23
- For Rails 6 / Webpacker, run:
23
+ Then follow the instructions for your framework:
24
+
25
+ - [Rails 7 / Importmap](#rails-7--importmap)
26
+ - [Rails 6 / Webpacker](#rails-6--webpacker)
27
+ - [Rails 5 / Sprockets](#rails-5--sprockets)
28
+
29
+ This sets up Chartkick with [Chart.js](https://www.chartjs.org/). For other charting libraries and frameworks, see [detailed instructions](#installation).
30
+
31
+ ### Rails 7 / Importmap
32
+
33
+ In `config/importmap.rb`, add:
34
+
35
+ ```ruby
36
+ pin "chartkick", to: "chartkick.js"
37
+ pin "Chart.bundle", to: "Chart.bundle.js"
38
+ ```
39
+
40
+ And in `app/javascript/application.js`, add:
41
+
42
+ ```js
43
+ import "chartkick"
44
+ import "Chart.bundle"
45
+ ```
46
+
47
+ ### Rails 6 / Webpacker
48
+
49
+ Run:
24
50
 
25
51
  ```sh
26
52
  yarn add chartkick chart.js
@@ -32,15 +58,15 @@ And in `app/javascript/packs/application.js`, add:
32
58
  import "chartkick/chart.js"
33
59
  ```
34
60
 
35
- For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
61
+ ### Rails 5 / Sprockets
62
+
63
+ In `app/assets/javascripts/application.js`, add:
36
64
 
37
65
  ```js
38
66
  //= require chartkick
39
67
  //= require Chart.bundle
40
68
  ```
41
69
 
42
- This sets up Chartkick with [Chart.js](https://www.chartjs.org/). For other charting libraries, see [detailed instructions](#installation).
43
-
44
70
  ## Charts
45
71
 
46
72
  Line chart
@@ -98,9 +124,10 @@ Timeline - *Google Charts*
98
124
  Multiple series
99
125
 
100
126
  ```erb
101
- <%= line_chart @goals.map { |goal|
102
- {name: goal.name, data: goal.feats.group_by_week(:created_at).count}
103
- } %>
127
+ <%= line_chart [
128
+ {name: "Workout", data: {"2021-01-01" => 3, "2021-01-02" => 4}},
129
+ {name: "Call parents", data: {"2021-01-01" => 5, "2021-01-02" => 3}}
130
+ ] %>
104
131
  ```
105
132
 
106
133
  or
@@ -109,7 +136,23 @@ or
109
136
  <%= line_chart Feat.group(:goal_id).group_by_week(:created_at).count %>
110
137
  ```
111
138
 
112
- ### Say Goodbye To Timeouts
139
+ ## Data
140
+
141
+ Data can be a hash, array, or URL.
142
+
143
+ #### Hash
144
+
145
+ ```erb
146
+ <%= line_chart({"2021-01-01" => 2, "2021-01-02" => 3}) %>
147
+ ```
148
+
149
+ #### Array
150
+
151
+ ```erb
152
+ <%= line_chart [["2021-01-01", 2], ["2021-01-02", 3]] %>
153
+ ```
154
+
155
+ #### URL
113
156
 
114
157
  Make your pages load super fast and stop worrying about timeouts. Give each chart its own endpoint.
115
158
 
@@ -133,7 +176,7 @@ For multiple series, add `chart_json` at the end.
133
176
  render json: Task.group(:goal_id).group_by_day(:completed_at).count.chart_json
134
177
  ```
135
178
 
136
- ### Options
179
+ ## Options
137
180
 
138
181
  Id, width, and height
139
182
 
@@ -330,30 +373,6 @@ For Padrino, use `yield_content` instead of `yield`.
330
373
 
331
374
  This is great for including all of your JavaScript at the bottom of the page.
332
375
 
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
376
  ### Multiple Series
358
377
 
359
378
  You can pass a few options with a series:
@@ -421,6 +440,20 @@ Next, choose your charting library.
421
440
 
422
441
  ### Chart.js
423
442
 
443
+ For Rails 7 / Importmap, in `config/importmap.rb`, add:
444
+
445
+ ```ruby
446
+ pin "chartkick", to: "chartkick.js"
447
+ pin "Chart.bundle", to: "Chart.bundle.js"
448
+ ```
449
+
450
+ And in `app/javascript/application.js`, add:
451
+
452
+ ```js
453
+ import "chartkick"
454
+ import "Chart.bundle"
455
+ ```
456
+
424
457
  For Rails 6 / Webpacker, run:
425
458
 
426
459
  ```sh
@@ -448,6 +481,18 @@ In your layout or views, add:
448
481
  <%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" %>
449
482
  ```
450
483
 
484
+ For Rails 7 / Importmap, in `config/importmap.rb`, add:
485
+
486
+ ```ruby
487
+ pin "chartkick", to: "chartkick.js"
488
+ ```
489
+
490
+ And in `app/javascript/application.js`, add:
491
+
492
+ ```js
493
+ import "chartkick"
494
+ ```
495
+
451
496
  For Rails 6 / Webpacker, run:
452
497
 
453
498
  ```sh
@@ -476,6 +521,27 @@ before your charts.
476
521
 
477
522
  ### Highcharts
478
523
 
524
+ For Rails 7 / Importmap, run:
525
+
526
+ ```sh
527
+ bin/importmap pin highcharts --download
528
+ ```
529
+
530
+ And in `config/importmap.rb`, add:
531
+
532
+ ```ruby
533
+ pin "chartkick", to: "chartkick.js"
534
+ ```
535
+
536
+ And in `app/javascript/application.js`, add:
537
+
538
+ ```js
539
+ import "chartkick"
540
+ import Highcharts from "highcharts"
541
+
542
+ window.Highcharts = Highcharts
543
+ ```
544
+
479
545
  For Rails 6 / Webpacker, run:
480
546
 
481
547
  ```sh
@@ -1,5 +1,13 @@
1
1
  module Chartkick
2
2
  class Engine < ::Rails::Engine
3
3
  # for assets
4
+
5
+ # for importmap
6
+ initializer "chartkick.importmap" do |app|
7
+ if defined?(Importmap)
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.5"
2
+ VERSION = "4.1.3"
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.