Socket
Book a DemoInstallSign in
Socket

swagchart

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagchart

1.2.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

Swagchart

Gem Version Installs

Get your swag on with this incredibly easy to use wrapper around Googles Chart API.

In case you haven't noticed, Swagchart is just an acronym for S.imple W.rapper A.round G.oogle Chart.

Swagchart is highly inspired by Chartkick but making use of Googles new ChartWrapper class which allows a more flexible and direct interaction. (the code is still in there and you can enable it if you want to .. look at lib/swagchart/helper.rb .. but unfortunately ChartWrapper doesn't allow many charts so I switched back to the classic approach by default).

You can still create beautiful Javascript charts with one line of Ruby. In fact now you can pretty much use all the fancy chart types from Googles Chart API.

Works with Rails, Sinatra and most browsers (including IE 6).

Usage examples

chart :line_chart, [{y: 23, x: 42}, {y: 666, x: 999}]
chart :line_chart, [[23, 42], [666, 999]], columns: ['x', 'y']
chart :line_chart, [[23, 42], [666, 999]], columns: ['x', 'y'], style: 'width:100%;'
chart :line_chart, [[1,2,4],[2,3,8],[3,4,16],[4,5,32]]
chart :line_chart, User.group_by_day(:created_at).count
chart :bar_chart, [['x', 'y'],[23, 42], [666, 999]]
chart :pie_chart, Goal.group(:name).count
chart :geo_map, [{'Country'=>'Germany', 'Population'=>8600000}, {'Country'=>'France', 'Population'=>6500000}]
chart :line_chart,
      [[0, nil, nil, 5], [1, 'foo', 'Foobar', 2], [2, nil, nil, 6], [3, 'bar', 'Barfoo', 3], [4, nil, nil, 8]],
      columns: ['y', {type: 'string', role: 'annotation'}, {type: 'string', role: 'annotationText'}, 'foo'],
      options: {annotations: {style: 'line'}}
chart :pie_chart, '/api/pie-chart-data'

Installation

Add this line to your application's Gemfile:

gem "swagchart"

And add the javascript files to your views. These files must be included before the helper methods.

<script type="text/javascript" src="//www.google.com/jsapi"></script>

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

  • Report bugs
  • Fix bugs and submit pull requests
  • Write, clarify, or fix documentation
  • Suggest or add new features

FAQs

Package last updated on 26 May 2016

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.