Stripped personal data from development repository
Samo Penic
2019-02-20 83c3f647c35477564b77cbc5b36d37d793d5442a
commit | author | age
83c3f6 1 # Polar Area
SP 2
3 Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value.
4
5 This type of chart is often useful when we want to show a comparison data similar to a pie chart, but also show a scale of values for context.
6
7 {% chartjs %}
8 {
9     "type": "polarArea",
10     "data": {
11         "labels": [
12             "Red",
13             "Green",
14             "Yellow",
15             "Grey",
16             "Blue"
17         ],
18         "datasets": [{
19             "label": "My First Dataset",
20             "data": [11, 16, 7, 3, 14],
21             "backgroundColor": [
22                 "rgb(255, 99, 132)",
23                 "rgb(75, 192, 192)",
24                 "rgb(255, 205, 86)",
25                 "rgb(201, 203, 207)",
26                 "rgb(54, 162, 235)"
27             ]
28         }]
29     },
30 }
31 {% endchartjs %}
32
33 ## Example Usage
34
35 ```javascript
36 new Chart(ctx, {
37     data: data,
38     type: 'polarArea',
39     options: options
40 });
41 ```
42
43 ## Dataset Properties
44
45 The following options can be included in a polar area chart dataset to configure options for that specific dataset.
46
47 | Name | Type | Description
48 | ---- | ---- | -----------
49 | `backgroundColor` | `Color[]` | The fill color of the arcs in the dataset. See [Colors](../general/colors.md#colors)
50 | `borderColor` | `Color[]` | The border color of the arcs in the dataset. See [Colors](../general/colors.md#colors)
51 | `borderWidth` | `Number[]` | The border width of the arcs in the dataset.
52 | `hoverBackgroundColor` | `Color[]` | The fill colour of the arcs when hovered.
53 | `hoverBorderColor` | `Color[]` | The stroke colour of the arcs when hovered.
54 | `hoverBorderWidth` | `Number[]` | The stroke width of the arcs when hovered.
55
56 ## Config Options
57
58 These are the customisation options specific to Polar Area charts. These options are merged with the [global chart default options](#default-options), and form the options of the chart.
59
60 | Name | Type | Default | Description
61 | ---- | ---- | ------- | -----------
62 | `startAngle` | `Number` | `-0.5 * Math.PI` | Starting angle to draw arcs for the first item in a dataset.
63 | `animation.animateRotate` | `Boolean` | `true` | If true, the chart will animate in with a rotation animation. This property is in the `options.animation` object.
64 | `animation.animateScale` | `Boolean` | `true` | If true, will animate scaling the chart from the center outwards.
65
66 ## Default Options
67
68 We can also change these defaults values for each PolarArea type that is created, this object is available at `Chart.defaults.polarArea`. Changing the global options only affects charts created after the change. Existing charts are not changed.
69
70 For example, to configure all new polar area charts with `animateScale = false` you would do:
71 ```javascript
72 Chart.defaults.polarArea.animation.animateScale = false;
73 ```
74
75 ## Data Structure
76
77 For a polar area chart, datasets need to contain an array of data points. The data points should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each.
78
79 You also need to specify an array of labels so that tooltips appear correctly for each slice.
80
81 ```javascript
82 data = {
83     datasets: [{
84         data: [10, 20, 30]
85     }],
86
87     // These labels appear in the legend and in the tooltips when hovering different arcs
88     labels: [
89         'Red',
90         'Yellow',
91         'Blue'
92     ]
93 };
94 ```