Rate these docs

React Bootstrap Charts

React Charts - Bootstrap 4 & Material Design

React Bootstrap charts are graphical representations of data. Charts come in different sizes and shapes: bar, line, pie, radar, polar and more.

At your disposal are 6 types of charts and multiple options for customization.


Line chart


        import React from "react";
        import { Line } from "react-chartjs-2";
        import { MDBContainer } from "mdbreact";

        class ChartsPage extends React.Component {
          state = {
            dataLine: {
              labels: ["January", "February", "March", "April", "May", "June", "July"],
              datasets: [
                {
                  label: "My First dataset",
                  fill: true,
                  lineTension: 0.3,
                  backgroundColor: "rgba(225, 204,230, .3)",
                  borderColor: "rgb(205, 130, 158)",
                  borderCapStyle: "butt",
                  borderDash: [],
                  borderDashOffset: 0.0,
                  borderJoinStyle: "miter",
                  pointBorderColor: "rgb(205, 130,1 58)",
                  pointBackgroundColor: "rgb(255, 255, 255)",
                  pointBorderWidth: 10,
                  pointHoverRadius: 5,
                  pointHoverBackgroundColor: "rgb(0, 0, 0)",
                  pointHoverBorderColor: "rgba(220, 220, 220,1)",
                  pointHoverBorderWidth: 2,
                  pointRadius: 1,
                  pointHitRadius: 10,
                  data: [65, 59, 80, 81, 56, 55, 40]
                },
                {
                  label: "My Second dataset",
                  fill: true,
                  lineTension: 0.3,
                  backgroundColor: "rgba(184, 185, 210, .3)",
                  borderColor: "rgb(35, 26, 136)",
                  borderCapStyle: "butt",
                  borderDash: [],
                  borderDashOffset: 0.0,
                  borderJoinStyle: "miter",
                  pointBorderColor: "rgb(35, 26, 136)",
                  pointBackgroundColor: "rgb(255, 255, 255)",
                  pointBorderWidth: 10,
                  pointHoverRadius: 5,
                  pointHoverBackgroundColor: "rgb(0, 0, 0)",
                  pointHoverBorderColor: "rgba(220, 220, 220, 1)",
                  pointHoverBorderWidth: 2,
                  pointRadius: 1,
                  pointHitRadius: 10,
                  data: [28, 48, 40, 19, 86, 27, 90]
                }
              ]
            }
          };

          render() {
            return (
              <MDBContainer>
                <h3 className="mt-5">Line chart</h3>
                <Line data={this.state.dataLine} options={{ responsive: true }} />
              </MDBContainer>
            );
          }
        }

        export default ChartsPage;


      

Radar chart


        import React from "react";
        import { Radar } from "react-chartjs-2";
        import { MDBContainer } from "mdbreact";
        
        
        class ChartsPage extends React.Component {
          state = {
            dataRadar: {
              labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
              datasets: [
                {
                  label: "My First dataset",
                  backgroundColor: "rgba(194, 116, 161, 0.5)",
                  borderColor: "rgb(194, 116, 161)",
                  data: [65, 59, 90, 81, 56, 55, 40]
                },
                {
                  label: "My Second dataset",
                  backgroundColor: "rgba(71, 225, 167, 0.5)",
                  borderColor: "rgb(71, 225, 167)",
                  data: [28, 48, 40, 19, 96, 27,100]
                }
              ]
            }
        
          }
        
        
        render() {
            return (
              <MDBContainer>
                <h3 className="mt-5">Radar chart</h3>
                <Radar data={this.state.dataRadar} options={{ responsive: true }} />
              </MDBContainer>
            );
          }
        }
        
        export default ChartsPage;

      

Bar chart


        import React from "react";
        import { Bar } from "react-chartjs-2";
        import { MDBContainer } from "mdbreact";

        class ChartsPage extends React.Component {
          state = {
            dataBar: {
              labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
              datasets: [
                {
                  label: "% of Votes",
                  data: [12, 19, 3, 5, 2, 3],
                  backgroundColor: [
                    "rgba(255, 134,159,0.4)",
                    "rgba(98,  182, 239,0.4)",
                    "rgba(255, 218, 128,0.4)",
                    "rgba(113, 205, 205,0.4)",
                    "rgba(170, 128, 252,0.4)",
                    "rgba(255, 177, 101,0.4)"
                  ],
                  borderWidth: 2,
                  borderColor: [
                    "rgba(255, 134, 159, 1)",
                    "rgba(98,  182, 239, 1)",
                    "rgba(255, 218, 128, 1)",
                    "rgba(113, 205, 205, 1)",
                    "rgba(170, 128, 252, 1)",
                    "rgba(255, 177, 101, 1)"
                  ]
                }
              ]
            },
            barChartOptions: {
              responsive: true,
              maintainAspectRatio: false,
              scales: {
                xAxes: [
                  {
                    barPercentage: 1,
                    gridLines: {
                      display: true,
                      color: "rgba(0, 0, 0, 0.1)"
                    }
                  }
                ],
                yAxes: [
                  {
                    gridLines: {
                      display: true,
                      color: "rgba(0, 0, 0, 0.1)"
                    },
                    ticks: {
                      beginAtZero: true
                    }
                  }
                ]
              }
            }
          }


          render() {
            return (
              <MDBContainer>
                <h3 className="mt-5">Bar chart</h3>
                <Bar data={this.state.dataBar} options={this.state.barChartOptions} />
              </MDBContainer>
            );
          }
        }

        export default ChartsPage;
      

