Top Related Projects
Simple HTML5 Charts using the <canvas> tag
📊 Re-usable, easy interface JavaScript chart library based on D3.js
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
📊 Interactive JavaScript Charts built on SVG
nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
Redefined chart library built with React and D3
Quick Overview
Angular-charts is a lightweight charting library for AngularJS applications. It provides a simple way to create interactive charts using D3.js and AngularJS directives, making it easy to integrate data visualization into Angular-based web applications.
Pros
- Easy integration with AngularJS applications
- Utilizes D3.js for powerful and flexible charting capabilities
- Supports various chart types (line, bar, pie, etc.)
- Responsive and interactive charts out of the box
Cons
- Limited to AngularJS 1.x, not compatible with newer Angular versions
- Less actively maintained compared to more modern charting libraries
- Documentation could be more comprehensive
- Fewer customization options compared to some other charting libraries
Code Examples
- Creating a simple line chart:
<div ac-chart="'line'" ac-data="lineData" ac-config="lineConfig"></div>
$scope.lineData = {
series: ['Series A', 'Series B'],
data: [
{x: "Jan", y: [100, 130]},
{x: "Feb", y: [140, 145]},
{x: "Mar", y: [115, 135]}
]
};
$scope.lineConfig = {
title: 'Line Chart',
tooltips: true,
labels: false,
mouseover: function() {},
mouseout: function() {},
click: function() {},
legend: {
display: true,
position: 'right'
}
};
- Creating a bar chart:
<div ac-chart="'bar'" ac-data="barData" ac-config="barConfig"></div>
$scope.barData = {
series: ['2008', '2009'],
data: [
{x: "Sales", y: [100, 130]},
{x: "Income", y: [140, 145]},
{x: "Expense", y: [115, 135]}
]
};
$scope.barConfig = {
title: 'Bar Chart',
yAxis: {
ticks: [20, 40, 60, 80, 100, 120, 140]
}
};
- Creating a pie chart:
<div ac-chart="'pie'" ac-data="pieData" ac-config="pieConfig"></div>
$scope.pieData = {
series: ['iPhone', 'iPad', 'iMac'],
data: [{
x: "Sales",
y: [30, 50, 20]
}]
};
$scope.pieConfig = {
title: 'Pie Chart',
tooltips: true,
labels: true,
colors: ['#FF6384', '#36A2EB', '#FFCE56'],
legend: {
display: true,
position: 'right'
}
};
Getting Started
-
Install the library using Bower:
bower install angular-charts
-
Include the necessary files in your HTML:
<script src="bower_components/d3/d3.min.js"></script> <script src="bower_components/angular/angular.min.js"></script> <script src="bower_components/angular-charts/dist/angular-charts.min.js"></script>
-
Add the module dependency to your Angular app:
angular.module('myApp', ['angularCharts']);
-
Use the
ac-chart
directive in your HTML to create charts, as shown in the code examples above.
Competitor Comparisons
Simple HTML5 Charts using the <canvas> tag
Pros of Chart.js
- More comprehensive and feature-rich charting library
- Actively maintained with frequent updates and a large community
- Supports a wider range of chart types and customization options
Cons of Chart.js
- Steeper learning curve due to its extensive API and options
- Larger file size, which may impact page load times
- Not specifically designed for Angular, requiring additional setup for integration
Code Comparison
angular-charts:
$scope.data = {
series: ['Sales', 'Income'],
data: [
{x: "2014", y: [100, 150]},
{x: "2015", y: [200, 250]}
]
};
Chart.js:
new Chart(ctx, {
type: 'bar',
data: {
labels: ['2014', '2015'],
datasets: [
{label: 'Sales', data: [100, 200]},
{label: 'Income', data: [150, 250]}
]
}
});
Summary
Chart.js offers a more robust and versatile charting solution with broader community support, while angular-charts provides a simpler, Angular-specific implementation. Chart.js may be preferable for complex projects requiring extensive customization, whereas angular-charts could be suitable for quick integration in Angular applications with basic charting needs.
📊 Re-usable, easy interface JavaScript chart library based on D3.js
Pros of billboard.js
- More actively maintained with frequent updates and releases
- Supports a wider variety of chart types and customization options
- Better documentation and examples
Cons of billboard.js
- Steeper learning curve due to more complex API
- Larger file size, which may impact page load times
Code Comparison
billboard.js:
var chart = bb.generate({
bindto: "#chart",
data: {
columns: [
["data1", 30, 200, 100, 400, 150, 250],
["data2", 50, 20, 10, 40, 15, 25]
]
}
});
angular-charts:
$scope.data = {
series: ['Sales', 'Income'],
data: [
{x: "Laptops", y: [100, 500]},
{x: "Desktops", y: [300, 100]}
]
};
Summary
billboard.js offers more features and better maintenance, making it suitable for complex charting needs. However, angular-charts may be easier to integrate for simple Angular projects. The code comparison shows that billboard.js uses a more declarative approach, while angular-charts relies on Angular's data binding.
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
Pros of d3
- More powerful and flexible, allowing for complex custom visualizations
- Larger community and ecosystem, with extensive documentation and examples
- Can be used with any framework or vanilla JavaScript
Cons of d3
- Steeper learning curve due to its low-level nature
- Requires more code to create basic charts
- Less integration with Angular-specific features
Code Comparison
d3:
const svg = d3.select("body").append("svg")
.attr("width", 400)
.attr("height", 300);
svg.selectAll("rect")
.data(data)
.enter().append("rect")
.attr("x", (d, i) => i * 40)
.attr("y", d => 300 - d * 10)
.attr("width", 38)
.attr("height", d => d * 10);
angular-charts:
$scope.data = {
series: ['Sales', 'Income'],
data: [
{x: "2014", y: [100, 150]},
{x: "2015", y: [120, 180]},
{x: "2016", y: [140, 200]}
]
};
$scope.chartType = 'bar';
Summary
d3 offers more flexibility and power for creating custom visualizations but requires more effort to implement. angular-charts provides a simpler, more Angular-friendly approach for basic charts but with less customization options. The choice between the two depends on the complexity of the visualizations needed and the developer's familiarity with Angular and d3.
📊 Interactive JavaScript Charts built on SVG
Pros of ApexCharts.js
- More comprehensive and feature-rich charting library
- Supports a wider range of chart types and customization options
- Active development with frequent updates and improvements
Cons of ApexCharts.js
- Larger file size and potentially higher performance overhead
- Steeper learning curve due to more complex API and configuration options
Code Comparison
ApexCharts.js:
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();
angular-charts:
$scope.data = {
series: ['Sales', 'Income'],
data: [
{x: "2014", y: [100, 50]},
{x: "2015", y: [130, 80]}
]
};
Summary
ApexCharts.js offers a more comprehensive charting solution with a wider range of features and customization options. It's actively maintained and frequently updated. However, it comes with a larger file size and a steeper learning curve. angular-charts, on the other hand, provides a simpler API and integration specifically for AngularJS applications, but with fewer chart types and customization options. The choice between the two depends on the specific requirements of your project and the level of complexity you're willing to work with.
nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
Pros of nivo
- More comprehensive and feature-rich charting library
- Supports React out of the box, with better integration
- Actively maintained with frequent updates and improvements
Cons of nivo
- Steeper learning curve due to more complex API
- Larger bundle size, which may impact performance for smaller projects
- Requires more setup and configuration compared to simpler libraries
Code Comparison
nivo example:
import { ResponsivePie } from '@nivo/pie'
const MyPieChart = ({ data }) => (
<ResponsivePie
data={data}
margin={{ top: 40, right: 80, bottom: 80, left: 80 }}
innerRadius={0.5}
padAngle={0.7}
cornerRadius={3}
/>
)
angular-charts example:
$scope.pieChart = {
data: [
{ label: "A", value: 25 },
{ label: "B", value: 75 }
],
options: {
thickness: 0.2
}
};
While both libraries provide charting capabilities, nivo offers a more modern and flexible approach with React integration. It provides more customization options but requires more setup. angular-charts is simpler to use but has limited features and is specifically designed for AngularJS applications. The code examples demonstrate the difference in syntax and configuration between the two libraries.
Redefined chart library built with React and D3
Pros of recharts
- Built with React, offering seamless integration with React applications
- More active development and larger community support
- Extensive documentation and examples
Cons of recharts
- Limited to React applications, not suitable for Angular projects
- Steeper learning curve for developers unfamiliar with React
Code Comparison
recharts:
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts';
const Chart = ({ data }) => (
<LineChart width={600} height={300} data={data}>
<Line type="monotone" dataKey="value" stroke="#8884d8" />
<CartesianGrid stroke="#ccc" />
<XAxis dataKey="name" />
<YAxis />
<Tooltip />
<Legend />
</LineChart>
);
angular-charts:
<div ac-chart="chartType" ac-data="data" ac-config="config" id='chart' class='chart'></div>
$scope.data = {
series: ['Sales', 'Income'],
data: [
{x: "Laptops", y: [100, 120]},
{x: "Desktops", y: [70, 80]}
]
};
Summary
recharts is a more modern and actively maintained library specifically designed for React applications, offering extensive features and documentation. However, it's limited to React ecosystems. angular-charts, while older and less actively maintained, provides a simpler integration for Angular projects but with fewer features and customization 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
Features
=======
- One click chart change
- Tiny - 4.4kb minified and gzipped
- Auto tooltips
- Auto h,w dimensions updates automatically when resizing
- Beautiful animations
- Callback events
- Simple data format
Download | Playground | Contribute
Installation
Grab the latest zip from releases, copy angular-charts.min.js
to web root, and refer it from page.
<script src='path/to/js/angular-charts.min.js' type='text/javascript'></script>
Add as dependency in your module
angular.module('yourApp', ['angularCharts']);
Dependencies
- angular
- d3
Install using bower
bower install angular-charts
Refer all dependencies in your page in right order
<script src='./bower_components/angular/angular.min.js' type='text/javascript'></script>
<script src='./bower_components/d3/d3.min.js' type='text/javascript'></script>
<script src='./bower_components/angular-charts/dist/angular-charts.min.js' type='text/javascript'></script>
Configuration
Directive syntax
<div ac-chart="chartType" ac-data="data" ac-config="config" id='chart' class='chart'></div>
Note: chartType, data and config are properties of scope. Not the actual values.
ac-chart - string
Allowed values - 'pie', 'bar', 'line', 'point', 'area'
ac-config - object
var config = {
title: '', // chart title. If this is false, no title element will be created.
tooltips: true,
labels: false, // labels on data points
// exposed events
mouseover: function() {},
mouseout: function() {},
click: function() {},
// legend config
legend: {
display: true, // can be either 'left' or 'right'.
position: 'left',
// you can have html in series name
htmlEnabled: false
},
// override this array if you're not happy with default colors
colors: [],
innerRadius: 0, // Only on pie Charts
lineLegend: 'lineEnd', // Only on line Charts
lineCurveType: 'cardinal', // change this as per d3 guidelines to avoid smoothline
isAnimate: true, // run animations while rendering chart
yAxisTickFormat: 's', //refer tickFormats in d3 to edit this value
xAxisMaxTicks: 7, // Optional: maximum number of X axis ticks to show if data points exceed this number
yAxisTickFormat: 's', // refer tickFormats in d3 to edit this value
waitForHeightAndWidth: false // if true, it will not throw an error when the height or width are not defined (e.g. while creating a modal form), and it will be keep watching for valid height and width values
};
ac-data - object
Entire data structure looks like this
var acData = {
series: ["Sales", "Income", "Expense"],
data: [{
x: "Computers",
y: [54, 0, 879],
tooltip: "This is a tooltip"
}]
}
series - string array
var series = [
"Sales",
"Income",
"Expense"
]
data - object array
x defines what goes on x axis, must be a string, y defines what goes on y axis, must be an array of numbers. Values are mapped to series by index. y[0] belongs to series[0], y[1] belongs to series[1] and so on. Tooltip is optional.
Each data point looks like this
var dataPoint = {
x: "Computers",
y: [54, 0, 879],
tooltip: "This is a tooltip"
}
Note: series and data are arrays
Events
Three events are exposed via config object.
click : function(d) {
$scope.messages.push('clicked!');
},
mouseover : function(d) {
$scope.messages.push('mouseover!');
},
mouseout : function(d) {
$scope.messages.push('mouseout!');
}
Contribute
Thanks to all awesome contributors
Some things to follow
-
Make sure all tests are passing.
-
Update this README if you are doing any change to config object.
-
Avoid any changes in data format
-
Keep backwards compatibility
git clone git@github.com:chinmaymk/angular-charts.git npm install bower install grunt
To run tests:
grunt karma
Got suggestions ?
Feel free to submit a pull request, file an issue, or get in touch on twitter @_chinmaymk
Top Related Projects
Simple HTML5 Charts using the <canvas> tag
📊 Re-usable, easy interface JavaScript chart library based on D3.js
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
📊 Interactive JavaScript Charts built on SVG
nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
Redefined chart library built with React and D3
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