forked from trading-peter/chart-elements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart-pie.js
55 lines (43 loc) · 1.56 KB
/
chart-pie.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { LitElement } from 'lit-element/lit-element.js';
import { ChartPropertyMixin } from './chart-property-mixin';
import { ContextMixin } from './context-mixin';
import { ResizeMixin } from './resize-mixin.js';
/**
Pie and doughnut charts are probably the most commonly used chart there are. They are divided into segments, the arc of each segment shows a the proportional value of each piece of data.
They are excellent at showing the relational proportions between data.
Pie and doughnut charts in are effectively the same class in Chart.js, but have one different default value - their percentageInnerCutout. This equates what percentage of the inner should be cut out. This defaults to 0 for pie charts, and 50 for doughnuts.
They are also registered under two aliases in the Chart core. Other than their different default value, and different alias, they are exactly the same.
##### Example
<chart-pie data="[[data]]"></chart-pie>
...
this.data = {
labels: [
"Red",
"Green",
"Yellow"
],
datasets: [
{
data: [300, 50, 100],
backgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
],
hoverBackgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
]
}]
};
@group Chart Elements
@element chart-pie
*/
class ChartPie extends ResizeMixin(ContextMixin(ChartPropertyMixin(LitElement))) {
constructor() {
super();
this.__type = 'pie';
}
}
window.customElements.define('chart-pie', ChartPie);