plotlyjs-ruby 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef9052b2bae4fd4db64519fdf870d90bd22919f3f79f9e3e27a9e9e8d79dbe45
4
- data.tar.gz: 53713eef32c9ded13eb0bcffaa375c9f0e7686f0c847d275f7d4893eb940ecb1
3
+ metadata.gz: 5e4f5777d446a41730047284dddd23ccc0723f758801175584db01706d9dec98
4
+ data.tar.gz: b39e14784091a7ddd7b76fc222186c98d5288b9ed731391e3268ae7869a79edf
5
5
  SHA512:
6
- metadata.gz: eabf5989d306f40581f74bca6247d93191e39a2698e5a1ecdddd5b5c72a2200b781ccbd1dce290aef41f24aa263049591dbe909b2e9604a318106cc0e54fcb67
7
- data.tar.gz: cfb1b5dd3169a80f10118d98d74ade1fec6985ce27c7565d106be876722b3886ab3c7449b486982c1404183b15b58ce8bac29cb10f8529968c53b6be97516cb3
6
+ metadata.gz: 4e5cf6c6a25fe897a9963b772cd3ae181d648e7a673c83ae7b245f35d0c196b1da93cd21dd29c0472853ab3e76cb2c7c43845e59d26c4cfd114b5a7bb81733d9
7
+ data.tar.gz: 3b507f76dd03c6444197309f23c33b9dbd6cbb15d387da0f865d37f75619e2e3bb8aba6df7040a98581f1838835e5f3c7a1366b657fbffdc1e785b1be542ecb6
data/README.md CHANGED
@@ -32,8 +32,9 @@ To create a basic plot, use the following code in your view:
32
32
 
33
33
  ```erb
34
34
  <%= Plotlyjs.new_plot(
35
- [{ x: [1, 2, 3, 4, 5] }, { y: [1, 2, 4, 8, 16]}],
36
- { width: 600, height: 250, margin: { t: 0 } }
35
+ "charts",
36
+ data: [{ x: [1, 2, 3, 4, 5] }, { y: [1, 2, 4, 8, 16]}],
37
+ layout: { width: 600, height: 250, margin: { t: 0 } }
37
38
  ) %>
38
39
  ```
39
40
 
@@ -1,16 +1,16 @@
1
1
  module Plotlyjs
2
2
  class Chart
3
- attr_reader :data, :layout, :config
3
+ attr_reader :element_id, :data, :layout, :config
4
+
5
+ def initialize(*ids, data:, layout:, config:)
6
+ @element_id = "plotlyjs-ruby-#{ids.join("_")}"
4
7
 
5
- def initialize(data, layout, config)
6
8
  @data = data
7
9
  @layout = layout
8
10
  @config = config
9
11
  end
10
12
 
11
13
  def to_html
12
- element_id = config.delete(:id) ||"plotly-chart-#{self.object_id}"
13
-
14
14
  js_vars = {
15
15
  data: data.to_json,
16
16
  layout: layout.to_json,
@@ -1,3 +1,3 @@
1
1
  module Plotlyjs
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/plotlyjs-ruby.rb CHANGED
@@ -7,10 +7,10 @@ require_relative 'plotlyjs/version'
7
7
 
8
8
  module Plotlyjs
9
9
  class << self
10
- def new_plot(data, layout = {}, config = {})
10
+ def new_plot(*ids, data: nil, layout: {}, config: {})
11
11
  merged_config = Plotlyjs::Utils.deep_merge(configuration.options, config)
12
12
 
13
- chart = Chart.new(data, layout, merged_config)
13
+ chart = Chart.new(ids, data: data, layout: layout, config: merged_config)
14
14
  chart.to_html
15
15
  end
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plotlyjs-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nightswinger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-07 00:00:00.000000000 Z
11
+ date: 2025-01-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A lightweight and straightforward Ruby wrapper for Plotly.js, enabling
14
14
  developers to create interactive, high-quality data visualizations effortlessly.