plot 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/plot/mark.rb +26 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67d6a3629080da18f0e3a73f6d8c49454c32698e54581c8b7bf8744c4773649c
4
- data.tar.gz: c4456dfbd322ae85cfe26e26e063122942922d9781eb4649a82351c8811b54d8
3
+ metadata.gz: 52d7e627ba05b46d6406679d44e071eb63762d9bdc4a8904883b4bffa4cb23e1
4
+ data.tar.gz: a475675aad7a4930ad021ae74f748879d4cd6464142c4accff94cd52cabe7041
5
5
  SHA512:
6
- metadata.gz: 6afb6dd820edb324e75f3478610dcee2fb2798e909471c11b91dad7152ace8bd336b837fc646b7a5d1d6911c4d72d6ff223d91d5b82e61df1411da8a249a1d29
7
- data.tar.gz: 665f0c522e9e9c37ba2093972367ff5a5115df26efa34300ecaef5606170a281a857333dfb2010cea1a2d5426029815fc21b1d928bfeb28fef7b339e1b6b3d5d
6
+ metadata.gz: 974a4403d5a7c3e4f98c63e7d85b3bfeb612671177f89080abbc912b6d1f12633754a1943e881fba6245dc89e08b984852c28ac6915f1b9cd313ae5a254b653d
7
+ data.tar.gz: 3ba284e6c02b47d58df65c476500b1673ec5a5fa316746e58e2ac6de463a731bc254f2e785e59f3855e632dc225e0b9dcad969fa7cdbbed774150b3cff83c6b3
data/lib/plot/mark.rb CHANGED
@@ -6,15 +6,25 @@ class Plot::MarkProxy
6
6
 
7
7
  def channel(name, value, **obj)
8
8
  # TODO: add checking if option is a channel
9
- obj[:value] = value
10
- @mark.add_option(name, obj)
9
+
10
+ if !obj.blank?
11
+ obj[:value] = value
12
+ @mark.add_option(name, obj)
13
+ else
14
+ @mark.add_option(name, value)
15
+ end
11
16
  end
12
17
 
13
- def option(name, value)
18
+ def option(name, value, wrap: false)
14
19
  if(value.class == Proc || [:title, :href, :ariaLabel].include?(name)) then
15
20
  raise "A channel should be used in place of option"
16
21
  end
17
- @mark.add_option(name, { value: value })
22
+
23
+ if wrap then
24
+ @mark.add_option(name, { value: value })
25
+ else
26
+ @mark.add_option(name, value )
27
+ end
18
28
  end
19
29
 
20
30
  def style(name, value)
@@ -82,7 +92,18 @@ class Plot::Mark
82
92
  end
83
93
  end
84
94
 
85
- "Plot['#{@type}'](JSON.parse('#{JSON.generate(data)}'), JSON.parse('#{JSON.generate(@options)}'))"
95
+ data.each do |d|
96
+ d.each do |k,v|
97
+ if v.class == Date then
98
+ d[k] = {
99
+ date: true,
100
+ string: v.to_s
101
+ }
102
+ end
103
+ end
104
+ end
105
+
106
+ "Plot['#{@type}'](JSON.parse(`#{JSON.generate(data)}`).map((obj) => { Object.keys(obj).forEach((k) => { if (obj[k].date) { obj[k] = new Date(Date.parse(obj[k].string)) } } ); return obj; }), JSON.parse('#{JSON.generate(@options)}'))"
86
107
  end
87
108
 
88
109
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reese Armstrong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-10 00:00:00.000000000 Z
11
+ date: 2023-10-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An unofficial DSL for making charts with Observable Plot. You define
14
14
  plot definitions with the DSL that create full charts when data is added. This gem