Changeset 6242 for branches/WebApplication
- Timestamp:
- 05/20/11 20:58:46 (14 years ago)
- Location:
- branches/WebApplication/MVC2/HLWebOKBQueryPlugin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/ChartController.cs
r6171 r6242 33 33 QueryServiceClient client = Query.GetClientFactory("okbtester", "okbtester"); 34 34 35 long[] runIds = new long[ 5];36 for (int i = 0; i < 5; i++) {35 long[] runIds = new long[104]; 36 for (int i = 0; i < 104; i++) { 37 37 runIds[i] = i; 38 38 } 39 39 Run[] runs = client.GetRuns(runIds, false); 40 40 //cm.Runs = runs; 41 41 cm.UpdateRunCollection(runs); 42 42 cm.UpdateBubbleChart(selectedAxisY, selectedAxisX, selectedBubbleSize); … … 49 49 public FileResult CreateBubbleChart(ChartModel model) 50 50 { 51 IList<int> items = new List<int>(); 52 53 items.Add(1); 54 items.Add(2); 55 items.Add(5); 56 items.Add(10); 51 //IList<int> items = new List<int>(); 52 //items.Add(1); 53 //items.Add(2); 54 //items.Add(5); 55 //items.Add(10); 57 56 58 57 Chart chart = new Chart(); … … 72 71 chart.Titles.Add("Bubble Chart"); 73 72 //chart.Legends.Add(CreateLegend()); 74 chart.Series.Add(CreateSeries( items,SeriesChartType.Bubble));73 chart.Series.Add(CreateSeries(model,SeriesChartType.Bubble)); 75 74 chart.ChartAreas.Add(CreateChartArea()); 76 77 75 78 76 … … 82 80 } 83 81 84 85 86 public Series CreateSeries(IList<int> results, SeriesChartType chartType) 82 private Dictionary<string, Dictionary<object, double>> categoricalMap = new Dictionary<string,Dictionary<object,double>>(); 83 private Dictionary<string, Dictionary<object, double>> CategoricalMap { 84 get { return categoricalMap; } 85 set { categoricalMap = value; } 86 } 87 88 private double GetCategoricalValue(string columnName, string value) { 89 if (!this.CategoricalMap.ContainsKey(columnName)) { 90 this.CategoricalMap[columnName] = new Dictionary<object, double>(); 91 } 92 if (!this.CategoricalMap[columnName].ContainsKey(value)) { 93 if (this.CategoricalMap[columnName].Values.Count == 0) { 94 this.CategoricalMap[columnName][value] = 1.0; 95 } 96 else { 97 this.CategoricalMap[columnName][value] = this.CategoricalMap[columnName].Values.Max() + 1.0; 98 } 99 } 100 return this.CategoricalMap[columnName][value]; 101 } 102 103 private double? GetValue(Run run, String columnName) { 104 if ((run == null) || string.IsNullOrEmpty(columnName)) { 105 return null; 106 } 107 Value value = run.ResultValues.FirstOrDefault(x => x.Name == columnName); 108 109 if (value == null) { 110 return null; 111 } 112 113 DoubleValue doubleValue = value as DoubleValue; 114 IntValue intValue = value as IntValue; 115 BoolValue boolValue = value as BoolValue; 116 FloatValue floatValue = value as FloatValue; 117 BinaryValue binaryValue = value as BinaryValue; 118 LongValue longValue = value as LongValue; 119 StringValue stringValue = value as StringValue; 120 121 double? ret = null; 122 if (doubleValue != null) { 123 if (!double.IsNaN(doubleValue.Value) && !double.IsInfinity(doubleValue.Value)) { 124 ret = doubleValue.Value; 125 } 126 } 127 else if (intValue != null) { 128 ret = intValue.Value; 129 } 130 else if (floatValue != null) { 131 ret = floatValue.Value; 132 } 133 else if (longValue != null) { 134 ret = longValue.Value; 135 } 136 else { 137 ret = GetCategoricalValue(columnName, value.ToString()); 138 } 139 return ret; 140 } 141 142 public Series CreateSeries(ChartModel model, SeriesChartType chartType) 87 143 { 88 144 Series seriesDetail = new Series(); … … 94 150 DataPoint point; 95 151 96 foreach (int result in results) 97 { 98 point = new DataPoint(); 99 point.AxisLabel = result.ToString(); 100 point.YValues = new double[] { (double)result }; 101 seriesDetail.Points.Add(point); 102 } 152 foreach (Run run in model.Runs) { 153 double? xValue, yValue, sValue; 154 xValue = GetValue(run, model.xAxisValue); 155 yValue = GetValue(run, model.yAxisValue); 156 sValue = GetValue(run, model.sizeAxisValue); 157 158 if (xValue.HasValue && yValue.HasValue && sValue.HasValue) { 159 xValue = xValue.Value; 160 yValue = yValue.Value; 161 sValue = sValue.Value; 162 double[] yValues = { (double)yValue, (double)sValue }; 163 point = new DataPoint(xValue.Value, yValues); 164 point.Tag = run; 165 point.MarkerStyle = MarkerStyle.Circle; 166 point.Color = Color.Blue; ; 167 seriesDetail.Points.Add(point); 168 } 169 } 170 171 //foreach (int result in results) 172 //{ 173 // point = new DataPoint(); 174 // point.AxisLabel = result.ToString(); 175 // point.YValues = new double[] { (double)result }; 176 // seriesDetail.Points.Add(point); 177 //} 103 178 seriesDetail.ChartArea = "Result Chart"; 104 179 return seriesDetail; … … 154 229 ChartModel cm = new ChartModel(); 155 230 231 //// Later, we will get the runs from the session ... 232 //QueryServiceClient client = Query.GetClientFactory("okbtester", "okbtester"); 233 234 //long[] runIds = new long[5]; 235 //for (int i = 0; i < 5; i++) { 236 // runIds[i] = i; 237 //} 238 //Run[] runs = client.GetRuns(runIds, false); 239 ////cm.Runs = runs; 240 //cm.UpdateRunCollection(runs); 241 ////cm.UpdateBubbleChart(selectedAxisY, selectedAxisX, selectedBubbleSize); 242 156 243 return PartialView("BubbleChart", cm); // name of usercontrol 157 244 } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/ChartModel.cs
r6165 r6242 14 14 15 15 private Color DataPointColor = System.Drawing.Color.Black; 16 private String xAxisValue; 17 private String yAxisValue; 18 private String sizeAxisValue; 16 //private String xAxisValue; 17 //private String yAxisValue; 18 //private String sizeAxisValue; 19 20 public String xAxisValue { 21 get { return (HttpContext.Current.Session["xAxisValue"] == null) ? null : (String)HttpContext.Current.Session["xAxisValue"]; } 22 set { HttpContext.Current.Session["xAxisValue"] = value; } 23 } 24 public String yAxisValue { 25 get { return (HttpContext.Current.Session["yAxisValue"] == null) ? null : (String)HttpContext.Current.Session["yAxisValue"]; } 26 set { HttpContext.Current.Session["yAxisValue"] = value; } 27 } 28 public String sizeAxisValue { 29 get { return (HttpContext.Current.Session["sizeAxisValue"] == null) ? null : (String)HttpContext.Current.Session["sizeAxisValue"]; } 30 set { HttpContext.Current.Session["sizeAxisValue"] = value; } 31 } 32 19 33 20 34 private Dictionary<string, Dictionary<object, double>> CategoricalMap { … … 23 37 } 24 38 39 //public Run[] Runs { 40 // set; 41 // get; 42 // // { 43 // //UpdateComboBoxValues(value); 44 45 // //} 46 //} 47 25 48 public Run[] Runs { 26 set; 27 get; 28 // { 29 //UpdateComboBoxValues(value); 30 31 //} 49 get { return (HttpContext.Current.Session["runs"] == null) ? null : (Run[])HttpContext.Current.Session["runs"]; } 50 set { HttpContext.Current.Session["runs"] = value; } 32 51 } 33 52
Note: See TracChangeset
for help on using the changeset viewer.