mattetti-googlecharts 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +2 -0
- data/lib/gchart/theme.rb +46 -0
- data/lib/gchart/version.rb +1 -1
- data/lib/themes.yml +45 -0
- metadata +3 -1
data/Manifest.txt
CHANGED
data/lib/gchart/theme.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Chart
|
4
|
+
class Theme
|
5
|
+
class ThemeNotFound < RuntimeError; end
|
6
|
+
|
7
|
+
@@theme_files = ["#{File.dirname(__FILE__)}/../themes.yml"]
|
8
|
+
|
9
|
+
attr_accessor :colors
|
10
|
+
attr_accessor :bar_colors
|
11
|
+
attr_accessor :background
|
12
|
+
attr_accessor :chart_background
|
13
|
+
|
14
|
+
def self.load(theme_name)
|
15
|
+
theme = new(theme_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.theme_files
|
19
|
+
@@theme_files
|
20
|
+
end
|
21
|
+
|
22
|
+
# Allows you to specify paths for custom theme files in YAML format
|
23
|
+
def self.add_theme_file(file)
|
24
|
+
@@theme_files << file
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(theme_name)
|
28
|
+
themes = {}
|
29
|
+
@@theme_files.each {|f| themes.update YAML::load(File.open(f))}
|
30
|
+
theme = themes[theme_name]
|
31
|
+
if theme
|
32
|
+
self.colors = theme[:colors]
|
33
|
+
self.bar_colors = theme[:bar_colors]
|
34
|
+
self.background = theme[:background]
|
35
|
+
self.chart_background = theme[:chart_background]
|
36
|
+
self
|
37
|
+
else
|
38
|
+
raise(ThemeNotFound, "Could not locate the #{theme_name} theme ...")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_options
|
43
|
+
{:background => background, :chart_background => chart_background, :bar_colors => bar_colors.join(',')}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/gchart/version.rb
CHANGED
data/lib/themes.yml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#Default themes ganked from Gruff: http://github.com/topfunky/gruff/tree/master
|
2
|
+
:keynote:
|
3
|
+
:colors:
|
4
|
+
- &blue 6886B4
|
5
|
+
- &yellow FDD84E
|
6
|
+
- &green 72AE6E
|
7
|
+
- &red D1695E
|
8
|
+
- &purple 8A6EAF
|
9
|
+
- &orange EFAA43
|
10
|
+
- &white FFFFFF
|
11
|
+
- &black !str 000000
|
12
|
+
:bar_colors: [ *blue, *yellow, *green, *red, *purple, *orange ]
|
13
|
+
:background: *black
|
14
|
+
:chart_background: *white
|
15
|
+
:thirty7signals:
|
16
|
+
:colors:
|
17
|
+
- &green 339933
|
18
|
+
- &purple cc99cc
|
19
|
+
- &blue 336699
|
20
|
+
- &yellow FFF804
|
21
|
+
- &red ff0000
|
22
|
+
- &orange cf5910
|
23
|
+
:bar_colors: [ *yellow, *blue, *green, *red, *purple, *orange ]
|
24
|
+
:background: *white
|
25
|
+
:pastel:
|
26
|
+
:colors:
|
27
|
+
- &blue a9dada
|
28
|
+
- &green aedaa9
|
29
|
+
- &peach daaea9
|
30
|
+
- &yellow dadaa9
|
31
|
+
- &dk_purple a9a9da
|
32
|
+
- &purple daaeda
|
33
|
+
- &grey dadada
|
34
|
+
:bar_colors: [ *blue, *green, *peach, *yellow, *dk_purple ]
|
35
|
+
:background_color: *white
|
36
|
+
:greyscale:
|
37
|
+
:bar_colors: [
|
38
|
+
282828,
|
39
|
+
383838,
|
40
|
+
686868,
|
41
|
+
989898,
|
42
|
+
c8c8c8,
|
43
|
+
e8e8e8
|
44
|
+
]
|
45
|
+
:background_color: *white
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mattetti-googlecharts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Aimonetti
|
@@ -35,6 +35,8 @@ files:
|
|
35
35
|
- config/requirements.rb
|
36
36
|
- lib/gchart.rb
|
37
37
|
- lib/gchart/aliases.rb
|
38
|
+
- lib/gchart/theme.rb
|
39
|
+
- lib/themes.yml
|
38
40
|
- lib/gchart/version.rb
|
39
41
|
- setup.rb
|
40
42
|
- spec/gchart_spec.rb
|