{"library":"quickchart-js","title":"QuickChart JavaScript Client","description":"quickchart-js is the official JavaScript client library for QuickChart.io, a web service that renders static Chart.js images from a URL or POST request. It allows developers to programmatically generate highly customizable charts for various applications like email, SMS, or chat platforms. The library wraps the QuickChart API, simplifying the process of setting chart configurations (based on Chart.js syntax), dimensions, formats, and retrieving either long encoded URLs, short shareable URLs, or saving charts directly to a file. The current stable version is 3.1.3, with updates released periodically, typically every few months, reflecting active maintenance. A key differentiator is its ability to convert dynamic Chart.js configurations into static images, offering robust integration options where dynamic JavaScript charting is not feasible.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install quickchart-js"],"cli":null},"imports":["import { QuickChart } from 'quickchart-js';","new QuickChart(apiKey, accountId);","QuickChart.getGradientFillHelper('horizontal', ['red', 'green']);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { QuickChart } from 'quickchart-js';\nimport * as fs from 'fs/promises';\n\nconst myChart = new QuickChart();\nmyChart.setConfig({\n  type: 'bar',\n  data: {\n    labels: ['January', 'February', 'March', 'April', 'May'],\n    datasets: [\n      { label: 'Dogs', data: [50, 60, 70, 180, 190] },\n      { label: 'Cats', data: [100, 200, 300, 400, 500] }\n    ],\n  },\n  options: {\n    plugins: {\n      legend: { position: 'top' },\n      title: { display: true, text: 'Monthly Pet Counts' },\n    },\n  },\n});\n\nmyChart.setWidth(800);\nmyChart.setHeight(400);\nmyChart.setFormat('png');\nmyChart.setBackgroundColor('#f8f8f8');\n\nasync function generateCharts() {\n  // Get the direct URL\n  console.log('Direct Chart URL:', myChart.getUrl());\n\n  // Get a short, fixed-length URL (requires network request)\n  try {\n    const shortUrl = await myChart.getShortUrl();\n    console.log('Short Chart URL:', shortUrl);\n  } catch (error) {\n    console.error('Failed to get short URL:', error);\n  }\n\n  // Write the chart to a file\n  const filePath = './mychart.png';\n  try {\n    await myChart.toFile(filePath);\n    console.log(`Chart saved to ${filePath}`);\n  } catch (error) {\n    console.error('Failed to save chart to file:', error);\n  }\n}\n\ngenerateCharts();\n","lang":"typescript","description":"This quickstart demonstrates how to configure a Chart.js bar chart, customize its properties, retrieve both long and short URLs, and save the generated image to a local file.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}