Top Related Projects
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
Simple HTML5 Charts using the <canvas> tag
Open-source JavaScript charting library behind Plotly and Dash
A visualization grammar.
Highcharts JS, the JavaScript charting framework
Quick Overview
Plottable is a flexible, interactive charting library built on top of D3.js. It provides a powerful set of components for creating customizable, responsive charts and visualizations for web applications. Plottable aims to simplify the process of creating complex charts while maintaining the flexibility and power of D3.
Pros
- Highly customizable and extensible
- Built on top of D3.js, leveraging its powerful data manipulation capabilities
- Responsive design, adapting to different screen sizes
- Supports a wide range of chart types and components
Cons
- Learning curve can be steep for those unfamiliar with D3.js
- Documentation could be more comprehensive
- Less active development and community support compared to some other charting libraries
Code Examples
- Creating a simple line chart:
var xScale = new Plottable.Scales.Linear();
var yScale = new Plottable.Scales.Linear();
var plot = new Plottable.Plots.Line()
.x(function(d) { return d.x; }, xScale)
.y(function(d) { return d.y; }, yScale)
.addDataset(new Plottable.Dataset(data));
var chart = new Plottable.Components.Table([
[new Plottable.Components.YAxis(yScale), plot],
[null, new Plottable.Components.XAxis(xScale)]
]);
chart.renderTo("#chart-container");
- Adding interactivity with a tooltip:
var pointer = new Plottable.Interactions.Pointer();
pointer.onPointerMove(function(p) {
var nearestEntity = plot.entityNearest(p);
if (nearestEntity.datum) {
tooltip.content(nearestEntity.datum.y.toString());
tooltip.show();
} else {
tooltip.hide();
}
});
pointer.attachTo(plot);
- Creating a stacked bar chart:
var stackedPlot = new Plottable.Plots.StackedBar()
.x(function(d) { return d.category; }, xScale)
.y(function(d) { return d.value; }, yScale)
.addDataset(new Plottable.Dataset(data1))
.addDataset(new Plottable.Dataset(data2))
.addDataset(new Plottable.Dataset(data3));
Getting Started
To use Plottable in your project, include the necessary files in your HTML:
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/plottable.js/3.7.0/plottable.css">
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/plottable.js/3.7.0/plottable.min.js"></script>
Then, create a container element for your chart and use Plottable to render it:
<div id="chart-container"></div>
<script>
// Your Plottable chart code here
</script>
For more detailed instructions and examples, refer to the Plottable documentation.
Competitor Comparisons
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
Pros of D3
- More flexible and powerful, allowing for highly customized visualizations
- Larger community and ecosystem, with extensive documentation and examples
- Direct manipulation of the DOM, providing fine-grained control over rendering
Cons of D3
- Steeper learning curve, requiring more time to master
- More verbose code for common chart types
- Lower-level API, often requiring more boilerplate for basic visualizations
Code Comparison
D3:
const svg = d3.select("body").append("svg")
.attr("width", 400)
.attr("height", 300);
svg.selectAll("circle")
.data(data)
.enter().append("circle")
.attr("cx", d => d.x)
.attr("cy", d => d.y)
.attr("r", 5);
Plottable:
const xScale = new Plottable.Scales.Linear();
const yScale = new Plottable.Scales.Linear();
const plot = new Plottable.Plots.Scatter()
.x(d => d.x, xScale)
.y(d => d.y, yScale)
.addDataset(new Plottable.Dataset(data));
plot.renderTo("svg#chart");
While D3 offers more flexibility and control, Plottable provides a higher-level API for creating common chart types with less code. D3 is better suited for complex, custom visualizations, while Plottable simplifies the process of creating standard charts.
Simple HTML5 Charts using the <canvas> tag
Pros of Chart.js
- Simpler API and easier to get started with for beginners
- Lightweight and fast, with a smaller file size
- More built-in chart types and animations out of the box
Cons of Chart.js
- Less flexible for complex or custom visualizations
- Limited support for advanced interactivity and data binding
- Fewer options for fine-grained control over chart elements
Code Comparison
Chart.js:
new Chart(ctx, {
type: 'bar',
data: {
labels: ['Red', 'Blue', 'Yellow'],
datasets: [{
label: 'My Dataset',
data: [12, 19, 3]
}]
}
});
Plottable:
var xScale = new Plottable.Scales.Category();
var yScale = new Plottable.Scales.Linear();
var plot = new Plottable.Plots.Bar()
.x(function(d) { return d.x; }, xScale)
.y(function(d) { return d.y; }, yScale);
Both libraries offer powerful charting capabilities, but Chart.js is more suitable for simple, quick implementations, while Plottable provides greater flexibility and control for complex visualizations. Chart.js has a gentler learning curve, whereas Plottable requires more setup but offers more customization options.
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
- Larger community and more frequent updates
- Built-in interactivity features like zooming, panning, and hover tooltips
Cons of Plotly.js
- Larger file size and potentially slower performance for complex visualizations
- Steeper learning curve due to more extensive API and options
- Less flexibility for custom styling and layout control
Code Comparison
Plotly.js:
Plotly.newPlot('myDiv', [{
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
type: 'scatter'
}]);
Plottable:
var xScale = new Plottable.Scales.Linear();
var yScale = new Plottable.Scales.Linear();
var plot = new Plottable.Plots.Line()
.x(function(d) { return d.x; }, xScale)
.y(function(d) { return d.y; }, yScale);
Summary
Plotly.js offers a wider range of chart types and built-in interactivity, making it suitable for complex data visualizations. It has a larger community and more frequent updates. However, it comes with a larger file size and a steeper learning curve. Plottable, on the other hand, provides more flexibility for custom styling and layout control, with a potentially smaller footprint and simpler API for basic charts. The choice between the two depends on the specific requirements of your project and the level of customization needed.
A visualization grammar.
Pros of Vega
- More powerful and flexible declarative grammar for creating a wide range of visualizations
- Better support for interactive and animated visualizations
- Larger and more active community, with frequent updates and improvements
Cons of Vega
- Steeper learning curve due to its more complex grammar and specification format
- Requires more verbose code to create basic charts compared to Plottable
- Less seamless integration with TypeScript projects
Code Comparison
Vega (JSON specification):
{
"data": {"url": "data.csv"},
"mark": "bar",
"encoding": {
"x": {"field": "category", "type": "nominal"},
"y": {"field": "value", "type": "quantitative"}
}
}
Plottable (TypeScript):
const plot = new Plottable.Plots.Bar()
.x(d => d.category, xScale)
.y(d => d.value, yScale)
.addDataset(new Plottable.Dataset(data));
Both libraries offer powerful data visualization capabilities, but Vega provides a more comprehensive and flexible approach at the cost of increased complexity. Plottable offers a simpler API for basic charts but may be less suitable for more advanced or custom visualizations.
Highcharts JS, the JavaScript charting framework
Pros of Highcharts
- More extensive documentation and examples
- Wider range of chart types and customization options
- Larger community and ecosystem
Cons of Highcharts
- Commercial license required for most use cases
- Steeper learning curve due to more complex API
- Larger file size, potentially impacting page load times
Code Comparison
Highcharts:
Highcharts.chart('container', {
series: [{
data: [1, 2, 3, 4, 5]
}]
});
Plottable:
var plot = new Plottable.Plot.Line()
.addDataset(new Plottable.Dataset([1, 2, 3, 4, 5]))
.renderTo("#container");
Summary
Highcharts offers a more comprehensive charting solution with extensive features and customization options, but comes with a commercial license requirement. Plottable, while open-source and potentially easier to learn, has a smaller feature set and community. The choice between the two depends on project requirements, budget constraints, and desired level of customization.
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
Plottable
Plottable is a library of chart components for creating flexible, custom charts for websites. It is built on top of D3.js and provides higher-level pieces, like plots, gridlines, and axes. As such, it's easier to quickly build charts than with D3, and the charts are much more flexible than standard-template charts provided by charting libraries. You can think of Plottable as a "D3 for Charts" — it is not a charting library but rather a library of chart components. Check out examples of Plottable on our website's examples page.
Philosophy
Plottable's core philosophy is "Composition over Configuration", so a lot of the API flexibility is in choosing which Components
to use, and how to arrange them in Tables
, rather than setting high-level properties on the charts. If you find you need a feature that doesn't exist, consider writing a new Component
that implements the functionality. This way, you can get your custom functionality and still benefit from the rest of the library.
Plottable is used and developed at Palantir Technologies. It's developed in TypeScript and distributed in ES5 JavaScript.
Quick Start
- Get Plottable:
- npm:
npm install --save plottable
- yarn:
yarn add plottable
- jsdelivr
- npm:
- Check out examples
- Read the tutorials
- Visit the website, plottablejs.org
Upgrading to v1.0.0
If you are upgrading from a pre-v1.0.0 version of Plottable to v1.0.0 or later, please use the Upgrade Guide on the wiki.
Upgrading to v2.0.0
Check out the full list of changes between v1.16.2 and v2.0.0.
Upgrading to v3.0.0
Check out the full list of changes between v2.9.0 and v3.0.0.
We Want To Help!
If you run into any problems using Plottable, please let us know. We want Plottable to be easy-to-use, so if you are getting confused, it is our fault, not yours. Create an issue and we'll be happy to help you out, or drop by our Gitter room.
Development
- Clone the repo
- Install local dependencies
yarn install
- Run
yarn build
to build the dependencies - Run
yarn start
and it will spin up a server (pointed at http://localhost:9999) and begin compiling the typescript code - Navigate to
http://localhost:9999/quicktests/
and choose a directory to view visual tests
Contributing
- Write your code
- Add tests for new functionality, and please add some quicktests too
- Run
yarn test
and verify it completes with no warnings or failures - Submit a pull request and sign the CLA when prompted by our bot
Top Related Projects
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
Simple HTML5 Charts using the <canvas> tag
Open-source JavaScript charting library behind Plotly and Dash
A visualization grammar.
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