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

third_prestige_rails_admin_charts

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

third_prestige_rails_admin_charts

  • 0.0.7
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= RailsAdminCharts

Installation

In your Gemfile, add the following dependency:

gem 'rails_admin_charts'

Run:

$ bundle install

This will include the lazy_high_charts gem and add the assets to the pipeline.

In your RailsAdmin initializer (app/config/initializers/rails_admin.rb), enable the action by adding:

config.actions do
  charts
end

For any model where you wish to display a chart (defaults to a cumulative total showing the last 100 days), add the following just under the class declaration:

include RailsAdminCharts

This adds the methods delta_records_since and total_records_since to your model, alongside graph_data which utilises them. The data displayed in the chart can be altered by overriding the class method graph_data in your model, for example in the case of a User model using single table inheritance:

  def self.graph_data since=30.days.ago
    [
      {
          name: 'Admin Users',
          pointInterval: point_interval = 1.day * 1000,
          pointStart: start_point = since.to_i * 1000,
          data: self.where(type: 'Admin').delta_records_since(since)
      },
      {
          name: 'Standard Users',
          pointInterval: point_interval,
          pointStart: start_point,
          data: self.where(type: nil).delta_records_since(since)
      }
    ]
  end

This project uses MIT-LICENSE.

FAQs

Package last updated on 13 Jan 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

  • 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