vega 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +28 -9
- data/config/importmap.rb +1 -0
- data/lib/vega/engine.rb +11 -0
- data/lib/vega/lite_chart.rb +1 -1
- data/lib/vega/spec.rb +13 -5
- data/lib/vega/version.rb +1 -1
- data/licenses/LICENSE-vega.txt +1 -1
- data/vendor/assets/javascripts/vega-embed.js +3884 -3159
- data/vendor/assets/javascripts/vega-lite.js +5558 -5550
- data/vendor/assets/javascripts/vega.js +3632 -3509
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81ef88e1766446a7d367331b58abcc2113a05cc3a914891dc81f5f82a026070f
|
4
|
+
data.tar.gz: 31f67095fcebf1cafa5bf8e50b81bf8a6830082d43bb383a7b6c299034907d24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbd22ed80b972dbbc1ab134755a4903b255b328963a8533e7e7cae29403cd1ac81aca3f84f8a0b0f42e93515a18d85a5ec582193a3a1d020f79527a66b8fd1aa
|
7
|
+
data.tar.gz: 19fad72d73ceddfaf669e3a0c0a970bdaeac5996018522e3acffca488533723e4e79a9609741399aefc1480a74891ac8f2b4db1a62540f107694fcc3e25e0a8d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Interactive charts for Ruby, powered by [Vega](https://vega.github.io/vega/) and
|
|
6
6
|
|
7
7
|
Works with Rails, iRuby, and other frameworks
|
8
8
|
|
9
|
-
[![Build Status](https://github.com/ankane/vega/workflows/build/badge.svg?branch=master)](https://github.com/ankane/vega/actions)
|
9
|
+
[![Build Status](https://github.com/ankane/vega-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/vega-ruby/actions)
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -18,11 +18,24 @@ gem 'vega'
|
|
18
18
|
|
19
19
|
The follow the instructions for how you plan to use it:
|
20
20
|
|
21
|
+
- [Rails 7 / Importmap](#rails-7--importmap) (experimental)
|
21
22
|
- [Rails 6 / Webpacker](#rails-6--webpacker)
|
22
23
|
- [Rails 5 / Sprockets](#rails-5--sprockets)
|
23
24
|
- [iRuby](#iruby)
|
24
25
|
- [Other](#other)
|
25
26
|
|
27
|
+
### Rails 7 / Importmap
|
28
|
+
|
29
|
+
Add to `app/javascript/application.js`:
|
30
|
+
|
31
|
+
```js
|
32
|
+
import "vega"
|
33
|
+
import "vega-lite"
|
34
|
+
import "vega-embed"
|
35
|
+
|
36
|
+
window.dispatchEvent(new Event("vega:load"));
|
37
|
+
```
|
38
|
+
|
26
39
|
### Rails 6 / Webpacker
|
27
40
|
|
28
41
|
Run:
|
@@ -56,9 +69,9 @@ No additional set up is needed.
|
|
56
69
|
For Sinatra and other web frameworks, include the Vega JavaScript files on pages with charts:
|
57
70
|
|
58
71
|
```html
|
59
|
-
<script src="https://cdn.jsdelivr.net/npm/vega@5.
|
60
|
-
<script src="https://cdn.jsdelivr.net/npm/vega-lite@
|
61
|
-
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6.
|
72
|
+
<script src="https://cdn.jsdelivr.net/npm/vega@5.21.0"></script>
|
73
|
+
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5.1.1"></script>
|
74
|
+
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6.19.1"></script>
|
62
75
|
```
|
63
76
|
|
64
77
|
## Getting Started
|
@@ -322,6 +335,12 @@ chart.spec
|
|
322
335
|
|
323
336
|
By default, the Vega parser uses the Function constructor, which [can cause issues with CSP](https://vega.github.io/vega/usage/interpreter/).
|
324
337
|
|
338
|
+
For Rails 7 / Importmap, add to `app/javascript/application.js`:
|
339
|
+
|
340
|
+
```js
|
341
|
+
import "vega-interpreter"
|
342
|
+
```
|
343
|
+
|
325
344
|
For Rails 6 / Webpacker, run:
|
326
345
|
|
327
346
|
```sh
|
@@ -342,22 +361,22 @@ embed_options(ast: true)
|
|
342
361
|
|
343
362
|
## History
|
344
363
|
|
345
|
-
View the [changelog](https://github.com/ankane/vega/blob/master/CHANGELOG.md)
|
364
|
+
View the [changelog](https://github.com/ankane/vega-ruby/blob/master/CHANGELOG.md)
|
346
365
|
|
347
366
|
## Contributing
|
348
367
|
|
349
368
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
350
369
|
|
351
|
-
- [Report bugs](https://github.com/ankane/vega/issues)
|
352
|
-
- Fix bugs and [submit pull requests](https://github.com/ankane/vega/pulls)
|
370
|
+
- [Report bugs](https://github.com/ankane/vega-ruby/issues)
|
371
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/vega-ruby/pulls)
|
353
372
|
- Write, clarify, or fix documentation
|
354
373
|
- Suggest or add new features
|
355
374
|
|
356
375
|
To get started with development:
|
357
376
|
|
358
377
|
```sh
|
359
|
-
git clone https://github.com/ankane/vega.git
|
360
|
-
cd vega
|
378
|
+
git clone https://github.com/ankane/vega-ruby.git
|
379
|
+
cd vega-ruby
|
361
380
|
bundle install
|
362
381
|
bundle exec rake test
|
363
382
|
```
|
data/config/importmap.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pin_all_from File.expand_path("../vendor/assets/javascripts", __dir__)
|
data/lib/vega/engine.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
module Vega
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
# for assets
|
4
|
+
|
5
|
+
# for importmap
|
6
|
+
if defined?(Importmap)
|
7
|
+
initializer "vega.importmap", after: "importmap" do |app|
|
8
|
+
app.importmap.draw(Engine.root.join("config/importmap.rb"))
|
9
|
+
app.config.assets.precompile << "vega-embed.js"
|
10
|
+
app.config.assets.precompile << "vega-interpreter.js"
|
11
|
+
app.config.assets.precompile << "vega-lite.js"
|
12
|
+
app.config.assets.precompile << "vega.js"
|
13
|
+
end
|
14
|
+
end
|
4
15
|
end
|
5
16
|
end
|
data/lib/vega/lite_chart.rb
CHANGED
data/lib/vega/spec.rb
CHANGED
@@ -11,7 +11,14 @@ module Vega
|
|
11
11
|
output = <<~EOS
|
12
12
|
#{html}
|
13
13
|
<script>
|
14
|
-
|
14
|
+
(function() {
|
15
|
+
var createChart = function() { #{js} };
|
16
|
+
if ("vegaEmbed" in window) {
|
17
|
+
createChart();
|
18
|
+
} else {
|
19
|
+
window.addEventListener("vega:load", createChart, true);
|
20
|
+
}
|
21
|
+
})();
|
15
22
|
</script>
|
16
23
|
EOS
|
17
24
|
output.respond_to?(:html_safe) ? output.html_safe : output
|
@@ -25,12 +32,13 @@ module Vega
|
|
25
32
|
<script>
|
26
33
|
require.config({
|
27
34
|
paths: {
|
28
|
-
'vega': 'https://cdn.jsdelivr.net/npm/vega@5.
|
29
|
-
'vega-
|
30
|
-
'vega-
|
35
|
+
'vega': 'https://cdn.jsdelivr.net/npm/vega@5.21.0?noext',
|
36
|
+
'vega-util': 'https://cdn.jsdelivr.net/npm/vega-util@1.17.0?noext',
|
37
|
+
'vega-lite': 'https://cdn.jsdelivr.net/npm/vega-lite@5.1.1?noext',
|
38
|
+
'vega-embed': 'https://cdn.jsdelivr.net/npm/vega-embed@6.19.1?noext'
|
31
39
|
}
|
32
40
|
});
|
33
|
-
require(['vega', 'vega-lite', 'vega-embed'], function(vega, vegaLite, vegaEmbed) {
|
41
|
+
require(['vega', 'vega-util', 'vega-lite', 'vega-embed'], function(vega, vegaUtil, vegaLite, vegaEmbed) {
|
34
42
|
#{js}
|
35
43
|
});
|
36
44
|
</script>
|
data/lib/vega/version.rb
CHANGED
data/licenses/LICENSE-vega.txt
CHANGED