source: code/Website/dot-net-library/written-by-xiao-yifang/OpenFlashChart/OpenFlashChart.cs

Last change on this file was 7849, checked in by dennisw, 15 years ago
File size: 5.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Globalization;
4using System.IO;
5using System.Text;
6using JsonFx.Json;
7using OpenFlashChart;
8
9namespace OpenFlashChart
10{
11 public class OpenFlashChart
12 {
13 private Title title;
14 private IList<ChartBase> elements;
15 private XAxis x_axis;
16 private YAxis y_axis;
17 private YAxis y_axis_right;
18 private Legend x_legend;
19 private Legend y_legend;
20 private Legend y2_legend;
21 private string bgcolor;
22 private RadarAxis radar_axis;
23 private ToolTip tooltip;
24 private int? num_decimals;
25 private bool? is_fixed_num_decimals_forced;
26 private bool? is_decimal_separator_comma;
27 private bool? is_thousand_separator_disabled;
28
29 public OpenFlashChart()
30 {
31 title = new Title("Chart Title");
32 Elements = new List<ChartBase>();
33 //x_axis = new XAxis();
34 //y_axis= new YAxis();
35 //y_axis_right = new YAxis();
36 }
37 [JsonProperty("title")]
38 public Title Title
39 {
40 set { this.title = value; }
41 get { return this.title; }
42 }
43 [JsonProperty("x_axis")]
44 public XAxis X_Axis
45 {
46 get
47 {
48 if(x_axis==null)
49 x_axis= new XAxis();
50 return this.x_axis;
51 }
52 set{ this.x_axis = value;}
53 }
54 [JsonProperty("y_axis")]
55 public YAxis Y_Axis
56 {
57 get
58 {
59 if(y_axis==null)
60 y_axis= new YAxis();
61 return this.y_axis;
62 }
63 set { this.y_axis = value; }
64 }
65 [JsonProperty("y_axis_right")]
66 public YAxis Y_Axis_Right
67 {
68 get
69 {
70 return y_axis_right;
71 }
72 set { y_axis_right = value; }
73 }
74 [JsonProperty("elements")]
75 public IList<ChartBase> Elements
76 {
77 get { return elements; }
78 set { elements = value; }
79 }
80 public void AddElement(ChartBase chart)
81 {
82 this.elements.Add(chart);
83 //Y_Axis.SetRange(chart.GetMinValue(), chart.GetMaxValue());
84 // X_Axis.SetRange(0,chart.GetValueCount());
85 X_Axis.Steps = 1;
86 }
87 [JsonProperty("x_legend")]
88 public Legend X_Legend
89 {
90 get { return x_legend; }
91 set { x_legend = value; }
92 }
93 [JsonProperty("y_legend")]
94 public Legend Y_Legend
95 {
96 get { return y_legend; }
97 set { y_legend = value; }
98 }
99 [JsonProperty("y2_legend")]
100 public Legend Y_RightLegend
101 {
102 get { return y2_legend; }
103 set { y2_legend = value; }
104 }
105 [JsonProperty("bg_colour")]
106 public string Bgcolor
107 {
108 get { return bgcolor; }
109 set { bgcolor = value; }
110 }
111 [JsonProperty("tooltip")]
112 public ToolTip Tooltip
113 {
114 get { return tooltip; }
115 set { tooltip = value; }
116 }
117 [JsonProperty("radar_axis")]
118 public RadarAxis Radar_Axis
119 {
120 get
121 {
122 return this.radar_axis;
123 }
124 set { this.radar_axis = value; }
125 }
126 [JsonProperty("num_decimals")]
127 public int? NumDecimals
128 {
129 get { return num_decimals; }
130 set { num_decimals = value; }
131 }
132 [JsonProperty("is_fixed_num_decimals_forced")]
133 public bool? IsFixedNumDecimalsForced
134 {
135 get { return is_fixed_num_decimals_forced; }
136 set { is_fixed_num_decimals_forced = value; }
137 }
138 [JsonProperty("is_decimal_separator_comma")]
139 public bool? IsDecimalSeparatorComma
140 {
141 get { return is_decimal_separator_comma; }
142 set { is_decimal_separator_comma = value; }
143 }
144 [JsonProperty("is_thousand_separator_disabled")]
145 public bool? IsThousandSeparatorDisabled
146 {
147 get { return is_thousand_separator_disabled; }
148 set { is_thousand_separator_disabled = value; }
149 }
150
151 public override string ToString()
152 {
153 StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
154 using (JsonWriter writer = new JsonWriter(sw))
155 {
156 writer.SkipNullValue = true;
157 writer.Write(this);
158 }
159 return sw.ToString();
160 }
161
162 public string ToPrettyString()
163 {
164 StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
165 using (JsonWriter writer = new JsonWriter(sw))
166 {
167 writer.SkipNullValue = true;
168 writer.PrettyPrint = true;
169 writer.Write(this);
170 }
171 return sw.ToString();
172 }
173 }
174}
Note: See TracBrowser for help on using the repository browser.