Sha256: d88471f04cdbae0331a6014e97f51352cd64d5a0691c5fa18df67bc97501eed9
Contents?: true
Size: 827 Bytes
Versions: 1
Compression:
Stored size: 827 Bytes
Contents
require File.join(File.dirname(__FILE__), 'usa_counties_svg') # @author salemine <info@salemine.com> class USAmap include UsaCountiesSvg # @param [Hash] stats_h stats to plot by county FIPS value eg stats_h ['35001'] = 3 # @param [Hash] colors_h colors to plot for numeric ranges eg colors_h [0..5] = '#CD5C5C' def initialize(stats_h = {}, colors_h = {}) @stats_h, @colors_h = stats_h, colors_h end # == Returns: # A colorized SVG (Scalable Vector Graphics) map of the USA def to_s css = '' @stats_h.each do |fips, val| colr = @colors_h.select { |range, hex| range.member?(val) }.values.first css << ".c#{fips} {fill:#{colr}}\n" end svg = UsaCountiesSvg.svg css.empty? ? svg : svg.gsub!(/\/\*CSS insertion point\*\//, "/*CSS insertion point*/\n#{css}") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
usamap-0.0.2 | lib/usamap.rb |