- Timestamp:
- 05/09/11 22:42:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/ChartController.cs
r6165 r6171 7 7 using HLWebOKBQueryPlugin.Helpers; 8 8 using HLWebOKBQueryPlugin.OKBQueryService; 9 using System.Web.UI.DataVisualization.Charting; 10 using System.Drawing; 11 using System.IO; 9 12 10 13 namespace HLWebOKBQueryPlugin.Controllers { … … 43 46 44 47 48 49 public FileResult CreateBubbleChart(ChartModel model) 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); 57 58 Chart chart = new Chart(); 59 chart.Width = 700; 60 chart.Height = 300; 61 chart.BackColor = Color.FromArgb(211, 223, 240); 62 chart.BorderlineDashStyle = ChartDashStyle.Solid; 63 chart.BackSecondaryColor = Color.White; 64 chart.BackGradientStyle = GradientStyle.TopBottom; 65 chart.BorderlineWidth = 1; 66 chart.Palette = ChartColorPalette.BrightPastel; 67 chart.BorderlineColor = Color.FromArgb(26, 59, 105); 68 chart.RenderType = RenderType.BinaryStreaming; 69 chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss; 70 chart.AntiAliasing = AntiAliasingStyles.All; 71 chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal; 72 chart.Titles.Add("Bubble Chart"); 73 //chart.Legends.Add(CreateLegend()); 74 chart.Series.Add(CreateSeries(items,SeriesChartType.Bubble)); 75 chart.ChartAreas.Add(CreateChartArea()); 76 77 78 79 MemoryStream ms = new MemoryStream(); 80 chart.SaveImage(ms); 81 return File(ms.GetBuffer(), @"image/png"); 82 } 83 84 85 86 public Series CreateSeries(IList<int> results, SeriesChartType chartType) 87 { 88 Series seriesDetail = new Series(); 89 seriesDetail.Name = "Result Chart"; 90 seriesDetail.IsValueShownAsLabel = false; 91 seriesDetail.Color = Color.FromArgb(198, 99, 99); 92 seriesDetail.ChartType = chartType; 93 seriesDetail.BorderWidth = 2; 94 DataPoint point; 95 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 } 103 seriesDetail.ChartArea = "Result Chart"; 104 return seriesDetail; 105 } 106 107 108 109 public ChartArea CreateChartArea() 110 { 111 ChartArea chartArea = new ChartArea(); 112 chartArea.Name = "Result Chart"; 113 chartArea.BackColor = Color.Transparent; 114 chartArea.AxisX.IsLabelAutoFit = false; 115 chartArea.AxisY.IsLabelAutoFit = false; 116 chartArea.AxisX.LabelStyle.Font = 117 new Font("Verdana,Arial,Helvetica,sans-serif", 118 8F, FontStyle.Regular); 119 chartArea.AxisY.LabelStyle.Font = 120 new Font("Verdana,Arial,Helvetica,sans-serif", 121 8F, FontStyle.Regular); 122 chartArea.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64); 123 chartArea.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64); 124 chartArea.AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64); 125 chartArea.AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64); 126 chartArea.AxisX.Interval = 1; 127 128 return chartArea; 129 } 130 131 132 133 45 134 public ActionResult Index() { 46 135 ChartModel cm = new ChartModel();
Note: See TracChangeset
for help on using the changeset viewer.