Module: GChart
- Defined in:
- lib/gchart.rb,
lib/gchart/bar.rb,
lib/gchart/map.rb,
lib/gchart/pie.rb,
lib/gchart/axis.rb,
lib/gchart/base.rb,
lib/gchart/line.rb,
lib/gchart/venn.rb,
lib/gchart/meter.rb,
lib/gchart/colors.rb,
lib/gchart/pie_3d.rb,
lib/gchart/scatter.rb,
lib/gchart/xy_line.rb,
lib/gchart/sparkline.rb,
lib/gchart/axis/top_axis.rb,
lib/gchart/axis/left_axis.rb,
lib/gchart/axis/right_axis.rb,
lib/gchart/axis/bottom_axis.rb,
lib/gchart/axis/vertical_axis.rb,
lib/gchart/axis/horizontal_axis.rb
Defined Under Namespace
Classes: Axis, Bar, Base, BottomAxis, HorizontalAxis, LeftAxis, Line, Map, Meter, Pie, Pie3D, RightAxis, Scatter, Sparkline, TopAxis, Venn, VerticalAxis, XYLine
Constant Summary collapse
- VERSION =
"1.0.0"
- URL =
"http://chart.apis.google.com/chart"
- SIMPLE_CHARS =
('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
- EXTENDED_CHARS =
('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + %w[- .]
- EXTENDED_PAIRS =
EXTENDED_CHARS.collect { |first| EXTENDED_CHARS.collect { |second| first + second } }.flatten
- URL_MAXIMUM_LENGTH =
Google does not document this – obtained by trial and error
2074
- COLORS =
{ :black => '000000', :red => 'ff0000', :green => '00ff00', :blue => '0000ff', :yellow => 'ffff00', :cyan => '00ffff', :magenta => 'ff00ff', :white => 'ffffff', :alice_blue => 'f0f8ff', :antique_white => 'faebd7', :antique_white1 => 'ffefdb', :antique_white2 => 'eedfcc', :antique_white3 => 'cdc0b0', :antique_white4 => '8b8378', :aquamarine => '7fffd4', :aquamarine1 => '7fffd4', :aquamarine2 => '76eec6', :aquamarine3 => '66cdaa', :aquamarine4 => '458b74', :azure => 'f0ffff', :azure1 => 'f0ffff', :azure2 => 'e0eeee', :azure3 => 'c1cdcd', :azure4 => '838b8b', :beige => 'f5f5dc', :bisque => 'ffe4c4', :bisque1 => 'ffe4c4', :bisque2 => 'eed5b7', :bisque3 => 'cdb79e', :bisque4 => '8b7d6b', :blanched_almond => 'ffebcd', :blue1 => '0000ff', :blue2 => '0000ee', :blue3 => '0000cd', :blue4 => '00008b', :blue_violet => '8a2be2', :brown => 'a52a2a', :brown1 => 'ff4040', :brown2 => 'ee3b3b', :brown3 => 'cd3333', :brown4 => '8b2323', :burlywood => 'deb887', :burlywood1 => 'ffd39b', :burlywood2 => 'eec591', :burlywood3 => 'cdaa7d', :burlywood4 => '8b7355', :cadet_blue => '5f9ea0', :cadet_blue1 => '98f5ff', :cadet_blue2 => '8ee5ee', :cadet_blue3 => '7ac5cd', :cadet_blue4 => '53868b', :chartreuse => '7fff00', :chartreuse1 => '7fff00', :chartreuse2 => '76ee00', :chartreuse3 => '66cd00', :chartreuse4 => '458b00', :chocolate => 'd2691e', :chocolate1 => 'ff7f24', :chocolate2 => 'ee7621', :chocolate3 => 'cd661d', :chocolate4 => '8b4513', :coral => 'ff7f50', :coral1 => 'ff7256', :coral2 => 'ee6a50', :coral3 => 'cd5b45', :coral4 => '8b3e2f', :cornflower_blue => '6495ed', :cornsilk => 'fff8dc', :cornsilk1 => 'fff8dc', :cornsilk2 => 'eee8cd', :cornsilk3 => 'cdc8b1', :cornsilk4 => '8b8878', :cyan1 => '00ffff', :cyan2 => '00eeee', :cyan3 => '00cdcd', :cyan4 => '008b8b', :dark_blue => '00008b', :dark_cyan => '008b8b', :dark_goldenrod => 'b8860b', :dark_goldenrod1 => 'ffb90f', :dark_goldenrod2 => 'eead0e', :dark_goldenrod3 => 'cd950c', :dark_goldenrod4 => '8b6508', :dark_gray => 'a9a9a9', :dark_green => '006400', :dark_grey => 'a9a9a9', :dark_khaki => 'bdb76b', :dark_magenta => '8b008b', :dark_olive_green => '556b2f', :dark_olive_green1 => 'caff70', :dark_olive_green2 => 'bcee68', :dark_olive_green3 => 'a2cd5a', :dark_olive_green4 => '6e8b3d', :dark_orange => 'ff8c00', :dark_orange1 => 'ff7f00', :dark_orange2 => 'ee7600', :dark_orange3 => 'cd6600', :dark_orange4 => '8b4500', :dark_orchid => '9932cc', :dark_orchid1 => 'bf3eff', :dark_orchid2 => 'b23aee', :dark_orchid3 => '9a32cd', :dark_orchid4 => '68228b', :dark_red => '8b0000', :dark_salmon => 'e9967a', :dark_sea_green => '8fbc8f', :dark_sea_green1 => 'c1ffc1', :dark_sea_green2 => 'b4eeb4', :dark_sea_green3 => '9bcd9b', :dark_sea_green4 => '698b69', :dark_slate_blue => '483d8b', :dark_slate_gray => '2f4f4f', :dark_slate_gray1 => '97ffff', :dark_slate_gray2 => '8deeee', :dark_slate_gray3 => '79cdcd', :dark_slate_gray4 => '528b8b', :dark_slate_grey => '2f4f4f', :dark_turquoise => '00ced1', :dark_violet => '9400d3', :deep_pink => 'ff1493', :deep_pink1 => 'ff1493', :deep_pink2 => 'ee1289', :deep_pink3 => 'cd1076', :deep_pink4 => '8b0a50', :deep_sky_blue => '00bfff', :deep_sky_blue1 => '00bfff', :deep_sky_blue2 => '00b2ee', :deep_sky_blue3 => '009acd', :deep_sky_blue4 => '00688b', :dim_gray => '696969', :dim_grey => '696969', :dodger_blue => '1e90ff', :dodger_blue1 => '1e90ff', :dodger_blue2 => '1c86ee', :dodger_blue3 => '1874cd', :dodger_blue4 => '104e8b', :firebrick => 'b22222', :firebrick1 => 'ff3030', :firebrick2 => 'ee2c2c', :firebrick3 => 'cd2626', :firebrick4 => '8b1a1a', :floral_white => 'fffaf0', :forest_green => '228b22', :gainsboro => 'dcdcdc', :ghost_white => 'f8f8ff', :gold => 'ffd700', :gold1 => 'ffd700', :gold2 => 'eec900', :gold3 => 'cdad00', :gold4 => '8b7500', :goldenrod => 'daa520', :goldenrod1 => 'ffc125', :goldenrod2 => 'eeb422', :goldenrod3 => 'cd9b1d', :goldenrod4 => '8b6914', :gray => 'bebebe', :gray0 => '000000', :gray1 => '030303', :gray2 => '050505', :gray3 => '080808', :gray4 => '0a0a0a', :gray5 => '0d0d0d', :gray6 => '0f0f0f', :gray7 => '121212', :gray8 => '141414', :gray9 => '171717', :gray10 => '1a1a1a', :gray11 => '1c1c1c', :gray12 => '1f1f1f', :gray13 => '212121', :gray14 => '242424', :gray15 => '262626', :gray16 => '292929', :gray17 => '2b2b2b', :gray18 => '2e2e2e', :gray19 => '303030', :gray20 => '333333', :gray21 => '363636', :gray22 => '383838', :gray23 => '3b3b3b', :gray24 => '3d3d3d', :gray25 => '404040', :gray26 => '424242', :gray27 => '454545', :gray28 => '474747', :gray29 => '4a4a4a', :gray30 => '4d4d4d', :gray31 => '4f4f4f', :gray32 => '525252', :gray33 => '545454', :gray34 => '575757', :gray35 => '595959', :gray36 => '5c5c5c', :gray37 => '5e5e5e', :gray38 => '616161', :gray39 => '636363', :gray40 => '666666', :gray41 => '696969', :gray42 => '6b6b6b', :gray43 => '6e6e6e', :gray44 => '707070', :gray45 => '737373', :gray46 => '757575', :gray47 => '787878', :gray48 => '7a7a7a', :gray49 => '7d7d7d', :gray50 => '7f7f7f', :gray51 => '828282', :gray52 => '858585', :gray53 => '878787', :gray54 => '8a8a8a', :gray55 => '8c8c8c', :gray56 => '8f8f8f', :gray57 => '919191', :gray58 => '949494', :gray59 => '969696', :gray60 => '999999', :gray61 => '9c9c9c', :gray62 => '9e9e9e', :gray63 => 'a1a1a1', :gray64 => 'a3a3a3', :gray65 => 'a6a6a6', :gray66 => 'a8a8a8', :gray67 => 'ababab', :gray68 => 'adadad', :gray69 => 'b0b0b0', :gray70 => 'b3b3b3', :gray71 => 'b5b5b5', :gray72 => 'b8b8b8', :gray73 => 'bababa', :gray74 => 'bdbdbd', :gray75 => 'bfbfbf', :gray76 => 'c2c2c2', :gray77 => 'c4c4c4', :gray78 => 'c7c7c7', :gray79 => 'c9c9c9', :gray80 => 'cccccc', :gray81 => 'cfcfcf', :gray82 => 'd1d1d1', :gray83 => 'd4d4d4', :gray84 => 'd6d6d6', :gray85 => 'd9d9d9', :gray86 => 'dbdbdb', :gray87 => 'dedede', :gray88 => 'e0e0e0', :gray89 => 'e3e3e3', :gray90 => 'e5e5e5', :gray91 => 'e8e8e8', :gray92 => 'ebebeb', :gray93 => 'ededed', :gray94 => 'f0f0f0', :gray95 => 'f2f2f2', :gray96 => 'f5f5f5', :gray97 => 'f7f7f7', :gray98 => 'fafafa', :gray99 => 'fcfcfc', :gray100 => 'ffffff', :green1 => '00ff00', :green2 => '00ee00', :green3 => '00cd00', :green4 => '008b00', :green_yellow => 'adff2f', :grey => 'bebebe', :grey0 => '000000', :grey1 => '030303', :grey2 => '050505', :grey3 => '080808', :grey4 => '0a0a0a', :grey5 => '0d0d0d', :grey6 => '0f0f0f', :grey7 => '121212', :grey8 => '141414', :grey9 => '171717', :grey10 => '1a1a1a', :grey11 => '1c1c1c', :grey12 => '1f1f1f', :grey13 => '212121', :grey14 => '242424', :grey15 => '262626', :grey16 => '292929', :grey17 => '2b2b2b', :grey18 => '2e2e2e', :grey19 => '303030', :grey20 => '333333', :grey21 => '363636', :grey22 => '383838', :grey23 => '3b3b3b', :grey24 => '3d3d3d', :grey25 => '404040', :grey26 => '424242', :grey27 => '454545', :grey28 => '474747', :grey29 => '4a4a4a', :grey30 => '4d4d4d', :grey31 => '4f4f4f', :grey32 => '525252', :grey33 => '545454', :grey34 => '575757', :grey35 => '595959', :grey36 => '5c5c5c', :grey37 => '5e5e5e', :grey38 => '616161', :grey39 => '636363', :grey40 => '666666', :grey41 => '696969', :grey42 => '6b6b6b', :grey43 => '6e6e6e', :grey44 => '707070', :grey45 => '737373', :grey46 => '757575', :grey47 => '787878', :grey48 => '7a7a7a', :grey49 => '7d7d7d', :grey50 => '7f7f7f', :grey51 => '828282', :grey52 => '858585', :grey53 => '878787', :grey54 => '8a8a8a', :grey55 => '8c8c8c', :grey56 => '8f8f8f', :grey57 => '919191', :grey58 => '949494', :grey59 => '969696', :grey60 => '999999', :grey61 => '9c9c9c', :grey62 => '9e9e9e', :grey63 => 'a1a1a1', :grey64 => 'a3a3a3', :grey65 => 'a6a6a6', :grey66 => 'a8a8a8', :grey67 => 'ababab', :grey68 => 'adadad', :grey69 => 'b0b0b0', :grey70 => 'b3b3b3', :grey71 => 'b5b5b5', :grey72 => 'b8b8b8', :grey73 => 'bababa', :grey74 => 'bdbdbd', :grey75 => 'bfbfbf', :grey76 => 'c2c2c2', :grey77 => 'c4c4c4', :grey78 => 'c7c7c7', :grey79 => 'c9c9c9', :grey80 => 'cccccc', :grey81 => 'cfcfcf', :grey82 => 'd1d1d1', :grey83 => 'd4d4d4', :grey84 => 'd6d6d6', :grey85 => 'd9d9d9', :grey86 => 'dbdbdb', :grey87 => 'dedede', :grey88 => 'e0e0e0', :grey89 => 'e3e3e3', :grey90 => 'e5e5e5', :grey91 => 'e8e8e8', :grey92 => 'ebebeb', :grey93 => 'ededed', :grey94 => 'f0f0f0', :grey95 => 'f2f2f2', :grey96 => 'f5f5f5', :grey97 => 'f7f7f7', :grey98 => 'fafafa', :grey99 => 'fcfcfc', :grey100 => 'ffffff', :honeydew => 'f0fff0', :honeydew1 => 'f0fff0', :honeydew2 => 'e0eee0', :honeydew3 => 'c1cdc1', :honeydew4 => '838b83', :hot_pink => 'ff69b4', :hot_pink1 => 'ff6eb4', :hot_pink2 => 'ee6aa7', :hot_pink3 => 'cd6090', :hot_pink4 => '8b3a62', :indian_red => 'cd5c5c', :indian_red1 => 'ff6a6a', :indian_red2 => 'ee6363', :indian_red3 => 'cd5555', :indian_red4 => '8b3a3a', :ivory => 'fffff0', :ivory1 => 'fffff0', :ivory2 => 'eeeee0', :ivory3 => 'cdcdc1', :ivory4 => '8b8b83', :khaki => 'f0e68c', :khaki1 => 'fff68f', :khaki2 => 'eee685', :khaki3 => 'cdc673', :khaki4 => '8b864e', :lavender => 'e6e6fa', :lavender_blush => 'fff0f5', :lavender_blush1 => 'fff0f5', :lavender_blush2 => 'eee0e5', :lavender_blush3 => 'cdc1c5', :lavender_blush4 => '8b8386', :lawn_green => '7cfc00', :lemon_chiffon => 'fffacd', :lemon_chiffon1 => 'fffacd', :lemon_chiffon2 => 'eee9bf', :lemon_chiffon3 => 'cdc9a5', :lemon_chiffon4 => '8b8970', :light_blue => 'add8e6', :light_blue1 => 'bfefff', :light_blue2 => 'b2dfee', :light_blue3 => '9ac0cd', :light_blue4 => '68838b', :light_coral => 'f08080', :light_cyan => 'e0ffff', :light_cyan1 => 'e0ffff', :light_cyan2 => 'd1eeee', :light_cyan3 => 'b4cdcd', :light_cyan4 => '7a8b8b', :light_goldenrod => 'eedd82', :light_goldenrod1 => 'ffec8b', :light_goldenrod2 => 'eedc82', :light_goldenrod3 => 'cdbe70', :light_goldenrod4 => '8b814c', :light_goldenrod_yellow => 'fafad2', :light_gray => 'd3d3d3', :light_green => '90ee90', :light_grey => 'd3d3d3', :light_pink => 'ffb6c1', :light_pink1 => 'ffaeb9', :light_pink2 => 'eea2ad', :light_pink3 => 'cd8c95', :light_pink4 => '8b5f65', :light_salmon => 'ffa07a', :light_salmon1 => 'ffa07a', :light_salmon2 => 'ee9572', :light_salmon3 => 'cd8162', :light_salmon4 => '8b5742', :light_sea_green => '20b2aa', :light_sky_blue => '87cefa', :light_sky_blue1 => 'b0e2ff', :light_sky_blue2 => 'a4d3ee', :light_sky_blue3 => '8db6cd', :light_sky_blue4 => '607b8b', :light_slate_blue => '8470ff', :light_slate_gray => '778899', :light_slate_grey => '778899', :light_steel_blue => 'b0c4de', :light_steel_blue1 => 'cae1ff', :light_steel_blue2 => 'bcd2ee', :light_steel_blue3 => 'a2b5cd', :light_steel_blue4 => '6e7b8b', :light_yellow => 'ffffe0', :light_yellow1 => 'ffffe0', :light_yellow2 => 'eeeed1', :light_yellow3 => 'cdcdb4', :light_yellow4 => '8b8b7a', :lime_green => '32cd32', :linen => 'faf0e6', :magenta1 => 'ff00ff', :magenta2 => 'ee00ee', :magenta3 => 'cd00cd', :magenta4 => '8b008b', :maroon => 'b03060', :maroon1 => 'ff34b3', :maroon2 => 'ee30a7', :maroon3 => 'cd2990', :maroon4 => '8b1c62', :medium_aquamarine => '66cdaa', :medium_blue => '0000cd', :medium_orchid => 'ba55d3', :medium_orchid1 => 'e066ff', :medium_orchid2 => 'd15fee', :medium_orchid3 => 'b452cd', :medium_orchid4 => '7a378b', :medium_purple => '9370db', :medium_purple1 => 'ab82ff', :medium_purple2 => '9f79ee', :medium_purple3 => '8968cd', :medium_purple4 => '5d478b', :medium_sea_green => '3cb371', :medium_slate_blue => '7b68ee', :medium_spring_green => '00fa9a', :medium_turquoise => '48d1cc', :medium_violet_red => 'c71585', :midnight_blue => '191970', :mint_cream => 'f5fffa', :misty_rose => 'ffe4e1', :misty_rose1 => 'ffe4e1', :misty_rose2 => 'eed5d2', :misty_rose3 => 'cdb7b5', :misty_rose4 => '8b7d7b', :moccasin => 'ffe4b5', :navajo_white => 'ffdead', :navajo_white1 => 'ffdead', :navajo_white2 => 'eecfa1', :navajo_white3 => 'cdb38b', :navajo_white4 => '8b795e', :navy => '000080', :navy_blue => '000080', :old_lace => 'fdf5e6', :olive_drab => '6b8e23', :olive_drab1 => 'c0ff3e', :olive_drab2 => 'b3ee3a', :olive_drab3 => '9acd32', :olive_drab4 => '698b22', :orange => 'ffa500', :orange1 => 'ffa500', :orange2 => 'ee9a00', :orange3 => 'cd8500', :orange4 => '8b5a00', :orange_red => 'ff4500', :orange_red1 => 'ff4500', :orange_red2 => 'ee4000', :orange_red3 => 'cd3700', :orange_red4 => '8b2500', :orchid => 'da70d6', :orchid1 => 'ff83fa', :orchid2 => 'ee7ae9', :orchid3 => 'cd69c9', :orchid4 => '8b4789', :pale_goldenrod => 'eee8aa', :pale_green => '98fb98', :pale_green1 => '9aff9a', :pale_green2 => '90ee90', :pale_green3 => '7ccd7c', :pale_green4 => '548b54', :pale_turquoise => 'afeeee', :pale_turquoise1 => 'bbffff', :pale_turquoise2 => 'aeeeee', :pale_turquoise3 => '96cdcd', :pale_turquoise4 => '668b8b', :pale_violet_red => 'db7093', :pale_violet_red1 => 'ff82ab', :pale_violet_red2 => 'ee799f', :pale_violet_red3 => 'cd6889', :pale_violet_red4 => '8b475d', :papaya_whip => 'ffefd5', :peach_puff => 'ffdab9', :peach_puff1 => 'ffdab9', :peach_puff2 => 'eecbad', :peach_puff3 => 'cdaf95', :peach_puff4 => '8b7765', :peru => 'cd853f', :pink => 'ffc0cb', :pink1 => 'ffb5c5', :pink2 => 'eea9b8', :pink3 => 'cd919e', :pink4 => '8b636c', :plum => 'dda0dd', :plum1 => 'ffbbff', :plum2 => 'eeaeee', :plum3 => 'cd96cd', :plum4 => '8b668b', :powder_blue => 'b0e0e6', :purple => 'a020f0', :purple1 => '9b30ff', :purple2 => '912cee', :purple3 => '7d26cd', :purple4 => '551a8b', :red1 => 'ff0000', :red2 => 'ee0000', :red3 => 'cd0000', :red4 => '8b0000', :rosy_brown => 'bc8f8f', :rosy_brown1 => 'ffc1c1', :rosy_brown2 => 'eeb4b4', :rosy_brown3 => 'cd9b9b', :rosy_brown4 => '8b6969', :royal_blue => '4169e1', :royal_blue1 => '4876ff', :royal_blue2 => '436eee', :royal_blue3 => '3a5fcd', :royal_blue4 => '27408b', :saddle_brown => '8b4513', :salmon => 'fa8072', :salmon1 => 'ff8c69', :salmon2 => 'ee8262', :salmon3 => 'cd7054', :salmon4 => '8b4c39', :sandy_brown => 'f4a460', :sea_green => '2e8b57', :sea_green1 => '54ff9f', :sea_green2 => '4eee94', :sea_green3 => '43cd80', :sea_green4 => '2e8b57', :seashell => 'fff5ee', :seashell1 => 'fff5ee', :seashell2 => 'eee5de', :seashell3 => 'cdc5bf', :seashell4 => '8b8682', :sienna => 'a0522d', :sienna1 => 'ff8247', :sienna2 => 'ee7942', :sienna3 => 'cd6839', :sienna4 => '8b4726', :sky_blue => '87ceeb', :sky_blue1 => '87ceff', :sky_blue2 => '7ec0ee', :sky_blue3 => '6ca6cd', :sky_blue4 => '4a708b', :slate_blue => '6a5acd', :slate_blue1 => '836fff', :slate_blue2 => '7a67ee', :slate_blue3 => '6959cd', :slate_blue4 => '473c8b', :slate_gray => '708090', :slate_gray1 => 'c6e2ff', :slate_gray2 => 'b9d3ee', :slate_gray3 => '9fb6cd', :slate_gray4 => '6c7b8b', :slate_grey => '708090', :snow => 'fffafa', :snow1 => 'fffafa', :snow2 => 'eee9e9', :snow3 => 'cdc9c9', :snow4 => '8b8989', :spring_green => '00ff7f', :spring_green1 => '00ff7f', :spring_green2 => '00ee76', :spring_green3 => '00cd66', :spring_green4 => '008b45', :steel_blue => '4682b4', :steel_blue1 => '63b8ff', :steel_blue2 => '5cacee', :steel_blue3 => '4f94cd', :steel_blue4 => '36648b', :tan => 'd2b48c', :tan1 => 'ffa54f', :tan2 => 'ee9a49', :tan3 => 'cd853f', :tan4 => '8b5a2b', :thistle => 'd8bfd8', :thistle1 => 'ffe1ff', :thistle2 => 'eed2ee', :thistle3 => 'cdb5cd', :thistle4 => '8b7b8b', :tomato => 'ff6347', :tomato1 => 'ff6347', :tomato2 => 'ee5c42', :tomato3 => 'cd4f39', :tomato4 => '8b3626', :turquoise => '40e0d0', :turquoise1 => '00f5ff', :turquoise2 => '00e5ee', :turquoise3 => '00c5cd', :turquoise4 => '00868b', :violet => 'ee82ee', :violet_red => 'd02090', :violet_red1 => 'ff3e96', :violet_red2 => 'ee3a8c', :violet_red3 => 'cd3278', :violet_red4 => '8b2252', :wheat => 'f5deb3', :wheat1 => 'ffe7ba', :wheat2 => 'eed8ae', :wheat3 => 'cdba96', :wheat4 => '8b7e66', :white_smoke => 'f5f5f5', :yellow1 => 'ffff00', :yellow2 => 'eeee00', :yellow3 => 'cdcd00', :yellow4 => '8b8b00', :yellow_green => '9acd32' }
Class Method Summary collapse
-
.bar(*args, &block) ⇒ Object
Convenience constructor for GChart::Bar.
-
.encode(encoding, n, max) ⇒ Object
Encode
n
as a string. -
.expand_color(color) ⇒ Object
Expands a 3-character rgb
color
into a 6-character rrggbb color. -
.line(*args, &block) ⇒ Object
Convenience constructor for GChart::Line.
-
.map(*args, &block) ⇒ Object
Convenience constructor for GChart::Map.
-
.meter(*args, &block) ⇒ Object
Convenience constructor for GChart::Meter.
-
.pie(*args, &block) ⇒ Object
Convenience constructor for GChart::Pie.
-
.pie3d(*args, &block) ⇒ Object
Convenience constructor for GChart::Pie3D.
-
.scatter(*args, &block) ⇒ Object
Convenience constructor for GChart::Scatter.
-
.sparkline(*args, &block) ⇒ Object
Convenience constructor for GChart::Sparkline.
-
.valid_color?(color) ⇒ Boolean
Returns
true
if thecolor
is valid, meaning it is either (a) a 3-character rgb representation of a color, (b) a 6-character rrggbb representation of a color, © an 8-character rrggbbtt representation of a color with transparency information or (d) a symbol representation of a color from theCOLORS
Hash
. -
.venn(*args, &block) ⇒ Object
Convenience constructor for GChart::Venn.
-
.xyline(*args, &block) ⇒ Object
Convenience constructor for GChart::XYLine.
Class Method Details
.bar(*args, &block) ⇒ Object
Convenience constructor for GChart::Bar.
29 |
# File 'lib/gchart.rb', line 29 def (*args, &block); Bar.new(*args, &block) end |
.encode(encoding, n, max) ⇒ Object
Encode n
as a string. n
is normalized based on max
. encoding
can currently only be :extended.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gchart.rb', line 54 def encode(encoding, n, max) case encoding when :simple return "_" if n.nil? SIMPLE_CHARS[((n/max.to_f) * (SIMPLE_CHARS.size - 1)).round] when :text return "-1" if n.nil? ((((n/max.to_f) * 1000.0).round)/10.0).to_s when :extended return "__" if n.nil? EXTENDED_PAIRS[max.zero? ? 0 : ((n/max.to_f) * (EXTENDED_PAIRS.size - 1)).round] else raise ArgumentError, "unsupported encoding: #{encoding.inspect}" end end |
.expand_color(color) ⇒ Object
Expands a 3-character rgb color
into a 6-character rrggbb color. Also expands a color
symbol from the COLORS
Hash
into its corresponding 6-character rrggbb color. Any other color
is returned unmodified.
8 9 10 11 12 13 14 |
# File 'lib/gchart/colors.rb', line 8 def (color) color.is_a?(String) && color.size == 3 \ ? color.split('').collect{ |c| c + c }.join('') \ : COLORS[color] \ ? COLORS[color] \ : color end |
.line(*args, &block) ⇒ Object
Convenience constructor for GChart::Line.
23 |
# File 'lib/gchart.rb', line 23 def line(*args, &block); Line.new(*args, &block) end |
.map(*args, &block) ⇒ Object
Convenience constructor for GChart::Map.
32 |
# File 'lib/gchart.rb', line 32 def map(*args, &block); Map.new(*args, &block) end |
.meter(*args, &block) ⇒ Object
Convenience constructor for GChart::Meter.
35 |
# File 'lib/gchart.rb', line 35 def meter(*args, &block); Meter.new(*args, &block) end |
.pie(*args, &block) ⇒ Object
Convenience constructor for GChart::Pie.
38 |
# File 'lib/gchart.rb', line 38 def pie(*args, &block); Pie.new(*args, &block) end |
.pie3d(*args, &block) ⇒ Object
Convenience constructor for GChart::Pie3D.
41 |
# File 'lib/gchart.rb', line 41 def pie3d(*args, &block); Pie3D.new(*args, &block) end |
.scatter(*args, &block) ⇒ Object
Convenience constructor for GChart::Scatter.
44 |
# File 'lib/gchart.rb', line 44 def scatter(*args, &block); Scatter.new(*args, &block) end |
.sparkline(*args, &block) ⇒ Object
Convenience constructor for GChart::Sparkline.
47 |
# File 'lib/gchart.rb', line 47 def sparkline(*args, &block); Sparkline.new(*args, &block) end |
.valid_color?(color) ⇒ Boolean
Returns true
if the color
is valid, meaning it is either (a) a 3-character rgb representation of a color, (b) a 6-character rrggbb representation of a color, © an 8-character rrggbbtt representation of a color with transparency information or (d) a symbol representation of a color from the COLORS
Hash
. Returns false
otherwise.
22 23 24 25 26 |
# File 'lib/gchart/colors.rb', line 22 def valid_color?(color) !!(COLORS[color] or (color.is_a?(String) and color =~ /^[0-9a-fA-F]+$/ and color.size.to_s =~ /^(3|6|8)$/)) end |