Quadratic Docs
  • Getting started
  • Examples
  • Open Quadratic
  • Quadratic AI
    • Getting started
    • Generate code
    • Generate data
    • Import PDFs
    • Import images
    • Security
  • Connections
    • SQL - getting started
    • PostgreSQL
    • MySQL
    • MS SQL Server
    • Parametrize queries
    • SQL AI assistant
    • Security
    • API requests
    • Request a connection
  • Python
    • Getting started
    • Reference cells
    • Return data to the sheet
    • Packages
    • Make an API request
    • Clean data
    • Charts/visualizations
    • Manipulate data
  • Javascript
    • Getting started
    • Reference cells
    • Return data to the sheet
    • API Requests
    • Charts/visualizations
    • Packages
  • Formulas
    • Getting started
    • AI assistant
    • Reference cells
    • Functions and operators
    • Arrays
    • Criteria
    • Wildcards
  • Spreadsheet
    • Navigating
    • Files
    • Shortcuts
    • Insert/delete rows and columns
    • Data validation
    • Present & share
    • Date-time formatting
    • Browser compatibility
  • Teams
    • Manage your team
    • Private files
    • Collaboration
    • Embedded sheets
  • Import data
    • SQL connections
    • API requests
    • Drag and drop .CSV
    • Drag and drop .Parquet
    • Import Excel files
  • Self hosting
    • Getting started
    • Docker
    • AWS
    • Azure
    • Google Cloud Platform
    • Bring your own AI
    • Other hosting
  • Quadratic for Education
    • Overview
    • Enrolling in the education plan
    • Teachers
    • Students
    • Researchers
    • Education FAQ
  • Company
    • About
    • Quadratic is source available
    • Brand assets
  • GitHub
  • Blog
  • Twitter
  • Discord
Powered by GitBook
On this page
  • Bar chart
  • Line chart

Was this helpful?

  1. Javascript

Charts/visualizations

PreviousAPI RequestsNextPackages

Last updated 1 year ago

Was this helpful?

Charts are supported in JavaScript using . No other libraries are currently supported.

Bar chart

import Chart from 'https://esm.run/chart.js/auto';

let canvas = new OffscreenCanvas(800, 450);
let context = canvas.getContext('2d');

// create data 
let data = [['Africa', 'Asia', 'Europe', 'Latin America', 'North America'],[2478, 5267, 734, 784, 433]]

// print data to console 
console.log(data)

// Create chart 
new Chart(canvas, {
    type: 'bar',
    data: {
        labels: data[0],
        datasets: [
        {
            label: "Population (millions)",
            backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
            data: data[1]
        }
        ]
    },
    options: {
        legend: { display: false },
        title: {
        display: true,
        text: 'Predicted world population (millions) in 2050'
        }
    }
});

// return chart to the sheet 
return canvas;

Line chart

import Chart from 'https://esm.run/chart.js/auto';

let canvas = new OffscreenCanvas(800, 450);
let context = canvas.getContext('2d');

// create data 
let data = [['1999', '2000', '2001', '2002', '2003'],[2478, 5267, 734, 784, 433]]

// print data to console 
console.log(data)

// Create chart 
new Chart(canvas, {
    type: 'line',
    data: {
        labels: data[0],
        datasets: [
        {
            label: "Population (millions)",
            backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
            data: data[1]
        }
        ]
    },
    options: {
        legend: { display: false },
        title: {
        display: true,
        text: 'Predicted world population (millions) in 2050'
        }
    }
});

// return chart to the sheet 
return canvas;
charts.js