chartkick 4.0.3 → 4.1.1

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: a0db2fe39f763929c498438dc88f75dd51dbc9ace5ede4819e9f4d88c0cad72f
4
- data.tar.gz: a1dbaf6eddf2bccfdc1e6f4b9fc114eea952eb021dedb7775832d3d5c2b8a389
3
+ metadata.gz: 72d125397684b6a65e9e3982dab00818b1387be38099f45ab340c0d6d78c8911
4
+ data.tar.gz: 9465bd9225d1e97ade176c1769d4ed84664a6a069a0e181d0e8e271505711be0
5
5
  SHA512:
6
- metadata.gz: 0eccf48920536b5f4277cac070759d501ee77177805e06146db100e1818337de38e7c9ae45109362817da72425d3385993136012d57530266122deb09c670ea1
7
- data.tar.gz: 55190f89407e99810198d82cda444c49f8877b86ea0148e8d408f06a4d3fc9935e07ec77414119f4d06ccd905bf9124b6678c044c2cd9d68e7de206b2901e3d3
6
+ metadata.gz: 514165df39581c34f1d6e929cf679475c929b36e9f47fdc9cdb7d415364833ba6bd1134bc272a364f1c11731c3cee68f48a7e0598e6394e95c1c2e0607c58e91
7
+ data.tar.gz: 83eec680a359d68461c4258f98cb5f99f387624ae9c7f222f49592f5fc19b2ead5ee83aa69ff5db8a3e58408f2a9bb9887de9059cb91b9dad556c334f8ecebcf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## 4.1.1 (2021-11-06)
2
+
3
+ - Updated Chartkick.js to 4.1.1
4
+ - Updated Chart.js to 3.6.0
5
+
6
+ ## 4.1.0 (2021-10-23)
7
+
8
+ - Added support for Turbo
9
+ - Added experimental support for `importmap-rails`
10
+ - Updated Chartkick.js to 4.1.0
11
+
12
+ ## 4.0.5 (2021-07-07)
13
+
14
+ - Updated Chartkick.js to 4.0.5
15
+ - Updated Chart.js to 3.4.1
16
+
17
+ ## 4.0.4 (2021-05-01)
18
+
19
+ - Updated Chartkick.js to 4.0.4
20
+ - Updated Chart.js to 3.2.1
21
+
1
22
  ## 4.0.3 (2021-04-10)
2
23
 
3
24
  - Updated Chartkick.js to 4.0.3
data/README.md CHANGED
@@ -29,7 +29,7 @@ yarn add chartkick chart.js
29
29
  And in `app/javascript/packs/application.js`, add:
30
30
 
31
31
  ```js
32
- require("chartkick/chart.js")
32
+ import "chartkick/chart.js"
33
33
  ```
34
34
 
35
35
  For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
