Skip to main content

Client libraries

We maintain client libraries for your convenience:

You don't necessarily need a library to use QuickChart. To use QuickChart without a library, simply build a QuickChart URL as described in API parameters.

Javascript/Node​

Run npm install quickchart-js to install the QuickChart dependency. Use it like so:

const QuickChart = require('quickchart-js');

const myChart = new QuickChart();
myChart
.setConfig({
type: 'bar',
data: {
labels: ['Hello world', 'Foo bar'],
datasets: [{ label: 'Foo', data: [1, 2] }],
},
})
.setWidth(800)
.setHeight(400)
.setBackgroundColor('transparent');

// Print the chart URL
console.log(myChart.getUrl());

Get more details on the quickchart-js project page.

Python​

Run pip install quickchart.io to install the QuickChart dependency. Use it like so:

from quickchart import QuickChart

qc = QuickChart()
qc.width = 500
qc.height = 300
qc.device_pixel_ratio = 2.0
qc.config = {
"type": "bar",
"data": {
"labels": ["Hello world", "Test"],
"datasets": [{
"label": "Foo",
"data": [1, 2]
}]
}
}

# Print the chart URL
print(qc.get_url())

Read the full Python tutorial or see details on the quickchart-python project page.

Ruby​

Run gem install quickchart to install the QuickChart Ruby gem:

require 'quickchart'

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

# Print the chart URL
puts qc.get_url

Learn more about chart generation in Ruby at the quickchart-ruby repository.

PHP​

Run composer require ianw/quickchart to install the QuickChart PHP library:

require 'quickchart'

$qc = new QuickChart(array(
'width' => 600,
'height' => 300,
));

$qc->setConfig('{
type: "bar",
data: {
labels: ["Hello world", "Test"],
datasets: [{
label: "Foo",
data: [1, 2]
}]
}
}');

// Print the chart URL
echo $qc->getUrl();

See the PHP QuickChart client at the quickchart-php repository.

C#​

Add the QuickChart package from NuGet. Then use the Chart object provided by the QuickChart namespace:

namespace QuickChartExample
{
public class SimpleExample
{
static void Main(string[] args) {
Chart qc = new Chart();

qc.Width = 500;
qc.Height = 300;
qc.Config = @"{
type: 'bar',
data: {
labels: ['Hello world', 'Test'],
datasets: [{
label: 'Foo',
data: [1, 2]
}]
}
}"

Console.WriteLine(qc.GetUrl());
}
}
}

The C# QuickChart client is available on NuGet and at the quickchart-csharp repository.

Java​

Add the QuickChart package from Maven Central. If you use Maven or Gradle, you can add it to your config (view details).

This library provides an io.quickchart package that contains a QuickChart class:

import io.quickchart.QuickChart;

public class PrintUrlExample {
public static void main(String[] args) {
QuickChart chart = new QuickChart();
chart.setWidth(500);
chart.setHeight(300);
chart.setConfig("{"
+ " type: 'bar',"
+ " data: {"
+ " labels: ['Q1', 'Q2', 'Q3', 'Q4'],"
+ " datasets: [{"
+ " label: 'Users',"
+ " data: [50, 60, 70, 180]"
+ " }]"
+ " }"
+ "}"
);

System.out.println(chart.getUrl());
}
}

The Java library is open-source and accessible on Github.

Go​

A third-party QuickChart Go library is available on Github. It can be used like so:

qc := quickchartgo.New()

qc.Config = chartConfig
qc.Config := `{
type: 'bar',
data: {
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
datasets: [{
label: 'Users',
data: [50, 60, 70, 180]
}]
}
}`

qc.Width = 500;
qc.Height = 300;
qc.Version = "2.9.4";

fmt.Println(qc.GetUrl());

Other programming languages​

QuickChart is not limited to the libraries listed above. You can create a QuickChart URL in any language by building a URL string. Because building a URL string is a matter of string concatenation, this can be done in any language.

See the API Parameters documentation to learn how to build a URL that renders a chart image.

If you need help, please reach out and we will help you implement in your preferred programming language.