Polar Area Chart


        import React from "react";
        import { Polar } from "react-chartjs-2";
        import { MDBContainer } from "mdbreact";

        class ChartsPage extends React.Component {
          state = {
            dataPolar: {
              datasets: [
                {
                  data: [300, 50, 100, 40, 120],
                  backgroundColor: [
                    "rgba(247, 70, 74, 0.5)",
                    "rgba(70, 191, 189, 0.5)",
                    "rgba(253, 180, 92, 0.5)",
                    "rgba(148, 159, 177, 0.5)",
                    "rgba(77, 83, 96, 0.5)"
                  ],
                  label: "My dataset" // for legend
                }
              ],
              labels: ["Red", "Green", "Yellow", "Grey", "Dark Grey"]
            }
          }

          render() {
            return (
              <MDBContainer>
                <h3 className="mt-5">Polar area chart</h3>
                <Polar data={this.state.dataPolar} options={{ responsive: true }} />
              </MDBContainer>
            );
          }
        }

        export default ChartsPage;
      

Pie Chart


        import React from "react";
        import { Pie } from "react-chartjs-2";
        import { MDBContainer } from "mdbreact";
        
        class ChartsPage extends React.Component {
          state = {
            dataPie: {
              labels: ["Red", "Green", "Yellow", "Grey", "Dark Grey"],
              datasets: [
                {
                  data: [300, 50, 100, 40, 120],
                  backgroundColor: [
                    "#F7464A",
                    "#46BFBD",
                    "#FDB45C",
                    "#949FB1",
                    "#4D5360",
                    "#AC64AD"
                  ],
                  hoverBackgroundColor: [
                    "#FF5A5E",
                    "#5AD3D1",
                    "#FFC870",
                    "#A8B3C5",
                    "#616774",
                    "#DA92DB"
                  ]
                }
              ]
            }
          }
        
          render() {
            return (
              <MDBContainer>
                <h3 className="mt-5">Pie chart</h3>
                <Pie data={this.state.dataPie} options={{ responsive: true }} />
              </MDBContainer>
            );
          }
        }
        
        export default ChartsPage;
      

Doughnut Chart


        import React from "react";
        import { Doughnut } from "react-chartjs-2";
        import { MDBContainer } from "mdbreact";

        class ChartsPage extends React.Component {
        state = {
          dataDoughnut: {
            labels: ["Red", "Green", "Yellow", "Grey", "Dark Grey"],
            datasets: [
              {
                data: [300, 50, 100, 40, 120],
                backgroundColor: ["#F7464A", "#46BFBD", "#FDB45C", "#949FB1", "#4D5360"],
                hoverBackgroundColor: [
                  "#FF5A5E",
                  "#5AD3D1",
                  "#FFC870",
                  "#A8B3C5",
                  "#616774"
                ]
              }
            ]
          }
        }

        render() {
            return (
            <MDBContainer>
              <h3 className="mt-5">Doughnut chart</h3>
              <Doughnut data={this.state.dataDoughnut} options={{ responsive: true }} />
            </MDBContainer>
            );
          }
        }

        export default ChartsPage;
      

Minimalist charts MDB Pro component

