plotlyjs-ruby 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/plotlyjs/chart.rb +4 -4
- data/lib/plotlyjs/version.rb +1 -1
- data/lib/plotlyjs-ruby.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e4f5777d446a41730047284dddd23ccc0723f758801175584db01706d9dec98
|
4
|
+
data.tar.gz: b39e14784091a7ddd7b76fc222186c98d5288b9ed731391e3268ae7869a79edf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
36
|
-
{
|
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
|
|
data/lib/plotlyjs/chart.rb
CHANGED
@@ -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,
|
data/lib/plotlyjs/version.rb
CHANGED
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
|
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.
|
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-
|
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.
|