Charts help you tell accurate and convincing stories around data with beautiful and accessible visualizations.
Note: Please direct all questions regarding support, bug fixes, and feature requests to the Carbon Charts core team.
Refer to the contribution guidelines before you start building. If you want to develop your own components, see the Vue Storybook to get started.
Visit the component status page for a complete list of available components.
$ yarn add @carbon/charts @carbon/charts-vue d3
$ npm install --save @carbon/charts @carbon/charts-vue d3
To start, try the BarChart
component with the example code below:
hello-world.vue<script>import Vue from 'vue';import '@carbon/charts/style.css';import chartsVue from '@carbon/charts-vue';Vue.use(chartsVue);export default {name: 'HelloWorld',components: {},data() {return {stackedBarData: {// ...see next section},stackedBarOptions: {// ...see next section},};},template:'<ccv-bar-chart :data="stackedBarData" :options="stackedBarOptions"></ccv-bar-chart>',};</script>
cd packages/vueyarn run storybook
Open browser to http://localhost:6006/
.
Data and options follow the same model in all charts, with minor exceptions and differences in specific components.
For example, you only need to provide one data set for pie and donut charts. In the case of donut charts, you can pass in an additional field called center
in your options when configuring the donut center.
Additional options available vary by chart type. For more examples see the data demo.
Below are sample data and options that can be used in a stacked bar chart:
import { BarChart, defaultColors } from '@carbon/charts';// Use the below if you're loading bundles through a CDN// const { BarChart, defaultColors } = Charts;const stackedBarData = {labels: ['Quantity', 'Leads', 'Sold', 'Restocking', 'Misc'],datasets: [{label: 'Dataset 1',backgroundColors: [defaultColors[0]],data: [65000, 29123, 35213, 51213, 16932],},{label: 'Dataset 2',backgroundColors: [defaultColors[1]],data: [32432, 21312, 56456, 21312, 34234],},{label: 'Dataset 3',backgroundColors: [defaultColors[2]],data: [12312, 23232, 34232, 12312, 34234],},],};const stackedBarOptions = {scales: {x: {title: '2018 Annual Sales',},y: {title: 'Figures',formatter: axisValue => {return `${axisValue / 1000}k`;},stacked: true,},},legendClickable: true,containerResizable: true,};
If you experience any issues while getting started with Carbon Charts, head over to the GitHub repo for more guidance and support. Please create a GitHub issue if you find a bug or need more help.