Sales
ROI
Conversion

        import React from "react";
        import {
          MDBContainer,
          MDBRow,
          MDBCol,
          MDBIcon,
          MDBSimpleChart
        } from "mdbreact";

        class ChartsPagePro extends React.Component {
          render() {
            return (
              <MDBContainer>
                <h3 className="mt-5">Minimalistic charts</h3>
                <div style={{ marginTop: "100px" }}>
                  <MDBContainer>
                    <MDBRow className="text-center">
                      <MDBCol sm="4">
                        <MDBSimpleChart
                          width={100}
                          height={100}
                          strokeWidth={3}
                          percent={56}
                          strokeColor="#4FB64E"
                          labelFontWeight="300"
                          labelColor="#000"
                        />
                        <h6 className="mt-5">
                          <span className="label green p-1 white-text">
                            <strong>Sales</strong>
                            <MDBIcon icon="arrow-circle-up" className="ml-1" />
                          </span>
                        </h6>
                      </MDBCol>
                      <MDBCol sm="4">
                        <MDBSimpleChart
                          width={100}
                          height={100}
                          strokeWidth={3}
                          percent={76}
                          strokeColor="#EA3C3B"
                          labelFontWeight="300"
                          labelColor="#000"
                        />
                        <h6 className="mt-5">
                          <span className="label red p-1 white-text">
                            <strong>ROI</strong>
                            <MDBIcon icon="arrow-circle-down" className="ml-1" />
                          </span>
                        </h6>
                      </MDBCol>
                      <MDBCol sm="4">
                        <MDBSimpleChart
                          width={100}
                          height={100}
                          strokeWidth={3}
                          percent={100}
                          strokeColor="#9D9D9D"
                          labelFontWeight="300"
                          labelColor="#000"
                        />
                        <h6 className="mt-5">
                          <span className="label grey p-1 white-text">
                            <strong>Conversion</strong>
                            <MDBIcon icon="minus-square" className="ml-1" />
                          </span>
                        </h6>
                      </MDBCol>
                    </MDBRow>
                  </MDBContainer>
                </div>
              </MDBContainer>
            );
          }
        }

        export default ChartsPagePro;

      

Install MDB CLI
It's the fastest way to create and host MDB projects
Free Download

Charts - API

In this section, you will find advanced information about the Line, Radar, Bar, Polar, Pie, Doughnut components. You will learn which modules are required in this component, what are the possibilities of configuring the component, and what events and methods you can use in working with it.


API Reference: Options

In order to use Charts components make sure you have imported proper module first.


                import { Line, Radar, Bar, Polar, Pie, Doughnut } from "react-chartjs-2";
      

The table below shows the configuration options of the components.


Line

Name Type Default Description Example
showLines Boolean true If false, the lines between points are not drawn. showLines: false
spanGaps Boolean false If false, NaN data causes a break in the line. spanGaps: true
scales Object - Changes the scale settings in the charts scales: { yAxes: [ { ticks: { max: 100, min: -100 } } ] }

Radar

Name Type Default Description Example
scale Object - Changes the scale settings in the charts scale: { display: false, ticks: { max: 250 } }
startAngle number -0.5 * Math.PI Starting angle to draw arcs for the first item in a dataset. startAngle: 3 * Math.PI

Bar

Name Type Default Description Example
scales Object - Changes the scale settings in the charts scales: { yAxes: [ { ticks: { max: 100, min: -100 } } ] }

Polar

Name Type Default Description Example
startAngle number -0.5 * Math.PI Starting angle to draw arcs for the first item in a dataset. startAngle: 3 * Math.PI
animation.animateRotate Boolean true If true, the chart will animate in with a rotation animation. This property is in the options.animation object. animation: { animateRotate: false }
animation.animateScale Boolean true If true, will animate scaling the chart from the center outwards. animation: { animateScale: false }
scale Object - Changes the scale settings in the charts scale: { display: false, ticks: { max: 250 } }

Doughnut & Pie

Name Type Default Description Example
rotation number -0.5 * Math.PI Starting angle to draw arcs from. rotation: 3 * Math.PI
circumference number 2 * Math.PI Sweep to allow arcs to cover. circumference: 3 * Math.PI
animation.animateRotate Boolean true If true, the chart will animate in with a rotation animation. This property is in the options.animation object. animation: { animateRotate: false }
animation.animateScale Boolean true If true, will animate scaling the chart from the center outwards. animation: { animateScale: false }
cutoutPercentage number 50 - for doughnut, 0 - for pie The percentage of the chart that is cut out of the middle. cutoutPercentage: 30

MDBSimpleChart - Component MDB Pro component

In this section, you will find advanced information about the MDBSimpleChart component. You will learn which modules are required in this component, what are the possibilities of configuring the component, and what events and methods you can use in working with it.


Import statement

In order to use MDBSimpleChart component make sure you have imported proper module first.


        import { MDBSimpleChart } from "mdbreact";
    

API Reference: Properties MDB Pro component

The table below shows the configuration options of the MDBSimpleChart component.

Name Type Default Description Example
width number 150 Chart width <MDBSimpleChart width={100} >
height number 150 Chart height <MDBSimpleChart height="100" >
strokeWidth number 10 The stroke width of the chart in pixels. <MDBSimpleChart strokeWidth={4} >
strokeColor string '#408AE5' The stroke colour of the charts. <MDBSimpleChart strokeColor="#4FB64E" >
labelFontWeight string 'bold' Label font weight <MDBSimpleChart labelFontWeight="light" >
labelFontSize string '1.2em' Label font size <MDBSimpleChart labelFontSize="2rem" >
fillColor string 'none' The fill color whithin the circle. <MDBSimpleChart fillColor="red" >
percent number 'none' The percentage shown on the chart <MDBSimpleChart percent={56} >