Chart types

The chart type is defined through the type property. It supports seven different types of charts with an option for customizations:

  • pie
  • bar
  • line
  • doughnut
  • polarArea
  • radar
  • horizontalBar

Each type has it's own format of data, and it can be supplied through the data property. For example, in the doughnut chart, the type should refer to doughnut and the data property should bind to the data options, as shown here:

<p-chart type="doughnut" [data]="doughnutdata"></p-chart>

The component class has to define data with the options labels and datasets, as shown here:

this.doughnutdata = {
labels: ['PrimeNG', 'PrimeUI', 'PrimeReact'],
datasets: [
{
data: [3000, 1000, 2000],
backgroundColor: [
"#6544a9",
"#51cc00",
"#5d4361"
],
hoverBackgroundColor: [
"#6544a9",
"#51cc00",
"#5d4361"
]
}
]
};

Along with the labels and data options, other properties related to skinning can be applied too.

The legends are closable by default (that is, if you want to visualize only a particular data variant, then it is possible by collapsing legends which are not required). The collapsed legend is represented with a strike line. The respective data component will disappear after the click operation on the legend.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.249.220