Top Related Projects
Simple HTML5 Charts using the <canvas> tag
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
JavaScript 3D Library.
Open-source JavaScript charting library behind Plotly and Dash
📊 Interactive JavaScript Charts built on SVG
Highcharts JS, the JavaScript charting framework
Quick Overview
Chartist.js is a simple, lightweight, and responsive JavaScript charting library. It provides a clean and customizable way to create SVG-based charts with a focus on simplicity and modern web standards.
Pros
- Lightweight and fast, with a small footprint
- Highly customizable with CSS styling options
- Responsive design, adapting to different screen sizes
- Good documentation and active community support
Cons
- Limited chart types compared to more comprehensive libraries
- Lack of built-in animations (though can be added with plugins)
- Not as feature-rich as some larger charting libraries
- Learning curve for advanced customizations
Code Examples
Creating a simple line chart:
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
[12, 9, 7, 8, 5],
[2, 1, 3.5, 7, 3],
[1, 3, 4, 5, 6]
]
});
Customizing a bar chart with CSS:
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';
}
}
}).on('draw', function(data) {
if(data.type === 'bar') {
data.element.attr({
style: 'stroke-width: 30px'
});
}
});
Creating a responsive pie chart:
new Chartist.Pie('.ct-chart', {
series: [20, 10, 30, 40]
}, {
donut: true,
donutWidth: 60,
startAngle: 270,
total: 200,
showLabel: false,
plugins: [
Chartist.plugins.legend()
]
});
Getting Started
- Include Chartist.js in your project:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/chartist@0.11.4/dist/chartist.min.css">
<script src="https://cdn.jsdelivr.net/npm/chartist@0.11.4/dist/chartist.min.js"></script>
- Create a container for your chart:
<div class="ct-chart ct-perfect-fourth"></div>
- Initialize a chart with JavaScript:
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
[12, 9, 7, 8, 5]
]
});
Competitor Comparisons
Simple HTML5 Charts using the <canvas> tag
Pros of Chart.js
- More extensive and feature-rich, offering a wider variety of chart types
- Larger community and more frequent updates, leading to better support and documentation
- Smoother animations and more interactive chart elements
Cons of Chart.js
- Larger file size, which may impact page load times
- Steeper learning curve due to more complex API and configuration options
- Less customizable styling options compared to Chartist's CSS-based approach
Code Comparison
Chartist:
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [[12, 9, 7, 8, 5]]
});
Chart.js:
new Chart(ctx, {
type: 'line',
data: {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
datasets: [{data: [12, 9, 7, 8, 5]}]
}
});
Both libraries offer straightforward ways to create basic charts, but Chart.js requires more configuration for advanced features. Chartist's syntax is generally more concise, while Chart.js provides more flexibility in data structure and chart customization.
Chart.js is better suited for complex, interactive visualizations, while Chartist excels in creating simple, lightweight charts with easy CSS styling. The choice between the two depends on project requirements, performance considerations, and desired level of customization.
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
Pros of D3
- Highly flexible and powerful, allowing for complex and custom visualizations
- Large ecosystem with numerous extensions and plugins
- Excellent performance for handling large datasets
Cons of D3
- Steeper learning curve due to its low-level nature
- Requires more code to create basic charts compared to Chartist
- Less suitable for quick, simple visualizations
Code Comparison
Chartist:
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [[12, 9, 7, 8, 5]]
});
D3:
const svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500);
svg.selectAll("rect")
.data(data)
.enter().append("rect")
.attr("y", (d) => y(d.name))
.attr("width", (d) => x(d.value))
.attr("height", y.bandwidth());
D3 offers more control and flexibility but requires more code for basic charts. Chartist provides a simpler API for common chart types, making it easier to create standard visualizations quickly. D3 excels in creating custom, interactive, and complex visualizations, while Chartist is better suited for straightforward, responsive charts with less customization.
JavaScript 3D Library.
Pros of Three.js
- Powerful 3D rendering capabilities for complex visualizations
- Extensive documentation and large community support
- Wide range of features including animations, lighting, and camera controls
Cons of Three.js
- Steeper learning curve due to its complexity
- Larger file size, which may impact page load times
- Overkill for simple 2D charts and graphs
Code Comparison
Three.js (3D scene setup):
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
Chartist (2D chart setup):
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [[12, 9, 7, 8, 5]]
}, {
fullWidth: true,
chartPadding: { right: 40 }
});
Three.js is ideal for complex 3D visualizations and interactive graphics, offering a wide range of features and strong community support. However, it comes with a steeper learning curve and larger file size. Chartist, on the other hand, is more suitable for simple 2D charts and graphs, with a focus on responsiveness and ease of use. The code comparison illustrates the difference in complexity between setting up a 3D scene in Three.js and creating a basic 2D chart with Chartist.
Open-source JavaScript charting library behind Plotly and Dash
Pros of Plotly.js
- More extensive and diverse chart types, including 3D plots and statistical charts
- Interactive features like zooming, panning, and hover tooltips out of the box
- Supports both SVG and WebGL rendering for better performance with large datasets
Cons of Plotly.js
- Larger file size and potentially slower load times compared to Chartist
- Steeper learning curve due to more complex API and configuration options
- May be overkill for simple charting needs
Code Comparison
Chartist example:
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [[12, 9, 7, 8, 5]]
});
Plotly.js example:
Plotly.newPlot('myDiv', [{
x: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
y: [12, 9, 7, 8, 5],
type: 'scatter'
}]);
Both libraries offer straightforward ways to create basic charts, but Plotly.js provides more built-in customization options and interactivity. Chartist focuses on simplicity and lightweight implementation, while Plotly.js offers a more comprehensive set of features at the cost of increased complexity and file size.
📊 Interactive JavaScript Charts built on SVG
Pros of ApexCharts
- More feature-rich with a wider variety of chart types
- Active development and frequent updates
- Extensive documentation and examples
Cons of ApexCharts
- Larger file size, potentially impacting page load times
- Steeper learning curve due to more complex API
Code Comparison
ApexCharts:
var options = {
chart: { type: 'line' },
series: [{ data: [30, 40, 35, 50, 49, 60, 70] }],
xaxis: { categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997] }
};
var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();
Chartist:
new Chartist.Line('.ct-chart', {
labels: [1991, 1992, 1993, 1994, 1995, 1996, 1997],
series: [[30, 40, 35, 50, 49, 60, 70]]
});
ApexCharts offers more configuration options out of the box, while Chartist provides a simpler API for basic charts. ApexCharts is actively maintained and offers more features, but comes with a larger file size. Chartist is lightweight and easy to use, but has fewer built-in chart types and customization options. The choice between the two depends on project requirements, performance considerations, and desired level of chart complexity.
Highcharts JS, the JavaScript charting framework
Pros of Highcharts
- More extensive feature set and chart types
- Better documentation and community support
- Responsive and mobile-friendly out of the box
Cons of Highcharts
- Commercial license required for most use cases
- Larger file size and potentially slower performance
- Steeper learning curve due to complexity
Code Comparison
Chartist:
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [[12, 9, 7, 8, 5]]
});
Highcharts:
Highcharts.chart('container', {
xAxis: {categories: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']},
series: [{data: [12, 9, 7, 8, 5]}]
});
Summary
Highcharts offers a more comprehensive charting solution with extensive features and better documentation, making it suitable for complex enterprise applications. However, it comes with a commercial license and a steeper learning curve. Chartist, on the other hand, is lightweight and free for all uses but has fewer features and less extensive documentation. The code comparison shows that both libraries have relatively simple syntax for basic charts, with Highcharts requiring slightly more configuration options.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
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? ⢠Docs ⢠Examples ⢠Contribution
Quickstart
Install this library using your favorite package manager:
pnpm add chartist
# or
yarn add chartist
# or
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.
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!
Top Related Projects
Simple HTML5 Charts using the <canvas> tag
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
JavaScript 3D Library.
Open-source JavaScript charting library behind Plotly and Dash
📊 Interactive JavaScript Charts built on SVG
Highcharts JS, the JavaScript charting framework
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot