SDKs overview

QuickChart offers a range of Software Development Kits (SDKs) and libraries designed to facilitate the programmatic generation of chart images, QR codes, and other visualizations. These tools abstract the underlying HTTP requests and JSON payload construction, allowing developers to integrate QuickChart functionality directly into their applications using familiar programming languages. The SDKs are particularly useful for server-side chart rendering, embedding charts in emails, and automating report generation without requiring client-side dependencies like a web browser to render the chart QuickChart documentation portal.

The core functionality provided by QuickChart's SDKs revolves around converting Chart.js configurations into static image URLs or direct image data. This approach enables developers to leverage the extensive customization options of Chart.js while offloading the rendering process to QuickChart's API. This is distinct from client-side charting libraries such as Google Charts or Chart.js itself, which typically render charts directly in a web browser using JavaScript.

The primary use cases for these SDKs include:

  • Automated Report Generation: Creating static chart images for inclusion in PDF reports or other document formats.
  • Email Embeds: Generating chart images that can be directly embedded into HTML emails, where JavaScript-based charts are often not supported.
  • Server-side Rendering: Producing chart images in environments where a client-side browser is unavailable or undesirable, such as background jobs or native desktop applications.
  • QR Code Generation: Creating scannable QR codes that can encode URLs or other data, often with an associated chart.

Official SDKs by language

QuickChart provides official SDKs for several popular programming languages, ensuring direct API integration and support. These libraries are maintained to provide idiomatic access to QuickChart's features, including chart generation, QR code creation, and URL customization. The official SDKs handle aspects like URL encoding, JSON serialization of chart configurations, and API request construction.

The following table outlines the officially supported SDKs, their package names, installation methods, and general maturity:

Language Package/Library Install Command Example Maturity
Node.js quickchart-js npm install quickchart-js Stable
Python quickchart pip install quickchart Stable
PHP quickchart/quickchart-php composer require quickchart/quickchart-php Stable
Ruby quickchart gem install quickchart Stable
Java quickchart-java Include in pom.xml (Maven) or build.gradle (Gradle) Stable
Go github.com/quickchart/quickchart-go go get github.com/quickchart/quickchart-go Stable
C# QuickChart dotnet add package QuickChart Stable

Installation

Installation procedures for QuickChart SDKs vary by programming language and package manager. The following provides common installation steps for each officially supported language. Detailed instructions and any specific dependencies are typically found in the respective SDK's GitHub repository or the QuickChart client libraries documentation.

Node.js

The Node.js library can be installed via npm (Node Package Manager).

npm install quickchart-js

Python

The Python library is available through pip (Python Package Installer).

pip install quickchart

PHP

For PHP projects, Composer is used to install the QuickChart library.

composer require quickchart/quickchart-php

Ruby

Ruby developers can install the QuickChart gem using Bundler or direct gem installation.

# For Bundler (add to Gemfile)
gem 'quickchart'

# Or direct installation
gem install quickchart

Java

Java projects typically integrate the QuickChart library via Maven or Gradle. Add the dependency to your project's pom.xml (Maven) or build.gradle (Gradle).

Maven

<dependency>
    <groupId>io.quickchart</groupId>
    <artifactId>quickchart</artifactId>
    <version>2.0.0</version> <!-- Check for the latest version -->
</dependency>

Gradle

implementation 'io.quickchart:quickchart:2.0.0' // Check for the latest version

Go

Go modules are used to install the QuickChart Go library.

go get github.com/quickchart/quickchart-go

C#

The C# library is installed using the .NET CLI or NuGet Package Manager.

dotnet add package QuickChart

Quickstart example

The following examples demonstrate how to generate a basic bar chart URL using the QuickChart SDKs in Python and Node.js. These examples illustrate the typical workflow: initializing the client, defining the Chart.js configuration, and retrieving the chart image URL.

Python Quickstart

This Python example generates a URL for a simple bar chart. The setConfig method accepts a JSON string or a Python dictionary representing the Chart.js configuration.

from quickchart import QuickChart

qc = QuickChart()
qc.width = 500
qc.height = 300
qc.device_pixel_ratio = 2.0
qc.config = {
    'type': 'bar',
    'data': {
        'labels': ['January', 'February', 'March', 'April', 'May'],
        'datasets': [{
            'label': 'Sales',
            'data': [50, 60, 70, 180, 190]
        }]
    }
}

print(qc.get_url())

Node.js Quickstart

The Node.js example performs a similar operation, demonstrating how to set chart dimensions and configuration, then obtain the chart URL.

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

const qc = new QuickChart();
qc.setWidth(500);
qc.setHeight(300);
qc.setDevicePixelRatio(2.0);
qc.setConfig({
    type: 'bar',
    data: {
        labels: ['January', 'February', 'March', 'April', 'May'],
        datasets: [{
            label: 'Sales',
            data: [50, 60, 70, 180, 190]
        }]
    }
});

console.log(qc.getUrl());

Both examples output a URL that, when accessed in a browser or image viewer, displays the generated bar chart image. Developers can also use methods like toDataUrl() or toFile() (where available) to retrieve the chart as a base64 encoded string or save it directly to a file, respectively. For more advanced features like custom fonts, background colors, or QR code generation, the SDKs expose additional methods and properties that mirror the QuickChart Chart Image API reference capabilities.

Community libraries

While QuickChart maintains a suite of official SDKs for major programming languages, the nature of its HTTP-based API allows for community-driven implementations in other environments or for specialized use cases. These community efforts may include wrappers for languages not officially supported, integrations with specific frameworks, or utilities that extend QuickChart's functionality.

The QuickChart API is designed to be accessible via standard HTTP requests, typically involving a POST request with a JSON payload containing the Chart.js configuration QuickChart request documentation. This architectural choice means that any programming language with HTTP client capabilities can interact with the QuickChart service, even without a dedicated SDK. Developers can construct the JSON request body and send it to the API endpoint, then process the image data returned.

As of late 2024, the primary focus of QuickChart's developer ecosystem remains on its official SDKs due to their comprehensive coverage of popular languages and direct support. However, developers seeking to integrate QuickChart into less common environments or requiring highly specialized integrations may explore:

  • Direct HTTP Client Usage: Building custom functions using native HTTP client libraries (e.g., requests in Python, fetch in JavaScript, HttpClient in Java) to craft and send API requests. This offers maximum flexibility at the cost of increased boilerplate code.
  • Framework-Specific Integrations: Developing components or plugins for specific web frameworks (e.g., Django, Ruby on Rails, Laravel) that encapsulate QuickChart functionality within the framework's idioms.
  • Third-Party Package Registries: Searching public package repositories (e.g., GitHub, npm, PyPI) for community-contributed libraries that may extend or wrap QuickChart's functionality. It is advisable to check the maintenance status and community support for such libraries before incorporating them into production systems.

The open-source nature of many Chart.js-based projects and the clear API specification encourage such community contributions, although their stability and feature completeness may vary. Developers are encouraged to consult the official QuickChart documentation for the most up-to-date and officially supported integration methods.