
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Create Google Charts in your views using ruby, with no Javascript required. This library will serialize your data andautomatically load any required charts packages, and render your charts for you. Requires jQuery.
class ActivitiesController < ActionController::Base
def graphs
@activities = {
'Work' => 11,
'Eat' => 2,
'Commute' => 2,
'Watch TV' => 2,
'Sleep' => 7
}
end
end
# views/activities/graphs.html.erb
<%= google_chart :pie, ['Task', 'Hours per Day'], @activities.map { |k,v| [k, v] }, { title: 'My Daily Activities' } %>
Add this line to your application's Gemfile:
gem 'simple-gcharts'
And then execute:
$ bundle
Or install it yourself as:
$ gem install simple-gcharts
Add script to application.js
(or appropriate page)
//= require jquery
//= require simple-gcharts
See the Google Charts Documentation for chart type descriptions and options.
def google_chart type, headers, data, opts={}, chart_id="chart-#{SecureRandom.hex(10)}", parent_tag=:div
Argument | Description |
---|---|
type | The type of chart (e.g. :line , see below) |
headers | The column data. Can be column name or object |
data | A 2-D array of data rows. headers and data combined are passed to arrayToDataTable() |
opts | Options passed to chart.draw() |
chart_id | The HTML id attribute to use for the chart |
parent_tag | The tag used to wrap the child tags |
Ruby can't make Javascript date objects, but fortunately Google Charts supports an alternate syntax for date and time datatypes. You can use chart_date_format
to convert DateTime objects to the proper format.
def chart_date_format(datetime, time=false)
if time
datetime.strftime "Date(%Y, %m, %d, %H, %M, %S)"
else
datetime.strftime "Date(%Y, %m, %d)"
end
end
Types |
---|
:annotation |
:area |
:bubble |
:bar |
:calendar |
:candlestick |
:column |
:combo |
:gantt |
:gauge |
:geochart |
:histogram |
:line |
:map |
:orgchart |
:pie |
:snakey |
:scatter |
:stepped |
:table |
:timeline |
:treemap |
:word |
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that simple-gcharts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.