1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Text;
|
---|
4 | using JsonFx.Json;
|
---|
5 |
|
---|
6 |
|
---|
7 | namespace OpenFlashChart
|
---|
8 | {
|
---|
9 | public class PieValue
|
---|
10 | {
|
---|
11 | private double val;
|
---|
12 | private string text;
|
---|
13 | private string click;
|
---|
14 | public PieValue(double val)
|
---|
15 | {
|
---|
16 | this.val = val;
|
---|
17 | }
|
---|
18 | public static implicit operator PieValue(double val)
|
---|
19 | {
|
---|
20 | return new PieValue(val,"");
|
---|
21 | }
|
---|
22 | public PieValue(double val, string text)
|
---|
23 | {
|
---|
24 | this.val = val;
|
---|
25 | this.Text = text;
|
---|
26 | }
|
---|
27 | [JsonProperty("value")]
|
---|
28 | public double Value
|
---|
29 | {
|
---|
30 | get { return val; }
|
---|
31 | set { val = value; }
|
---|
32 | }
|
---|
33 | [JsonProperty("label")]
|
---|
34 | public string Text
|
---|
35 | {
|
---|
36 | get { return text; }
|
---|
37 | set { text = value; }
|
---|
38 | }
|
---|
39 | [JsonProperty("on-click")]
|
---|
40 | public string Click
|
---|
41 | {
|
---|
42 | get { return click; }
|
---|
43 | set { click = value; }
|
---|
44 | }
|
---|
45 | }
|
---|
46 | public class Pie : Chart<PieValue>
|
---|
47 | {
|
---|
48 | private int border;
|
---|
49 | private IEnumerable<String> colours;
|
---|
50 | private double alpha;
|
---|
51 | private PieAnimationSeries animate;
|
---|
52 | private double start_angle;
|
---|
53 | private bool? gradientfill;
|
---|
54 | private bool? nolabels;
|
---|
55 |
|
---|
56 | public Pie()
|
---|
57 | {
|
---|
58 | this.ChartType = "pie";
|
---|
59 | this.border = 2;
|
---|
60 | this.colours = new string[] { "#d01f3c", "#356aa0", "#C79810" };
|
---|
61 | this.alpha = 0.6;
|
---|
62 | //this.animate = true;
|
---|
63 | //gradientfill = true;
|
---|
64 |
|
---|
65 | }
|
---|
66 | [JsonProperty("colours")]
|
---|
67 | public IEnumerable<string> Colours
|
---|
68 | {
|
---|
69 | get { return this.colours; }
|
---|
70 | set
|
---|
71 | {
|
---|
72 | this.colours = value;
|
---|
73 | }
|
---|
74 | }
|
---|
75 | [JsonProperty("border")]
|
---|
76 | public int Border
|
---|
77 | {
|
---|
78 | get { return border; }
|
---|
79 | set { border = value; }
|
---|
80 | }
|
---|
81 | [JsonProperty("alpha")]
|
---|
82 | public double Alpha
|
---|
83 | {
|
---|
84 | get { return alpha; }
|
---|
85 | set
|
---|
86 | {
|
---|
87 | if (value < 0)
|
---|
88 | alpha = 0;
|
---|
89 | else if ((value >= 0) && (value <= 1))
|
---|
90 | alpha = value;
|
---|
91 | else if ((value > 1)&&(value<=100))
|
---|
92 | alpha = value/100;
|
---|
93 | else
|
---|
94 | alpha = 1.0;
|
---|
95 | }
|
---|
96 | }
|
---|
97 | [JsonProperty("animate")]
|
---|
98 | public PieAnimationSeries Animate
|
---|
99 | {
|
---|
100 | get { return animate; }
|
---|
101 | set { animate = value; }
|
---|
102 | }
|
---|
103 | [JsonProperty("start-angle")]
|
---|
104 | public double StartAngle
|
---|
105 | {
|
---|
106 | get { return start_angle; }
|
---|
107 | set { start_angle = value; }
|
---|
108 | }
|
---|
109 | [JsonProperty("gradient-fill")]
|
---|
110 | public bool? GradientFillMode
|
---|
111 | {
|
---|
112 | get { return gradientfill; }
|
---|
113 | set { gradientfill = value; }
|
---|
114 | }
|
---|
115 | [JsonProperty("no-labels")]
|
---|
116 | public bool? NoLabels
|
---|
117 | {
|
---|
118 | get { return nolabels; }
|
---|
119 | set { nolabels = value; }
|
---|
120 | }
|
---|
121 | }
|
---|
122 | }
|
---|