Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3_maps

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3_maps

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

D3Maps Ruby Gem

D3Maps Ruby Gem is a gem that simplifies the process of creating maps of the United States and assigning data values to each location.

Installation

Add this line to your application's Gemfile:

gem 'd3_maps'

And then execute:

$ bundle

Or install it yourself as:

$ gem install d3_maps

In app/assets/javascripts/application.js, include

//= require d3_maps

Usage

Create the database needed to store the information for your project. The database consist of a States table with information on number, code, and name. Number must be included. Code and name are optional values to display.

rails generate model States number:integer code:string name:string
rake db:migrate

In the seeds.rb file

require 'csv'
tsv_text = File.read(Rails.root.join('assets', 'tsv', 'us_states', 'us-state-names.tsv'))
tsv = CSV.parse(tsv_text, :headers => true, :col_sep => "\t")
tsv.each do |row|
  s = State.new
  s.number = row['id']
  s.code = row['code']
  s.name = row['name']
  s.save
end

puts "There are now #{State.count} in the states table"

Seed your database.

rake db:seed

Or reset your database

rake db:reset

Host the data as a json file as part of your application

rails generate controller States index

Replace the States/states_controller.rb and states/index.html.erb files with the same files in d3maps.

The map for United states is located in views/welcome/index.html.erb The map for the world is located in views/welcome/about.html.erb

To generate the world map, repeat the process and seed your database with data located at at app/tsv/world/world-countries-names.tsv

FAQs

Package last updated on 10 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc