Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


QuickChart Gem

A Ruby client for the chart image API.


Use the lib/quickchart.rb library in this project, or install as a Ruby gem:

gem install quickchart


This library provides a QuickChart class. Import and instantiate it. Then set properties on it and specify a Chart.js config:

require 'quickchart'

qc =
    type: "bar",
    data: {
      labels: ["Hello world", "Test"],
      datasets: [{
        label: "Foo",
        data: [1, 2]
  width: 600,
  height: 300,
  device_pixel_ratio: 2.0,

Use get_url() on your quickchart object to get the encoded URL that renders your chart:

puts qc.get_url

If you have a long or complicated chart, use get_short_url() to get a fixed-length URL using the web service (note that these URLs only persist for a short time unless you have a subscription):

puts qc.get_short_url

The URLs will render an image of a chart:

Creating the chart object

The QuickChart class constructor accepts the following parameters. config is the only required parameter, the rest are optional:

config: hash or string (required)

The actual Chart.js chart configuration.

width: int

Width of the chart image in pixels. Defaults to 500

height: int

Height of the chart image in pixels. Defaults to 300

format: string

Format of the chart. Defaults to png. svg is also valid.

background_color: string

The background color of the chart. Any valid HTML color works. Defaults to #ffffff (white). Also takes rgb, rgba, and hsl values.

device_pixel_ratio: float

The device pixel ratio of the chart. This will multiply the number of pixels by the value. This is usually used for retina displays. Defaults to 1.0.

key: string

QuickChart API key (not required)

version: string

Sets the Chart.js version to use (e.g. 2.9.4 or 3.8.0). Valid options are described in the documentation.

Getting URLs

There are two ways to get a URL for your chart object.

get_url: string

Returns a URL that will display the chart image when loaded.

get_short_url: string

Uses the web service to create a fixed-length chart URL that displays the chart image. Returns a URL such as

Note that short URLs expire after a few days for users of the free service. You can subscribe to keep them around longer.

Other outputs

to_blob: binary string

Returns a binary string representing the chart image

to_file(path: string)

Write the image to a file

For example:


More examples

Checkout the examples directory to see other usage.


Ruby client for chart API







No releases published


No packages published