chartkick 4.0.4 → 4.1.2
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 +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +83 -29
- 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 +3348 -2672
- data/vendor/assets/javascripts/chartkick.js +18 -11
- 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: fc72b4105d5e863040aec42ff49f32623f8fa3c74488b8ecdf5bb80d465653b3
|
4
|
+
data.tar.gz: 1e17d23367ad1ab3dd619d654e36f3f7cf179ed67f16164c22262460720627d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
102
|
-
|
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
|
-
|
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
|
-
|
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.
|
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
|
+
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
|
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.
|