chartkick 4.0.3 → 4.1.1
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 +21 -0
- data/README.md +61 -33
- data/config/importmap.rb +1 -0
- data/lib/chartkick/engine.rb +9 -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 +3647 -2757
- data/vendor/assets/javascripts/chartkick.js +35 -15
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72d125397684b6a65e9e3982dab00818b1387be38099f45ab340c0d6d78c8911
|
|
4
|
+
data.tar.gz: 9465bd9225d1e97ade176c1769d4ed84664a6a069a0e181d0e8e271505711be0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
|
102
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
data/config/importmap.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pin_all_from File.expand_path("../vendor/assets/javascripts", __dir__)
|
data/lib/chartkick/engine.rb
CHANGED
|
@@ -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
|
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.
|