@@ -39,6 +39,13 @@ 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 `app/javascript/application.js`, add:
43
+
44
+ ```js
45
+ import "chartkick"
46
+ import "Chart.bundle"
47
+ ```
48
+
42
49
  This sets up Chartkick with [Chart.js](https://www.chartjs.org/). For other charting libraries, see [detailed instructions](#installation).
43
50
 
44
51
  ## Charts
@@ -98,9 +105,10 @@ Timeline - *Google Charts*
98
105
  Multiple series
99
106
 
100
107
  ```erb
101
- <%= line_chart @goals.map { |goal|
102
- {name: goal.name, data: goal.feats.group_by_week(:created_at).count}
103
- } %>
108
+ <%= line_chart [
109
+ {name: "Workout", data: {"2021-01-01" => 3, "2021-01-02" => 4}},
110
+ {name: "Call parents", data: {"2021-01-01" => 5, "2021-01-02" => 3}}
111
+ ] %>
104
112
  ```
105
113
 
106
114
  or
@@ -109,7 +117,23 @@ or
109
117
  <%= line_chart Feat.group(:goal_id).group_by_week(:created_at).count %>
110
118
  ```
111
119
 
112
- ### Say Goodbye To Timeouts
120
+ ## Data
121
+
122
+ Data can be a hash, array, or URL.
123
+
124
+ #### Hash
125
+
126
+ ```erb
127
+ <%= line_chart({"2021-01-01" => 2, "2021-01-02" => 3}) %>
128
+ ```
129
+
130
+ #### Array
131
+
132
+ ```erb
133
+ <%= line_chart [["2021-01-01", 2], ["2021-01-02", 3]] %>
134
+ ```
135
+
136
+ #### URL
113
137
 
114
138
  Make your pages load super fast and stop worrying about timeouts. Give each chart its own endpoint.
115
139
 
@@ -133,7 +157,7 @@ For multiple series, add `chart_json` at the end.
133
157
  render json: Task.group(:goal_id).group_by_day(:completed_at).count.chart_json
134
158
  ```
135
159
 
136
- ### Options
160
+ ## Options
137
161
 
138
162
  Id, width, and height
139
163
 
@@ -330,30 +354,6 @@ For Padrino, use `yield_content` instead of `yield`.
330
354
 
331
355
  This is great for including all of your JavaScript at the bottom of the page.
332
356
 
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
357
  ### Multiple Series
358
358
 
359
359
  You can pass a few options with a series:
@@ -430,7 +430,7 @@ yarn add chartkick chart.js
430
430
  And in `app/javascript/packs/application.js`, add:
431
431
 
432
432
  ```js
433
- require("chartkick/chart.js")
433
+ import "chartkick/chart.js"
434
434
  ```
435
435
 
436
436
  For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
@@ -440,6 +440,13 @@ For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
440
440
  //= require Chart.bundle
441
441
  ```
442
442
 
443
+ For Rails 7 / Importmap (experimental), in `app/javascript/application.js`, add:
444
+
445
+ ```js
446
+ import "chartkick"
447
+ import "Chart.bundle"
448
+ ```
449
+
443
450
  ### Google Charts
444
451
 
445
452
  In your layout or views, add:
@@ -457,7 +464,7 @@ yarn add chartkick
457
464
  And in `app/javascript/packs/application.js`, add:
458
465
 
459
466
  ```js
460
- require("chartkick")
467
+ import "chartkick"
461
468
  ```
462
469
 
463
470
  For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
@@ -466,6 +473,12 @@ For Rails 5 / Sprockets, in `app/assets/javascripts/application.js`, add:
466
473
  //= require chartkick
467
474
  ```
468
475
 
476
+ For Rails 7 / Importmap (experimental), in `app/javascript/application.js`, add:
477
+
478
+ ```js
479
+ import "chartkick"
480
+ ```
481
+
469
482
  To specify a language or Google Maps API key, use:
470
483
 
471
484
  ```js
@@ -485,7 +498,7 @@ yarn add chartkick highcharts
485
498
  And in `app/javascript/packs/application.js`, add:
486
499
 
487
500
  ```js
488
- require("chartkick/highcharts")
501
+ import "chartkick/highcharts"
489
502
  ```
490
503
 
491
504
  For Rails 5 / 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:
@@ -495,6 +508,21 @@ For Rails 5 / Sprockets, download [highcharts.js](https://code.highcharts.com/hi
495
508
  //= require highcharts
496
509
  ```
497
510
 
511
+ For Rails 7 / Importmap (experimental), run:
512
+
513
+ ```sh
514
+ bin/importmap pin highcharts --download
515
+ ```
516
+
517
+ And in `app/javascript/application.js`, add:
518
+
519
+ ```js
520
+ import "chartkick"
521
+ import Highcharts from "highcharts"
522
+
523
+ window.Highcharts = Highcharts
524
+ ```
525
+
498
526
  ### Sinatra and Padrino
499
527
 
500
528
  Download [chartkick.js](https://raw.githubusercontent.com/ankane/chartkick/master/vendor/assets/javascripts/chartkick.js) and include it manually.
@@ -0,0 +1 @@
1
+ pin_all_from File.expand_path("../vendor/assets/javascripts", __dir__)
@@ -1,5 +1,14 @@
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.importmap.draw(Engine.root.join("config/importmap.rb"))
9
+ app.config.assets.precompile << "chartkick.js"
10
+ app.config.assets.precompile << "Chart.bundle.js"
11
+ end
12
+ end
4
13
  end
5
14
  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.3"
2
+ VERSION = "4.1.1"
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.