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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3b596c09118b82dc1166f6413ff31aae7801b79db73f4dc2e09acab9ccfa21a
4
- data.tar.gz: 9ce59baf66bfd278f457a7686d8d8b2e4aa9c6f046d99b1d1184d206b6a680a0
3
+ metadata.gz: 81ef88e1766446a7d367331b58abcc2113a05cc3a914891dc81f5f82a026070f
4
+ data.tar.gz: 31f67095fcebf1cafa5bf8e50b81bf8a6830082d43bb383a7b6c299034907d24
5
5
  SHA512:
6
- metadata.gz: 79c6c4705a054f0f9b9a4001f10496c1af17440ebf672c77ca856a35c9778c98ed40ce5f31ac90f31b05ec23df9640ff41d070b31b8466e8dec7930b1cf1a56d
7
- data.tar.gz: ff0808b2c0cbaac73e266798cb048c6d0884e36b135f76bc5ebe74af5125a42a7e9a7018c22a7077a4c8530be431171cdc3b6d4a9e28a48643a24772b65537f7
6
+ metadata.gz: fbd22ed80b972dbbc1ab134755a4903b255b328963a8533e7e7cae29403cd1ac81aca3f84f8a0b0f42e93515a18d85a5ec582193a3a1d020f79527a66b8fd1aa
7
+ data.tar.gz: 19fad72d73ceddfaf669e3a0c0a970bdaeac5996018522e3acffca488533723e4e79a9609741399aefc1480a74891ac8f2b4db1a62540f107694fcc3e25e0a8d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.0 (2021-10-23)
2
+
3
+ - Added experimental support for `importmap-rails`
4
+ - Updated Vega to 5.21.0, Vega-Lite to 5.1.1, and Vega-Embed to 6.19.1
5
+
1
6
  ## 0.1.3 (2021-03-14)
2
7
 
3
8
  - Added Vega-Interpreter
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.19.1"></script>
60
- <script src="https://cdn.jsdelivr.net/npm/vega-lite@4.17.0"></script>
61
- <script src="https://cdn.jsdelivr.net/npm/vega-embed@6.15.1"></script>
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
  ```
@@ -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
@@ -11,7 +11,7 @@ module Vega
11
11
  :transform, :layer, :hconcat, :vconcat, :concat
12
12
 
13
13
  def initialize
14
- @schema = "https://vega.github.io/schema/vega-lite/v4.json"
14
+ @schema = "https://vega.github.io/schema/vega-lite/v5.json"
15
15
  super()
16
16
  end
17
17
 
data/lib/vega/spec.rb CHANGED
@@ -11,7 +11,14 @@ module Vega
11
11
  output = <<~EOS
12
12
  #{html}
13
13
  <script>
14
- #{js}
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.19.1?noext',
29
- 'vega-lite': 'https://cdn.jsdelivr.net/npm/vega-lite@4.17.0?noext',
30
- 'vega-embed': 'https://cdn.jsdelivr.net/npm/vega-embed@6.15.1?noext'
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
@@ -1,3 +1,3 @@
1
1
  module Vega
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2018, University of Washington Interactive Data Lab
1
+ Copyright (c) 2015-2021, University of Washington Interactive Data Lab
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without