0.0
No release in over a year
A lightweight and straightforward Ruby wrapper for Plotly.js, enabling developers to create interactive, high-quality data visualizations effortlessly.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Plotlyjs Ruby

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

Installation

  1. Add this line to your application's Gemfile:

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

    bin/importmap pin plotly.js-dist
  3. 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.