Donut Chart
Introduction
You can check a running example of this Donut Chart here.
All chart parameters for the Donut Chart can be checked in the API tab.
Basic Example
HTML
<o-chart type="donutChart" entity="EMovementTypesTotal" x-axis="MOVEMENTTYPES" y-axis="MOVEMENT" chart-height="400"></o-chart>
Custom Configuration Example
HTML
<o-chart type="donutChart" chart-height="400" entity="EMovementTypesTotal" x-axis="MOVEMENTTYPES" y-axis="MOVEMENT" [chart-parameters]="chartParameters"></o-chart>
TS
import { Component, ViewChild} from '@angular/core';
import { OChartComponent, DonutChartConfiguration } from 'ontimize-web-ngx-charts';
@Component({
selector: 'donut',
templateUrl: './donut.component.html'
})
export class DonutComponent {
chartParameters: DonutChartConfiguration;
constructor(protected injector: Injector,
protected navigationService: NavigationBarService,
protected translateService: OTranslateService) {
this.chartParameters = new DonutChartConfiguration();
this.chartParameters.showLabels = false;
this.chartParameters.cornerRadius = 15;
this.chartParameters.donutRatio = 0.5;
}
}
Donut Chart
Directive: o-chart
Inherited inputs
-
from OChartComponent:
- chart-height
- chart-parameters
- chart-width
- data
- type
- x-axis
- x-data-type
- x-label
- y-axis
- y-data-type
- y-label
Chart Parameters
Name | Description | Default |
---|---|---|
color string[] |
Colors to use for the different data. |
|
colorData OColorData[] = { value: string, color: string } |
List of colors for each value in the Y axis of the chart |
|
cornerRadius number |
Corner radius of donut slices |
0 |
donutRatio number |
Percent of pie radius to cut out of the middle to make the donut. It is multiplied by the outer radius to calculate the inner radius, thus it should be between 0 and 1. |
0.35 |
duration number |
Duration in ms to take when updating chart. For things like bar charts, each bar can animate by itself but the total time taken should be this value. |
500 |
endAngle function |
Function used to manage the ending angle of the donut chart |
|
labelSunbeamLayout boolean |
Enable or disable Sunbeam layout for labels |
true |
labelThreshold number |
Configure the minimum slice size for labels to show up |
0.01 |
labelType string |
Type of data shown in the label (key, value, percent) |
0 |
labelsOutside boolean |
Whether donut chart labels should be outside the slices instead of inside them |
false |
legendPosition string |
Position of the legend (top, right, bottom) |
top |
showLabels boolean |
Display donut labels |
true |
showLegend boolean |
Whether to display the legend or not |
true |
showTooltip boolean |
Enable or disable the tooltip |
true |
startAngle function |
Function used to manage the starting angle of the donut chart |
|
valueType string |
Formats value(s) |
|
Inherited outputs
-
from ChartComponent:
- onDoubleTap
- onPinch
- onPress
- onRotate
- onSwipe
- onTap