Socket
Book a DemoInstallSign in
Socket

pill_chart

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pill_chart

1.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

one simple pills PillChart

A simple rubygem for create little svg pill charts.

Like this :

state_pills

Or without progression state :

simple_pills

It can be used alone, or in Rails (tested in 4.0.4) as a view helper.

Use it in Rails in 3 steps

  • Add pill_chart to your Gemfile (by adding this line: gem 'pill_chart', '~> 1.0.2')
  • Run bundle install into your terminal, on your rails project directory
  • Use the following methods directly into your views ! (Don't forget to mark it as html_safe)

Helpers overview

# It will draw a simple pill, filled to `value`.
draw_pill_chart(height: 10, width: 60, value: 33, max: 100, colors: {})
# It will draw a stated pill (the color changes with the value), filled to `value`.
draw_state_pill_chart(height: 10, width: 60, value: 33, max: 100, colors: {})

Some examples

Draw a simple pill at 33% (simple pills ) in a Rails view:

<%= draw_pill_chart(width: 60, value: 33).html_safe %>

Draw a state pill at 70% (state pills ) in a Rails view:

<%= draw_state_pill_chart(width: 60, value: 70).html_safe %>

Available parameters

The max parameter represents the maximum value. For example, a value of 60 and a max of 120 will fill the half of the pill.

You can pass custom colors in a hash to the colors parameter. The color's default values are :

colors = {
    "background" => "#eee", # the background colour
    "foreground" => "#999", # the pill color when it's a simple pill (not a state pill)
    "low" => "#AD6D6D", # the pill color under 20% when it's a state pill
    "medium" => "#C59663", # the pill color between 20 and 40% when it's a state pill
    "high" => "#ADC563", # the pill color between 40 and 70% when it's a state pill
    "full" => "#92C447" # the pill color between 70 and 100% when it's a state pill
}

Use it without Rails

# Create a new SimplePillChart object, with theses parameters
elt = PillChart::SimplePillChart.new(height, width, value, max, :simple, colors)

# Run the pill method to generate the svg content
elt.pill

FAQs

Package last updated on 24 Mar 2014

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.