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 +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +99 -33
- data/lib/chartkick/engine.rb +8 -0
- data/lib/chartkick/helper.rb +1 -0
- data/lib/chartkick/version.rb +1 -1
- data/licenses/LICENSE-date-fns.txt +21 -20
- data/vendor/assets/javascripts/Chart.bundle.js +3073 -2478
- data/vendor/assets/javascripts/chartkick.js +8 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89ed1824ceea10158a8321a32e75daeb96dcb1eaeea839dc6f4eddd1de97cd88
|
4
|
+
data.tar.gz: 8c4a6ff2477b7314cec55237fbcfafe7e0b95efb4890a50925edb4eb095bb468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
102
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/chartkick/engine.rb
CHANGED
@@ -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
|
data/lib/chartkick/helper.rb
CHANGED
@@ -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) {
|
data/lib/chartkick/version.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
The
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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.
|