Socket
Book a DemoInstallSign in
Socket

plotlyjs-ruby

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plotlyjs-ruby

bundlerRubyGems.org
Version
0.4.0
Version published
Maintainers
1
Created
Source

Plotlyjs Ruby

A lightweight and straightforward Ruby wrapper for Plotly.js, enabling developers to create interactive, high-quality data visualizations effortlessly.

Installation

  • Add this line to your application's Gemfile:

    gem "plotlyjs-ruby"
    
  • Run the following command to pin plotly.js-dist in the import map:

    bin/importmap pin plotly.js-dist
    
  • Add the following code to app/javascript/application.js:

    import Plotly from "plotly.js-dist"
    
    window.Plotly = Plotly
    

Usage

Basic Usage

To create a basic plot, use the following code in your view:

<%= Plotlyjs.new_plot(
  "charts",
  data: [{ x: [1, 2, 3, 4, 5] }, { y: [1, 2, 4, 8, 16]}],
  layout: { width: 600, height: 250, margin: { t: 0 } }
) %>

Global Configuration

To set options for all of your charts, create an initializer file config/initializers/plotlyjs-ruby.rb with:

Plotlyjs.configure do |config|
  config.options = {
    responsive: true,
    displayModeBar: false
  }
end

For more details, follow the Plotly Getting Started Guide.

FAQs

Package last updated on 16 Jan 2025

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