-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsym-pie.js
120 lines (101 loc) · 2.43 KB
/
sym-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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
(function (PV) {
"use strict";
var currentValue;
function symbolVis() { };
PV.deriveVisualizationFromBase(symbolVis);
var definition = {
typeName: "pie",
iconUrl: 'Scripts\\app\\editor\\symbols\\ext\\icons\\pie.png',
visObjectType: symbolVis,
datasourceBehavior: PV.Extensibility.Enums.DatasourceBehaviors.Multiple,
getDefaultConfig: function () {
return {
DataShape: 'table',
Height: 150,
Width: 150,
}
},
}
symbolVis.prototype.init = function (scope, elem) {
this.onDataUpdate = dataUpdate;
var maximumValue;
var minimumValue;
var takenvalue;
am4core.useTheme(am4themes_animated);
var chart = am4core.create("chartContainerpie", am4charts.PieChart3D);
chart.hiddenState.properties.opacity = 0;
chart.legend = new am4charts.Legend();
chart.data = [
{
country: "Lithuania",
litres: 501.9
},
{
country: "Czech Republic",
litres: 301.9
},
{
country: "Ireland",
litres: 201.1
},
{
country: "Germany",
litres: 165.8
},
{
country: "Australia",
litres: 139.9
},
{
country: "Austria",
litres: 128.3
},
{
country: "UK",
litres: 99
},
{
country: "Belgium",
litres: 60
},
{
country: "The Netherlands",
litres: 50
}
];
var series = chart.series.push(new am4charts.PieSeries3D());
series.dataFields.value = "litres";
series.dataFields.category = "country";
function convertToChart(data){
return data.Rows.map(function(item){
return{
value: item.Value,
attribute: item.Label
}
});
}
function dataUpdate(newData){
if(newData){
var chartData = convertToChart(newData)
maximumValue = Number(chartData[0].value);
minimumValue = Number(chartData[1].value);
takenvalue = Number(chartData[2].value);
chart.data = [
{
country: "fabrika1",
litres: maximumValue
},
{
country: "fabrika2",
litres: minimumValue
},
{
country: "fabrika3",
litres: takenvalue
}
];
}
}
};
PV.symbolCatalog.register(definition);
})(window.PIVisualization);