Sha256: 0bb560c0263f35f33dffec5cfdf64b4618629e34a3968134abe21d807681a431

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

require './lib/plotrb.rb'

ump_data = pdata.name('unemp') do
	url('unemployment.tsv')
	format(:tsv) { parse :rate => :number }
end
cty_data = pdata.name('counties') do
	url('us-10m.json')
	format(:topojson) { feature 'counties' }
	transform [
		geopath_transform.projection(:albersUsa),
		zip_transform.with('unemp').match('id').against('id').as('value').default(nil),
		filter_transform.test('d.path!=null && d.value!=null')
	]
end

cs = quantize_scale.name('color').from([0, 0.15]).to(
	[
		"#f7fbff",
    "#deebf7",
    "#c6dbef",
    "#9ecae1",
    "#6baed6",
    "#4292c6",
    "#2171b5",
    "#08519c",
    "#08306b"
  ])

mark = path_mark.from(cty_data) do
	enter do
		path { from 'path' }
	end
	update do
		fill { scale(cs).from('value.data.rate') }
	end
	hover do
		fill 'red'
	end
end

vis = visualization.width(960).height(500) do
	data ump_data, cty_data
	scales cs
	marks mark
end

puts vis.generate_spec(:pretty)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plotrb-0.0.1 examples/choropleth.rb