-
-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathPieChart.ux
60 lines (52 loc) · 1.83 KB
/
PieChart.ux
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
<ChartPage Title="Pie chart" File="PieChart" ux:Class="PieChart" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")
function Item( y, z, label, color ) {
this.y = y
this.z = z
this.label = label
this.color = color
}
var names = [ "Vebjørn", "Annbjørg", "Øystein", "Åslaug", "Tormod", "Borghild" ]
var colors = [ "#DEF", "#DFE", "#FDE", "#EDF", "#EFD", "#FED" ]
exports.data1 = Observable()
function create() {
var list = []
for (var i=0; i < names.length; ++i ) {
var c = Math.random() * 100 + 10
list.push( new Item( c, Math.random(), names[i], colors[i] ) )
}
return list
}
exports.random = function() {
exports.data1.replaceAll( create() )
}
exports.random()
</JavaScript>
<AttractorConfig Unit="Normalized" Type="Elastic" ux:Global="pieAttract"/>
<ChartButton Alignment="TopRight" Margin="5" Clicked="{random}" Label="✧"/>
<c:Plot Margin="5,20,20,10">
<c:DataSeries Data="{data1}"/>
<Panel BoxSizing="FillAspect" Margin="30">
<c:PlotData>
<c:PlotPoint Style="Radial" PointOffset="0.05" Attractor="pieAttract">
<Text Value="{Plot data.label}"/>
</c:PlotPoint>
</c:PlotData>
<VectorLayer HitTestMode="None">
<c:PlotData>
<!-- arcs to show Z-axis data -->
<Panel Width="attract({Plot data.source.z},pieAttract) * 100%"
Height="attract({Plot data.source.z},pieAttract) * 100%">
<Arc
StartAngleDegrees="attract({Plot data.accumulatedWeight.y},pieAttract)*360"
EndAngleDegrees="attract({Plot data.cumulativeWeight.y},pieAttract)*360"
StrokeColor="#488" StrokeWidth="2"/>
</Panel>
<c:PlotWedge Color="{Plot data.object}.color" StrokeColor="#488" StrokeWidth="1"
Attractor="pieAttract"/>
</c:PlotData>
</VectorLayer>
</Panel>
</c:Plot>
</ChartPage>