Skip to content

marcodpt/chart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chart

A chart element based on chart.js

Live demo

Usage

import chart from 'https://cdn.jsdelivr.net/gh/marcodpt/chart/index.js'

document.body.appendChild(chart({
  X: ['Jan', 'Fev', 'Mar'],
  Y: [1.5, 3.0, 4.5]
}))

document.body.appendChild(chart({
  X: ['Jan', 'Fev', 'Mar'],
  Y: [
    {
      data: [1.5, 3.0, 4.5],
      borderColor: 'blue',
      label: 'Sells ($)'
    }, {
      data: [2.5, 3.0, 2.5],
      borderColor: 'red',
      label: 'Expenses ($)'
    }
  ]
}))

Params

  • string type: type of chart (default: line)
  • object options: chart options (default: {})
  • array X: labels of X axis
  • array Y: items can be just axis Y values or a object with the following props:
    • array data: axis Y values of this line
    • string borderColor: color of line
    • string label: the chart label of this line