lara-light-indigo

Charts

Chart components are based on Chart.js, an open source HTML5 based charting library.

Import via Module

import { Chart } from 'primereact/chart';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/chart/chart.min.js"></script>
 
Getting Started

Chart component is a wrapper around on Chart.js 3.3.2+ so chart.js needs to be included in your project. For a complete documentation and samples please refer to the chart.js website.


npm install chart.js
 
Chart Types

Chart type is defined using the type property. Currently there are 6 options available; "pie", "doughtnut", "line", "bar", "radar" and "polarArea".

Data

Data of a chart is provided using a binding to the data property, each type has its own format of data. Here is an example of a line chart.


<Chart type="line" data={data} />
 

const data = {
    labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
    datasets: [
        {
            label: 'First Dataset',
            data: [65, 59, 80, 81, 56, 55, 40],
            fill: false,
            borderColor: '#4bc0c0'
        },
        {
            label: 'Second Dataset',
            data: [28, 48, 40, 19, 86, 27, 90],
            fill: false,
            borderColor: '#565656'
        }
    ]
};
 
Options

While a series can be customized per dataset, general chart options are defined with options property. Example below adds a title and customizes the legend position of the chart. For all available options refer to the charts.js documentation.


<Chart type="line" data={data} options={options} />
 

const options = {
    plugins: {
        title: {
            display: true,
            text: 'My Title',
            font: {
                size: 16
            }
        },
        legend: {
            position: 'bottom'
        }
    };
}
 
Properties
NameTypeDefaultDescription
idstringnullUnique identifier of the element.
typestringnullType of the chart.
dataanynullData to display.
optionsobjectnullOptions to customize the chart.
pluginsany[]nullUsed to custom plugins of the chart.
widthstringnullWidth of the chart in non-responsive mode.
heightstringnullHeight of the chart in non-responsive mode.
stylestringnullInline style of the element.
classNamestringnullStyle class of the element.
Methods
NameParametersDescription
refresh-Redraws the graph.
Accessibility

This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma