What is chartist?
Chartist is a simple, responsive, and customizable charting library for creating various types of charts in web applications. It is designed to be lightweight and easy to use, making it a popular choice for developers who need to quickly add charts to their projects.
What are chartist's main functionalities?
Line Chart
This feature allows you to create a line chart. The code sample demonstrates how to create a simple line chart with labels for the days of the week and three series of data.
const Chartist = require('chartist');
new Chartist.Line('.ct-chart', {
labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
series: [
[12, 9, 7, 8, 5],
[2, 1, 3.5, 7, 3],
[1, 3, 4, 5, 6]
]
});
Bar Chart
This feature allows you to create a bar chart. The code sample demonstrates how to create a stacked bar chart with labels for the quarters of the year and three series of data.
const Chartist = require('chartist');
new Chartist.Bar('.ct-chart', {
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
series: [
[800000, 1200000, 1400000, 1300000],
[200000, 400000, 500000, 300000],
[100000, 200000, 400000, 600000]
]
}, {
stackBars: true,
axisY: {
labelInterpolationFnc: function(value) {
return (value / 1000) + 'k';
}
}
});
Pie Chart
This feature allows you to create a pie chart. The code sample demonstrates how to create a donut chart with four segments and custom options for the donut width, start angle, and total value.
const Chartist = require('chartist');
new Chartist.Pie('.ct-chart', {
series: [20, 10, 30, 40],
labels: ['A', 'B', 'C', 'D']
}, {
donut: true,
donutWidth: 60,
startAngle: 270,
total: 200,
showLabel: true
});
Other packages similar to chartist
chart.js
Chart.js is a popular open-source library for creating responsive and interactive charts. It offers a wide range of chart types and is known for its ease of use and extensive documentation. Compared to Chartist, Chart.js provides more advanced features and customization options, making it suitable for more complex charting needs.
d3
D3.js (Data-Driven Documents) is a powerful JavaScript library for creating complex and highly customizable visualizations. It provides a wide range of tools for manipulating documents based on data. While D3.js offers more flexibility and control over the visualizations compared to Chartist, it has a steeper learning curve and requires more effort to create basic charts.
highcharts
Highcharts is a commercial charting library that offers a wide variety of chart types and advanced features. It is known for its high performance and extensive customization options. Highcharts provides more out-of-the-box features and support compared to Chartist, but it requires a license for commercial use.
Big welcome by the Chartist Guy
Chartist is a simple responsive charting library built with SVG. There are hundreds of nice charting libraries already
out there, but they are either:
- use the wrong technologies for illustration (canvas)
- weighs hundreds of kilobytes
- are not flexible enough while keeping the configuration simple
- are not friendly to designers
- more annoying things
That's why we started Chartist and our goal is to solve all of the above issues.
Quickstart
•
What is it made for?
•
What's new in v1?
•
Examples
•
Contribution
Quickstart
Install this library using your favorite package manager:
pnpm add chartist
yarn add chartist
npm i chartist
Then, just import chart you want and use it:
import { BarChart } from 'chartist';
new BarChart('#chart', {
labels: ['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'W10'],
series: [
[1, 2, 4, 8, 6, -2, -1, -4, -6, -2]
]
}, {
high: 10,
low: -10,
axisX: {
labelInterpolationFnc: (value, index) => (index % 2 === 0 ? value : null)
}
});
Need an API to fetch data? Consider Cube, an open-source API for data apps.
What is it made for?
Chartist's goal is to provide a simple, lightweight and unintrusive library to responsively craft charts on your website.
It's important to understand that one of the main intentions of Chartist is to rely on standards rather than providing
it's own solution to a problem which is already solved by those standards. We need to leverage the power of browsers
today and say good bye to the idea of solving all problems ourselves.
Chartist works with inline-SVG and therefore leverages the power of the DOM to provide parts of its functionality. This
also means that Chartist does not provide it's own event handling, labels, behaviors or anything else that can just be
done with plain HTML, JavaScript and CSS. The single and only responsibility of Chartist is to help you drawing "Simple
responsive Charts" using inline-SVG in the DOM, CSS to style and JavaScript to provide an API for configuring your charts.
What's new in v1?
ESM
Now Chartist is truly an ES module and exposes its API through the exports, thus making Chartist tree-shakable.
Migration from v0.11
- Each property of Chartist object now is named export.
- Chart classes were renamed.
- Easing object now is named export.
const Chartist = require('chartist')
new Chartist.Bar();
new Chartist.Line();
new Chartist.Pie();
new Chartist.Svg();
Chartist.Svg.Easing
import { BarChart, LineChart, PieChart, Svg, easings } from 'chartist'
new BarChart()
new LineChart()
new PieChart()
new Svg()
easings
TypeScript
Chartist was rewritten and fully typed with TypeScript.
Some of exposed types
import type {
BarChartData,
BarChartOptions,
LineChartData,
LineChartOptions,
PieChartData,
PieChartOptions
} from 'chartist'
Examples
Bar Chart
Line Chart
Pie Chart
Plugins
Coming soon.
For v0.11
Some features aren't right for the core product
but there is a great set of plugins available
which add features like:
and more.
See all the plugins here.
Contribution
We are looking for people who share the idea of having a simple, flexible charting library that is responsive and uses
modern and future-proof technologies. The goal of this project is to create a responsive charting library where developers
have their joy in using it and designers love it because of the designing flexibility they have. Please contribute
to the project if you like the idea and the concept and help us to bring nice looking responsive open-source charts
to the masses.
Contribute if you like the Chartist Guy!