🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

apex-charts-node

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apex-charts-node

Headless image renderer for Apex Charts

1.1.0
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

apex-charts-node

This package allows you to render Apex Charts on the server as PNG images. It's part of QuickChart, which offers a suite of tools for rendering charts & graphs as images.

Rendering takes an Apex Charts config and is made possible through the use of puppeteer, which uses the Chromium browser for "headless" rendering.

Installation

This project is available on NPM.

npm install apex-charts-node

Example

const ApexChartsNode = require('apex-charts-node');

// Build your config as you would normally
const config = {
  chart: {
    type: 'line'
  },
  series: [{
    name: 'sales',
    data: [30,40,35,50,49,60,70,91,125]
  }],
  xaxis: {
    categories: [1991,1992,1993,1994,1995,1996,1997, 1998,1999]
  }
};

// Render the chart to image
const image = await ApexChartsNode.render(drawChart, {
  width: 500,
  height: 300,
});

This produces the following image:

Apex Charts Image

Usage

render(chartConfig, options) -> Buffer

The library exposes a single function, render.

chartConfig is a JSON/Javascript object that is used to define the chart. You can put any regular Apex Charts object here.

options is a dictionary containing some settings and parameters:

  • width: Width of chart canvas
  • height: Height of chart canvas

Note that if you specify width only, height will be automatically calculated according to the "golden ratio" 1.618, which translates roughly to a 16:10 aspect ratio.

FAQs

Package last updated on 12 Apr 2022

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