public FileResult GetSaleRankChart() { var gQuery = (from m in orderDetailRepo.GetWithFilterAndOrder() group m by m.Meal.MealName into g orderby g.Sum(item => item.Quantity * 1) descending select new Group<string, int> { Key = g.Key, Value = g.Sum(item=> item.Quantity * 1) }) .Take(5); var chart = new Chart(); chart.ChartAreas.Add(new ChartArea("Default")); chart.Width = 500; chart.Height = 400; chart.ChartAreas["Default"].Area3DStyle.Enable3D = true; chart.ChartAreas["Default"].Area3DStyle.Inclination = 15; chart.ChartAreas["Default"].Area3DStyle.Rotation = 15; chart.Series.Add(new Series("Data")); foreach (var item in gQuery) { chart.Series["Data"].Points.AddXY(item.Key, item.Value); } System.IO.MemoryStream ms = new System.IO.MemoryStream(); chart.SaveImage(ms, ChartImageFormat.Png); ms.Seek(0, System.IO.SeekOrigin.Begin); return File(ms, "image/png"); }
// Initiate the chart to be rendered private Chart InitiateChart(int width, int height) { var chart = new Chart(); chart.Width = width; chart.Height = height; chart.BorderSkin.BackColor = System.Drawing.Color.Transparent; chart.BorderSkin.PageColor = System.Drawing.Color.Transparent; chart.BackColor = System.Drawing.Color.FromArgb(211, 223, 240); chart.BorderlineDashStyle = ChartDashStyle.Solid; chart.BackSecondaryColor = System.Drawing.Color.White; chart.BackGradientStyle = GradientStyle.TopBottom; chart.BorderlineWidth = 1; chart.Palette = ChartColorPalette.BrightPastel; chart.BorderlineColor = System.Drawing.Color.FromArgb(26, 59, 105); chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss; chart.AntiAliasing = AntiAliasingStyles.All; chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal; AddChartTitle(); if (ChartTitle != null) { chart.Titles.Add(CreateTitle()); } chart.Legends.Add(CreateLegend()); AddChartSeries(); foreach (var series in ChartSeriesData) { chart.Series.Add(series); } chart.ChartAreas.Add(CreateChartArea()); return chart; }
public static object GetUrlFromChart(this HtmlHelper helper, Chart chart) { string path = "~/Images/graphs/"; string filename = path + Guid.NewGuid(); chart.ToWebImage("jpeg").Save(filename); return ".." + filename.Substring(1) + ".jpeg"; }
private FileContentResult ReturnChart(Chart chart) { var stream = new MemoryStream(); chart.SaveImage(stream, ChartImageFormat.Png); stream.Position = 0; return File(stream.GetBuffer(), "image/png"); }
public MemoryStream BuildChart(int? type, IDictionary<string, float> dataPoints) { // default to line var chartType = type == null ? SeriesChartType.Line : (SeriesChartType)type; var chart = new Chart(); // configure your chart area (dimensions, etc) here. var area = new ChartArea(); chart.ChartAreas.Add(area); TickMark tm = new TickMark(); // create and customize your data series. var series = new Series(); foreach (var item in dataPoints) { series.Points.AddXY(item.Key, item.Value); } //series.Label = "#PERCENT{P0}"; series.Font = new Font("Segoe UI", 8.0f, FontStyle.Bold); series.ChartType = chartType; series["PieLabelStyle"] = "Outside"; chart.Series.Add(series); var returnStream = new MemoryStream(); chart.ImageType = ChartImageType.Png; chart.SaveImage(returnStream); returnStream.Position = 0; return returnStream; }
public static Chart LineChart() { Chart chart = new Chart(ChartType.Line); Series series = chart.SeriesCollection.AddSeries(); series.Name = "Series 1"; series.Add(new double[] { 1, 5, -3, 20, 11 }); series = chart.SeriesCollection.AddSeries(); series.Name = "Series 2"; series.Add(new double[] { 22, 4, 12, 8, 12 }); series = chart.SeriesCollection.AddSeries(); series.Name = "Series 3"; series.Add(new double[] { 12, 14, -3, 18, 1 }); chart.XAxis.MajorTickMark = TickMarkType.Outside; chart.XAxis.Title.Caption = "X-Axis"; chart.YAxis.MajorTickMark = TickMarkType.Outside; chart.YAxis.Title.Caption = "Y-Axis"; chart.YAxis.HasMajorGridlines = true; chart.PlotArea.LineFormat.Color = XColors.DarkGray; chart.PlotArea.LineFormat.Width = 1; chart.PlotArea.LineFormat.Visible = true; chart.Legend.Docking = DockingType.Bottom; chart.Legend.LineFormat.Visible = true; XSeries xseries = chart.XValues.AddXSeries(); xseries.Add("A", "B", "C", "D", "E", "F"); return chart; }
public void drawing(bufferedLockBitmap pixel, Chart chart1) { int R, G, B; for (int i = 0; i < pixel.Height; i++) { for (int j = 0; j <pixel.Width; j++) { R = pixel.Getpixel(j,i).R; Rarray[R]++; G = pixel.Getpixel(j, i).G; Garray[G]++; B = pixel.Getpixel(j, i).B; Barray[B]++; } } chart1.Series["Red"].Points.Clear(); chart1.Series["Green"].Points.Clear(); chart1.Series["Blue"].Points.Clear(); for (int w = 0; w < 256; w++) { chart1.Series["Red"].Points.AddXY(w, this.Rarray[w]); chart1.Series["Green"].Points.AddXY(w, this.Garray[w]); chart1.Series["Blue"].Points.AddXY(w, this.Barray[w]); } chart1.Series["Green"].ChartType = SeriesChartType.SplineArea; chart1.Series["Green"].Color = Color.Green; chart1.Series["Red"].ChartType = SeriesChartType.SplineArea; chart1.Series["Red"].Color = Color.Red; chart1.Series["Blue"].ChartType = SeriesChartType.SplineArea; chart1.Series["Blue"].Color = Color.Blue; }
public void Create_LinearChart_WithYAxis() { var chart = new Chart<DateTime, double>(); var linearY = chart.GetLinearY(10d); Assert.NotNull(linearY); }
/// <summary> /// Called at the start of your algorithm to setup your requirements: /// </summary> public override void Initialize() { //Set the date range you want to run your algorithm: SetStartDate(startDate); SetEndDate(endDate); //Set the starting cash for your strategy: SetCash(100000); //Add any stocks you'd like to analyse, and set the resolution: // Find more symbols here: http://quantconnect.com/data AddSecurity(SecurityType.Equity, "SPY", resolution: Resolution.Minute); //Chart - Master Container for the Chart: Chart stockPlot = new Chart("Trade Plot"); //On the Trade Plotter Chart we want 3 series: trades and price: Series buyOrders = new Series("Buy", SeriesType.Scatter, 0); Series sellOrders = new Series("Sell", SeriesType.Scatter, 0); Series assetPrice = new Series("Price", SeriesType.Line, 0); stockPlot.AddSeries(buyOrders); stockPlot.AddSeries(sellOrders); stockPlot.AddSeries(assetPrice); AddChart(stockPlot); Chart avgCross = new Chart("Strategy Equity"); Series fastMA = new Series("FastMA", SeriesType.Line, 1); Series slowMA = new Series("SlowMA", SeriesType.Line, 1); avgCross.AddSeries(fastMA); avgCross.AddSeries(slowMA); AddChart(avgCross); resamplePeriod = TimeSpan.FromMinutes((endDate - startDate).TotalMinutes / 2000); }
public static void BindData(Chart chart, string prvName, object context, string[] seriesExpr, string labelExpr, string labelLookupName) { var prv = WebManager.GetService<IProvider<object,object>>(prvName); var ognlContext = new Dictionary<string,object>(); ognlContext["data"] = prv.Provide(context); var ognlExpr = new NReco.OGNL.EvalOgnl(); int seriesIdx = 0; foreach (var expr in seriesExpr) { var dataset = (IEnumerable)ognlExpr.Eval( expr, ognlContext ); var series = chart.Series[seriesIdx]; foreach (var val in dataset) { var decVal = Convert.ToDecimal(val); series.Points.AddY(decVal); } seriesIdx++; } /*if (!String.IsNullOrEmpty(labelExpr)) { var labels = (IEnumerable)ognlExpr.Eval( labelExpr, ognlContext ); var labelsList = new List<string>(); var labelPrv = String.IsNullOrEmpty(labelLookupName) ? null : WebManager.GetService<IProvider<object,string>>(labelLookupName); foreach (var lbl in labels) { labelsList.Add( labelPrv!=null ? labelPrv.Provide(lbl) : Convert.ToString(lbl) ); } res += "&"+labelParam+String.Join("|", labelsList.ToArray() ); }*/ }
/// <summary> /// This overloaded constructor creates a chart from the provided ChartConfigProvider /// </summary> /// <param name="ChartConfig">The chart config.</param> /// <param name="ThisPage">The this page.</param> /// <param name="imageMap">if set to <c>true</c> [image map].</param> public ChartBuilder(ChartConfigProvider ChartConfig, Page ThisPage, bool imageMap) { try { currConfig = ChartConfig; chartToBuild = new Chart(); chartToBuild.ChartAreas.Add(new ChartArea()); chartToBuild.Page = ThisPage; XmlDocument xmlData = GetXmlData(); BuildXAxisLabels(xmlData); FillSeriesData(xmlData); SetObjectParameters(chartToBuild, currConfig.ChartParams); SetObjectParameters(chartToBuild.ChartAreas[0], currConfig.ChartAreaParams); SetObjectParameters(chartToBuild.ChartAreas[0].AxisX, currConfig.ChartAxisXParams); SetObjectParameters(chartToBuild.ChartAreas[0].AxisY, currConfig.ChartAxisYParams); SetObjectParameters(chartToBuild.ChartAreas[0].AxisX2, currConfig.ChartAxisX2Params); SetObjectParameters(chartToBuild.ChartAreas[0].AxisY2, currConfig.ChartAxisY2Params); if (currConfig.ChartLegendParams.Count > 0) { Legend l = new Legend(); SetObjectParameters(l, currConfig.ChartLegendParams); chartToBuild.Legends.Add(l); } SetRenderMethod(imageMap); } catch (Exception ex) { throw ex; } }
public ActionResult Input() { List<string> xval = new List<string>(); List<string> yval = new List<string>(); List<string> yval2 = new List<string>(); foreach (var points in db.Users.ToList().OrderByDescending(c => c.Win).Take(9)) { xval.Add(points.Name); yval.Add(points.Input.ToString()); yval2.Add(points.Win.ToString()); } string[] _xval = xval.ToArray(); string[] _yval = yval.ToArray(); string[] _yval2 = yval2.ToArray(); var chartsPoint = new Chart(width: 1000, height: 400, theme: ChartTheme.Blue) //,theme: ChartTheme.Blue .AddSeries( name: "Buy-In", xValue: _xval, yValues: _yval ) .AddSeries( name:"Gewonnen", xValue: _xval, yValues: _yval2) .AddLegend(); return File(chartsPoint.GetBytes("png"), "image/png"); }
private void paintItem(Graphics g, int x, int y, Chart chart) { System.Diagnostics.Debug.Print("{0}\t{1}\t{2}\t{3}\t{4}", chart.m_obj.Name, chart.m_nLineFromX, chart.m_nLineFromY, chart.m_nLineToX, chart.m_nLineToY); g.DrawLine(Pens.Black, x + chart.m_nLineFromX, y + chart.m_nLineFromY, x + chart.m_nLineToX, y + chart.m_nLineToY); foreach (var c in chart._box.Select(_ => _.Value).Where(_ => _ != null)) paintItem(g, x, y, c); }
public static void CreateChart(string imagePath,string name, IEnumerable<BenchResult> results, Func<BenchResult,double> selector) { Chart chart = new Chart(); chart.Width = 500; chart.Height = 400; chart.Titles.Add(name); var area = new ChartArea("Default"); chart.ChartAreas.Add(area); var series = new Series("Default"); chart.Series.Add(series); area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep90; area.AxisX.LabelStyle.TruncatedLabels = false; area.AxisX.Interval = 1; series.ChartType = SeriesChartType.Column; series.IsValueShownAsLabel = true; series.XValueType = ChartValueType.String; series.YValueType = ChartValueType.Int32; foreach(var r in results.OrderBy( r => selector(r))) { DataPoint point = new DataPoint(); point.SetValueXY(r.Serializer.Replace("Adapter",""),(int)Math.Round(selector(r))); point.AxisLabel = r.Serializer.Replace("Adapter", ""); series.Points.Add(point); } chart.SaveImage(imagePath, ChartImageFormat.Png); }
/// <summary> /// Setup the basic settings for a chart, all that needs to be added is a series of data. /// </summary> /// <param name="titleText">The title you would like displayed in the graph</param> /// <returns></returns> private Chart PrepChart(string titleText) { var chart = new Chart(); chart.Width = 412; chart.Height = 296; chart.ImageType = ChartImageType.Png; chart.Palette = ChartColorPalette.BrightPastel; chart.BackColor = Color.Cornsilk; chart.RenderType = RenderType.BinaryStreaming; chart.BorderlineDashStyle = ChartDashStyle.Solid; chart.BackGradientStyle = GradientStyle.TopBottom; chart.BorderlineWidth = 2; chart.BorderlineColor = Color.Blue; chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss; chart.AntiAliasing = AntiAliasingStyles.All; chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal; var title = chart.Titles.Add("Main"); title.Text = titleText; title.Docking = Docking.Top; title.Font = new Font(FontFamily.GenericSansSerif, 8.25F, FontStyle.Bold); ChartArea chartArea = chart.ChartAreas.Add("Default"); chartArea.BackColor = Color.Transparent; chartArea.BorderColor = Color.Red; chartArea.AxisX.IsMarginVisible = true; chartArea.Area3DStyle.Enable3D = true; return chart; }
public ActionResult Details(int width = 500, int height = 500) { var chart = new Chart { Height = height, Width = width }; var chartArea = new ChartArea("Area1") { AxisX = { Interval = 1 }, Area3DStyle = { Enable3D = true }, BackColor = Color.Transparent }; chart.ChartAreas.Add(chartArea); chart.BackColor = Color.Transparent; var seriescountAll = new Series("项目统计"); var countAll = _iProjectInfoStateService.GetAll() .Select(a => new { Key = a.ProjectInfoStateName, Count = a.ProjectInfos.Count(b => !b.Deleted) }); seriescountAll.ChartArea = "Area1"; seriescountAll.IsVisibleInLegend = true; seriescountAll.IsValueShownAsLabel = true; seriescountAll.Label = "#VALX #VALY"; seriescountAll.Points.DataBind(countAll, "Key", "Count", ""); seriescountAll.ChartType = SeriesChartType.Funnel; chart.Series.Add(seriescountAll); var imageStream = new MemoryStream(); chart.SaveImage(imageStream, ChartImageFormat.Png); imageStream.Position = 0; return new FileStreamResult(imageStream, "image/png"); }
public void ConstructorLoadsTemplate() { var template = WriteTemplate(@"<Chart BorderWidth=""2""></Chart>"); var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, themePath: template); AssertBuiltChartAction(chart, c => { Assert.AreEqual(2, c.BorderWidth); }); }
public void ConstructorLoadsTheme() { //Vanilla theme /* * <Chart Palette="SemiTransparent" BorderColor="#000" BorderWidth="2" BorderlineDashStyle="Solid"> <ChartAreas> <ChartArea _Template_="All" Name="Default"> <AxisX> <MinorGrid Enabled="False" /> <MajorGrid Enabled="False" /> </AxisX> <AxisY> <MajorGrid Enabled="False" /> <MinorGrid Enabled="False" /> </AxisY> </ChartArea> </ChartAreas> </Chart> */ var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, theme: ChartTheme.Vanilla); AssertBuiltChartAction(chart, c => { Assert.AreEqual(c.Palette, DV.ChartColorPalette.SemiTransparent); Assert.AreEqual(c.BorderColor, Color.FromArgb(0, Color.Black)); Assert.AreEqual(1, c.ChartAreas.Count); Assert.IsFalse(c.ChartAreas[0].AxisX.MajorGrid.Enabled); Assert.IsFalse(c.ChartAreas[0].AxisY.MinorGrid.Enabled); }); }
public void ChartImage() { var products = new[] { new Product {Name = "Kayak", Category = "Watersports", Price = 275m}, new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95m}, new Product {Name = "Soccer ball", Category = "Football", Price = 19.50m}, new Product {Name = "Corner flags", Category = "Football", Price = 34.95m}, new Product {Name = "Thinking cap", Category = "Chess", Price = 16m}, }; Chart chart = new Chart(600, 200, @"<Chart BackColor=""Gray"" BackSecondaryColor=""WhiteSmoke"" BackGradientStyle=""DiagonalRight"" AntiAliasing=""All"" BorderlineDashStyle = ""Solid"" BorderlineColor = ""Gray""> <BorderSkin SkinStyle = ""Emboss"" /> <ChartAreas> <ChartArea Name=""Default"" _Template_=""All"" BackColor=""Wheat"" BackSecondaryColor=""White"" BorderColor=""64, 64, 64, 64"" BorderDashStyle=""Solid"" ShadowColor=""Transparent""> </ChartArea> </ChartAreas> </Chart>"); chart.AddSeries( chartType: "Column", yValues: products.Select(p => p.Price).ToArray(), xValue: products.Select(p => p.Name).ToArray() ); chart.Write(); }
public void BuildChartAddsDefaultArea() { var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100); AssertBuiltChartAction(chart, c => { Assert.AreEqual(1, c.ChartAreas.Count); Assert.AreEqual("Default", c.ChartAreas[0].Name); }); }
public ActionResult Agitator(int Id) { var politicalViews = new List<KeyValuePair<string, int>>(); var agitatorHouses = dataManager.AgitatorHouseRelations.GetAll().Where(ah => ah.AgitatorId == Id && ah.HouseId.HasValue).Select(wh => wh.HouseId.Value).ToList(); var houses = dataManager.Houses.GetAll().Where(h => agitatorHouses.Contains(h.Id) && h.Latitude.HasValue && h.Longitude.HasValue).ToList(); var persons = dataManager.Persons.GetAll().Where(p => houses.Select(x => x.Id).Contains(p.HouseId ?? 0)).ToList(); var voters = dataManager.Voters.GetAll().Where(v => persons.Select(x => x.Id).Contains(v.PersonId ?? 0)).ToList(); var voterPartyRelations = dataManager.VoterPartyRelations.GetAll().ToList(); var parties = voterPartyRelations.Where(vp => voters.Select(x => x.Id).Contains(vp.VoterId ?? 0)) .Select(x => dataManager.Parties.Get(x.PartyId ?? 0)).ToList(); foreach (var house in houses) { var hPersons = persons.Where(x => x.HouseId == house.Id).ToList(); var hVoters = voters.Where(x => hPersons.Select(x2 => x2.Id).Contains(x.PersonId ?? 0)).ToList(); var hVoterPartyRelations = voterPartyRelations.Where(x => hVoters.Select(x2 => x2.Id).Contains(x.VoterId ?? 0)).ToList(); var hParties = parties.Where(x => hVoterPartyRelations.Select(x2 => x2.PartyId).Contains(x.Id)).ToList(); foreach (var hParty in hParties.GroupBy(x => x.Id).Select(x => x.First())) { politicalViews.Add(new KeyValuePair<string, int>(hParty.Name, hVoterPartyRelations.Where(x => x.PartyId == hParty.Id).Count())); } } var chart = new Chart(width: 200, height: 200) .AddSeries( name: "Employee", xValue: politicalViews.Select(p => p.Key).ToArray(), yValues: politicalViews.Select(p => p.Value).ToArray(), chartType: "Pie"); return File(chart.GetBytes(), "image/jpeg"); }
public Chart GetChart() { // Simple pie Chart chart = new Chart(); var yValues = new double[] { 0.3, 0.2, 0.5 }; chart.ChartAreas.Add(new ChartArea()); chart.Palette = ChartColorPalette.None; chart.PaletteCustomColors = new Color[] { Color.FromArgb(111, 174, 21), Color.FromArgb(255, 39, 40), Color.FromArgb(132, 135, 130) }; chart.Height = 500; chart.Width = 500; chart.Series.Add(new Series()); chart.Series[0].ChartType = SeriesChartType.Pie; chart.Series[0].IsValueShownAsLabel = true; chart.Series[0].LabelFormat = "{P0}"; chart.Series[0].Font = new Font("Arial", 34f, FontStyle.Bold); foreach (double y in yValues) { chart.Series[0].Points.AddY(y); } return chart; }
// // GET: /Expense/ChartByMonth /// <summary> /// Shows a bar chart based on the expenses between the /// start and end dates. /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <returns>The bar chart of the expenses by months.</returns> public ActionResult ChartByMonth(DateTime? start, DateTime? end, int width = 600, int height = 400) { if (!end.HasValue) { end = DateTime.Now; } if (!start.HasValue) { start = end.Value.AddYears(-1); } var resultByMonth = from e in db.Expenses.Where(x => start <= x.Date && x.Date <= end).ToList() group e by e.Date.ToString("yyyy. MM.") into expenseGroup select new { Month = expenseGroup.Key, Value = expenseGroup.Sum(e => e.Amount) }; resultByMonth = resultByMonth.OrderBy(x => x.Month); var chart = new Chart(width, height) .AddSeries( chartType: "Column", xValue: resultByMonth.Select(r => r.Month).ToArray(), yValues: resultByMonth.Select(r => r.Value).ToArray()) .Write(format: "png"); return null; }
public ActionResult GetPieChart() { int[] ranges = { 4, 8, 12 }; var query = from value in uploadDataMgr.GetUploadedLive().ToList() .Where(p => p.ScoreTotal != null) .Select(p => p.ScoreTotal) group value by ranges.Where(x => value >= x) .DefaultIfEmpty() .Last() into groups select new { Key = groups.Key, Values = groups }; Dictionary<string, int> dictRiskCat = new Dictionary<string, int>(); foreach (var group in query) { if (group.Key == 0) dictRiskCat.Add("Low Risk", group.Values.Count()); else if (group.Key == 4) dictRiskCat.Add("Medium Risk", group.Values.Count()); else if (group.Key == 8) dictRiskCat.Add("High Risk", group.Values.Count()); } var key = new Chart(width: 300, height: 300) .AddTitle("Risk Summary") .AddSeries( chartType: "Pie", name: "Risk Summary", xValue: dictRiskCat.Keys, yValues: dictRiskCat.Values); return File(key.ToWebImage().GetBytes(), "image/jpeg"); }
protected virtual void AddChartData(Chart chart, List<Series> data) { foreach (Series series in data) { chart.Series.Add(series); } }
public ChartActionResult(Chart chart, ChartImageFormat imageFormat = ChartImageFormat.Png) { if (chart == null) { throw new ArgumentNullException("chart"); } _chart = chart; _imageFormat = imageFormat; }
public ActionResult CreateChartByMonthPerYear(int year) { try { List<int> lstArticlesCount = articleManager.GetArticlesPerMonth(year); string temp = @"<Chart BackColor=""LightGray"" ForeColor=""LightBlue""> <ChartAreas> <ChartArea Name=""Default"" _Template_=""All""> <AxisY> <LabelStyle Font=""Verdana, 15px"" /> </AxisY> <AxisX LineColor=""64, 64, 64, 64"" Interval=""1""> <LabelStyle Font=""Verdana, 14px"" /> </AxisX> </ChartArea> </ChartAreas> </Chart>"; Chart chartPerMonth = new Chart(width: 1000, height: 500, theme: temp).AddTitle(year.ToString()).AddSeries(chartType: "column", xValue: new[] { "Janury", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }, yValues: lstArticlesCount).Write("bmp"); return null; } catch (Exception e) { ViewBag.ErrorTitle = "Server Error"; ViewBag.ErrorDescription = "Please try again later"; return View("~/Views/Shared/ErrorPage.cshtml"); } }
private static Chart InitializeBarGraph(SeriesCollection seriesCollection, string yAxisTitle) { var chart = new Chart(); //chart.Title = "Burndown"; chart.Type = ChartType.Combo; chart.TempDirectory = VirtualPathUtility.ToAbsolute("~/file/chart"); chart.SeriesCollection.Add(seriesCollection); chart.YAxis.Label.Text = yAxisTitle; chart.YAxis.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC"); chart.YAxis.DefaultTick.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC"); chart.XAxis.DefaultTick.Label.Color = System.Drawing.ColorTranslator.FromHtml("#CCCCCC"); chart.LegendBox.Visible = false; chart.BorderStyle = System.Web.UI.WebControls.BorderStyle.None; chart.TitleBox.Visible = false; chart.Background.Color = System.Drawing.ColorTranslator.FromHtml("#333333"); chart.DefaultSeries.Element.Color = System.Drawing.ColorTranslator.FromHtml("#1B12A6"); chart.DefaultElement.Color = System.Drawing.ColorTranslator.FromHtml("#1B12A6"); chart.Width = new System.Web.UI.WebControls.Unit(600, System.Web.UI.WebControls.UnitType.Pixel); chart.Height = new System.Web.UI.WebControls.Unit(400, System.Web.UI.WebControls.UnitType.Pixel); chart.Font.Name = "Helvetica"; chart.Font.Size = new System.Web.UI.WebControls.FontUnit(24, System.Web.UI.WebControls.UnitType.Pixel); chart.YAxis.Label.Font = new System.Drawing.Font("Helvetica", 8); chart.YAxis.DefaultTick.Label.Font = new System.Drawing.Font("Helvetica", 8); chart.XAxis.DefaultTick.Label.Font = new System.Drawing.Font("Helvetica", 8); //NOTE: needed to do this for the old version of .net charting (3.4). chart.FileManager.TempDirectory = VirtualPathUtility.ToAbsolute("~/file/chart"); chart.FileManager.SaveImage(chart.GetChartBitmap()); //chart.FileManager.FileName = chart.FileManager.TempDirectory + "/" + chart.FileManager.FileName + ".png"; return chart; }
public FileStreamResult Weight(int timeFrame = 0) { var weightChart = new Chart { Width = 600, Height = 300 }; var weights = _repository.GetWeightsByUser(User.Identity.Name); if (timeFrame > 0) { timeFrame = timeFrame * -1; var pastDate = DateTime.Today.AddMonths(timeFrame); weights = weights.Where(w => w.WeightDate > pastDate); } weights = weights.OrderBy(w => w.WeightDate); var builder = new DailyWeightChartBuilder(weights.ToList(), weightChart); builder.BuildChart(); // Save the chart to a MemoryStream var imgStream = new MemoryStream(); weightChart.SaveImage(imgStream, ChartImageFormat.Png); imgStream.Seek(0, SeekOrigin.Begin); // Return the contents of the Stream to the client return File(imgStream, "image/png"); }
public static Chart GenerateBarChart(IList<LogStatistic<DateTime, int>> values, int width, int height) { Chart ch = new Chart(); ch.ChartAreas.Add(new ChartArea()); List<string> dates = new List<string>(); List<int> counts = new List<int>(); foreach (var tuple in values) { dates.Add(tuple.Key.Date.ToShortDateString()); counts.Add(tuple.Value); } int[] yval = counts.ToArray(); // Initialize an array of strings string[] xval = dates.ToArray(); Series series = new Series("Default"); series.ChartType = SeriesChartType.Bar; // Add series into the chart's series collection ch.Series.Add(series); // Bind the double array to the Y axis points of the Default data series ch.Series["Default"].Points.DataBindXY(xval, yval); ch.Width = width; ch.Height = height; return ch; }
public bool IsTrendChartDrawn() { return(Chart.HasDrawnTrend()); }
private int _lines = 64; // number of spectrum lines //ctor public Analyzer(ProgressBar left, ProgressBar right, Spectrum spectrum, ComboBox devicelist, Chart chart) { _fft = new float[8192]; _lastlevel = 0; _hanctr = 0; _t = new DispatcherTimer(); _t.Tick += _t_Tick; _t.Interval = TimeSpan.FromMilliseconds(25); //40hz refresh rate//25 _t.IsEnabled = false; _l = left; _r = right; _l.Minimum = 0; _r.Minimum = 0; _r.Maximum = (ushort.MaxValue); _l.Maximum = (ushort.MaxValue); _process = new WASAPIPROC(Process); _spectrumdata = new List <byte>(); _spectrum = spectrum; _chart = chart; _devicelist = devicelist; _initialized = false; chart.Series.Add("wave"); chart.Series["wave"].ChartType = SeriesChartType.FastLine; chart.Series["wave"].ChartArea = "ChartArea1"; chart.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false; chart.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false; chart.ChartAreas["ChartArea1"].AxisY.Maximum = 255; chart.ChartAreas["ChartArea1"].AxisY.Minimum = 0; chart.ChartAreas["ChartArea1"].AxisX.Maximum = 64; chart.ChartAreas["ChartArea1"].AxisX.Minimum = 0; for (int i = 0; i < chart.ChartAreas["ChartArea1"].AxisX.Maximum; i++) { chart.Series["wave"].Points.Add(0); } Init(); }
protected void GetApproachXAxisChart(Models.Signal signal, Chart chart) { Series series = GetApproachXAxisApproachSeries(signal, 0); chart.Series.Add(series); }
protected void GetSignalsXAxisPhaseNumberSeriesChart(List <Models.Signal> signals, Chart chart) { var availablePhaseNumbers = new List <int>(); foreach (var signal in signals) { availablePhaseNumbers.AddRange(signal.GetPhasesForSignal()); } availablePhaseNumbers = availablePhaseNumbers.Distinct().ToList(); var colorCode = 1; foreach (var phaseNumber in availablePhaseNumbers) { var seriesName = "Phase " + phaseNumber; Series series = GetSignalXAxisPhaseNumberSeries(signals, colorCode, phaseNumber, seriesName); colorCode++; chart.Series.Add(series); } }
protected void GetSignalsXAxisDirectionSeriesChart(List <Models.Signal> signals, Chart chart) { var availableDirections = new List <DirectionType>(); foreach (var signal in signals) { availableDirections.AddRange(signal.GetAvailableDirections()); } availableDirections = availableDirections.Distinct().ToList(); var colorCode = 1; foreach (var directionType in availableDirections) { var seriesName = directionType.Description; var series = CreateSeries(colorCode, seriesName); foreach (var signal in signals) { var binsContainers = GetBinsContainersByDirection(directionType, signal); var dataPoint = new DataPoint(); dataPoint.SetValueY(SelectedAggregationType == AggregationType.Sum ? binsContainers.Sum(b => b.SumValue) : Convert.ToInt32(Math.Round(binsContainers.Sum(b => b.SumValue) / (double)availableDirections.Count))); dataPoint.AxisLabel = signal.SignalDescription; series.Points.Add(dataPoint); } colorCode++; chart.Series.Add(series); } }
protected override void GetTimeCharts() { Chart chart = null; switch (SelectedSeries) { case SeriesType.PhaseNumber: foreach (var signal in Signals) { chart = ChartFactory.CreateTimeXIntYChart(this, new List <Models.Signal> { signal }); GetTimeXAxisApproachSeriesChart(signal, chart); if (ShowEventCount) { SetTimeXAxisSignalSeriesForEventCount(chart, signal); } SaveChartImage(chart); } break; case SeriesType.Direction: foreach (var signal in Signals) { chart = ChartFactory.CreateTimeXIntYChart(this, new List <Models.Signal> { signal }); GetTimeXAxisDirectionSeriesChart(signal, chart); if (ShowEventCount) { SetTimeXAxisSignalSeriesForEventCount(chart, signal); var eventCountOptions = (ApproachEventCountAggregationOptions)this; Series series = eventCountOptions.GetTimeXAxisSignalSeries(signal); chart.Series.Add(series); } SaveChartImage(chart); } ; break; case SeriesType.Signal: chart = ChartFactory.CreateTimeXIntYChart(this, Signals); GetTimeXAxisSignalSeriesChart(Signals, chart); if (ShowEventCount) { SetTimeXAxisRouteSeriesForEventCount(Signals, chart); } SaveChartImage(chart); break; case SeriesType.Route: chart = ChartFactory.CreateTimeXIntYChart(this, Signals); SetTimeXAxisRouteSeriesChart(Signals, chart); if (ShowEventCount) { SetTimeXAxisRouteSeriesForEventCount(Signals, chart); } SaveChartImage(chart); break; default: throw new Exception("Invalid X-Axis Series Combination"); } }
public HighchartsAdapter(Highchart chart) { _chart = new Chart(chart); }
public static void Run() { // ExStart:AddCustomLabelsToDataPointsInTheSeriesOfChart // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); Workbook workbook = new Workbook(FileFormatType.Xlsx); Worksheet sheet = workbook.Worksheets[0]; // Put data sheet.Cells[0, 0].PutValue(1); sheet.Cells[0, 1].PutValue(2); sheet.Cells[0, 2].PutValue(3); sheet.Cells[1, 0].PutValue(4); sheet.Cells[1, 1].PutValue(5); sheet.Cells[1, 2].PutValue(6); sheet.Cells[2, 0].PutValue(7); sheet.Cells[2, 1].PutValue(8); sheet.Cells[2, 2].PutValue(9); // Generate the chart int chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.ScatterConnectedByLinesWithDataMarker, 5, 1, 24, 10); Chart chart = sheet.Charts[chartIndex]; chart.Title.Text = "Test"; chart.CategoryAxis.Title.Text = "X-Axis"; chart.ValueAxis.Title.Text = "Y-Axis"; chart.NSeries.CategoryData = "A1:C1"; // Insert series chart.NSeries.Add("A2:C2", false); Series series = chart.NSeries[0]; int pointCount = series.Points.Count; for (int i = 0; i < pointCount; i++) { ChartPoint pointIndex = series.Points[i]; pointIndex.DataLabels.Text = "Series 1" + "\n" + "Point " + i; } // Insert series chart.NSeries.Add("A3:C3", false); series = chart.NSeries[1]; pointCount = series.Points.Count; for (int i = 0; i < pointCount; i++) { ChartPoint pointIndex = series.Points[i]; pointIndex.DataLabels.Text = "Series 2" + "\n" + "Point " + i; } workbook.Save(dataDir + "output_out_.xlsx", Aspose.Cells.SaveFormat.Xlsx); // ExEnd:AddCustomLabelsToDataPointsInTheSeriesOfChart }
public async Task <ActionResult> SkillMap(int competency, string projectId) { var imgStream = new MemoryStream(); var skillMapChart = new Chart() { Width = 500, Height = 550 }; InitializeServiceClient(); try { HttpResponseMessage skillResponse = await client.PostAsJsonAsync("Skill/GetAllSkillResourceCount?projectId=" + projectId, req); List <SkillCompetencyResource> result = await skillResponse.Content.ReadAsAsync <List <SkillCompetencyResource> >(); List <string> xValues = new List <string>(); List <double> yValues1 = new List <double>(); List <double> yValues2 = new List <double>(); List <double> yValues3 = new List <double>(); List <double> yValues4 = new List <double>(); List <double> yValues5 = new List <double>(); for (int k = 0; k < result.Count; k++) { xValues.Add(result[k].Skill); yValues1.Add(result[k].NoviceCount); yValues2.Add(result[k].AdvancedBeginnerCount); yValues3.Add(result[k].CompetentCount); yValues4.Add(result[k].ProficientCount); yValues5.Add(result[k].ExpertCount); } Series s1 = new Series(); s1.Name = "SkillMap"; s1.ChartType = SeriesChartType.Radar; s1.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); s1.MarkerSize = 9; s1.BorderColor = System.Drawing.Color.FromArgb(180, 26, 59, 105); s1.Color = System.Drawing.Color.FromArgb(220, 65, 140, 240); s1.ShadowOffset = 1; skillMapChart.Series.Add(s1); //Legend l = new Legend(); //l.IsTextAutoFit = false; //l.Name = "Default"; //l.BackColor = System.Drawing.Color.Transparent; //l.Font = new System.Drawing.Font("Trebuchet MS", 7, System.Drawing.FontStyle.Bold); //l.Alignment = System.Drawing.StringAlignment.Far; //l.Position.Y = 74; //l.Position.Height = 14; //l.Position.Width = 19; //l.Position.X = 74; switch (competency) { case 1: //Series s1 = new Series(); //s1.Name = "Novice"; //s1.ChartType = SeriesChartType.Radar; //s1.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); //s1.MarkerSize = 9; //s1.BorderColor = System.Drawing.Color.FromArgb(220, 255, 255, 204); //s1.Color = System.Drawing.Color.FromArgb(220, 255, 255, 204); //s1.ShadowOffset = 1; //skillMapChart.Series.Add(s1); skillMapChart.Series["SkillMap"].Points.DataBindXY(xValues, yValues1); //l.Title = "Novice"; break; case 2: //Series s2 = new Series(); //s2.Name = "AdvancedBeginner"; //s2.ChartType = SeriesChartType.Radar; //s2.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); //s2.MarkerSize = 9; //s2.BorderColor = System.Drawing.Color.FromArgb(220, 255, 255, 204); ////s2.BorderColor = System.Drawing.Color.FromArgb(220, 252, 180, 65); //s2.Color = System.Drawing.Color.FromArgb(220, 255, 255, 204); //s2.ShadowOffset = 1; //skillMapChart.Series.Add(s2); skillMapChart.Series[0].Points.DataBindXY(xValues, yValues2); // l.Title = "Advanced Beginner"; break; case 3: //Series s3 = new Series(); //s3.Name = "Competent"; //s3.ChartType = SeriesChartType.Radar; //s3.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); //s3.MarkerSize = 9; //s3.BorderColor = System.Drawing.Color.FromArgb(220, 255, 204, 153); ////s3.BorderColor = System.Drawing.Color.FromArgb(220, 63, 191, 127); //s3.Color = System.Drawing.Color.FromArgb(220, 255, 204, 153); //s3.ShadowOffset = 1; //skillMapChart.Series.Add(s3); skillMapChart.Series[0].Points.DataBindXY(xValues, yValues3); // l.Title = "Competent"; break; case 4: //Series s4 = new Series(); //s4.Name = "Proficient"; //s4.ChartType = SeriesChartType.Radar; //s4.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); //s4.MarkerSize = 9; //s4.BorderColor = System.Drawing.Color.FromArgb(220, 255, 204, 229); ////s4.BorderColor = System.Drawing.Color.FromArgb(220, 63, 127, 191); //s4.Color = System.Drawing.Color.FromArgb(220, 255, 204, 229); //s4.ShadowOffset = 1; //skillMapChart.Series.Add(s4); skillMapChart.Series[0].Points.DataBindXY(xValues, yValues4); // l.Title = "Proficient"; break; case 5: //Series s5 = new Series(); //s5.Name = "Expert"; //s5.ChartType = SeriesChartType.Radar; //s5.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); //s5.MarkerSize = 9; //s5.BorderColor = System.Drawing.Color.FromArgb(220, 153, 255, 153); ////s5.BorderColor = System.Drawing.Color.FromArgb(220, 191, 63, 63); //s5.Color = System.Drawing.Color.FromArgb(220, 153, 255, 153); //s5.ShadowOffset = 1; //skillMapChart.Series.Add(s5); skillMapChart.Series[0].Points.DataBindXY(xValues, yValues5); // l.Title = "Expert"; break; } skillMapChart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss; // skillMapChart.Legends.Add(l); ChartArea c = new ChartArea(); c.BorderColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); c.BackSecondaryColor = System.Drawing.Color.White; c.BackColor = System.Drawing.Color.OldLace; c.ShadowColor = System.Drawing.Color.Transparent; c.Area3DStyle.Rotation = 10; c.Area3DStyle.Perspective = 10; c.Area3DStyle.Inclination = 15; c.Area3DStyle.IsRightAngleAxes = false; c.Area3DStyle.WallWidth = 0; c.Area3DStyle.IsClustered = false; c.Position.Y = 15; c.Position.Height = 78; c.Position.Width = 88; c.Position.X = 5; c.AxisY.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); c.AxisY.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 7, System.Drawing.FontStyle.Bold); c.AxisY.MajorGrid.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); c.AxisX.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); c.AxisX.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 7, System.Drawing.FontStyle.Bold); c.AxisX.MajorGrid.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); skillMapChart.ChartAreas.Add(c); // Save the chart to a MemoryStream skillMapChart.SaveImage(imgStream, ChartImageFormat.Png); imgStream.Seek(0, SeekOrigin.Begin); } catch (Exception ex) { //UserManager users = (UserManager)Session["CurrentUser"]; //LogHelper.AddLog("ChartsController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID); TelemetryClient telemetry = new TelemetryClient(); telemetry.TrackException(ex); } // Return the contents of the Stream to the client return(File(imgStream, "image/png")); }
private string GetSpecificLoggingInfo(string description, List <float> loggingList, Chart chart) { chart.Visible = true; chart.Series[description].Points.Clear(); double sec = 0; foreach (var info in loggingList) { chart.Series[description].Points.AddXY(sec, info); sec += 0.400; } string allInfo = description + ": \n Minimum: " + loggingList.Min() + "\n Maximum: " + loggingList.Max() + "\n Average : " + loggingList.Average(); return(allInfo); }
public string GetUserData(string name) { UserData userData = new UserData(); Chart chart = new Chart(); List <Feature> features = new List <Feature>(); List <string> tijd = new List <string>(); List <string> gemeente = new List <string>(); List <double> vocht = new List <double>(); List <double> temp = new List <double>(); List <int> licht = new List <int>(); List <int> co2 = new List <int>(); string query = string.Format("SELECT Breedtegraad, Lengtegraad, Gebruiker, Vochtigheid, Temperatuur, CO2, Lichtsterkte, Tijd, Gemeente FROM Waardes WHERE Gebruiker='{0}'", name); string json = ""; try { OleDbConnection connection = new OleDbConnection(); connection.ConnectionString = connString; connection.Open(); OleDbCommand command = new OleDbCommand { Connection = connection, CommandText = query }; OleDbDataReader reader = command.ExecuteReader(); string[] data = new string[9]; string desc; while (reader.Read()) { List <double> coords = new List <double>(); for (int x = 0; x < 9; x++) { // Lat, Long, User, Vochtigheid, Temp, CO2, Licht, Time data[x] = reader[x].ToString(); } //data[0] = data[0].Replace(',', '.'); //data[1] = data[1].Replace(',', '.'); coords.Add(Convert.ToDouble(data[1])); coords.Add(Convert.ToDouble(data[0])); vocht.Add(Convert.ToDouble(data[3])); temp.Add(Convert.ToDouble(data[4])); co2.Add(Convert.ToInt32(data[5])); licht.Add(Convert.ToInt32(data[6])); tijd.Add(data[7]); gemeente.Add(data[8]); desc = string.Format(@"Temperatuur: {1} <br/>Vochtigheid: {0} <br/>CO²: {2} <br/>Lichtsterkte: {3} <br/>Tijd van meting: {4}", data[3], data[4], data[5], data[6], data[7]); Properties properties = new Properties { description = desc, title = "Gemeten door: " + data[2] }; Geometry geometry = new Geometry { type = "Point", coordinates = coords }; Feature feature = new Feature { type = "Feature", properties = properties, geometry = geometry }; features.Add(feature); } connection.Close(); chart.CO2 = co2; chart.Licht = licht; chart.Temp = temp; chart.Tijd = tijd; chart.Vocht = vocht; chart.Gemeente = gemeente; userData.chart = chart; userData.features = features; json = JsonConvert.SerializeObject(userData, Formatting.Indented); } catch (Exception e) { Console.WriteLine(e.Message); return(json); } return(json); }
//Експорт private void ExportButton_OnClick(object sender, RoutedEventArgs e) { ComboBoxItem comboItem = (ComboBoxItem)ComboBox.SelectedItem; //Експорт в png if (comboItem.Name != null && comboItem.Name.ToString() == "Png") { SaveFileDialog dialog = new SaveFileDialog(); dialog.RestoreDirectory = true; dialog.DefaultExt = "*.Png "; dialog.Title = "Збереження"; dialog.Filter = "Файл зображення (*.png )|*.png "; if (dialog.ShowDialog() == true) { //збереження файлу Stream fileStream = dialog.OpenFile(); Chart.ExportToImage(fileStream); fileStream.Close(); //Повідомлення про успішне експортування MessageBox.Show("Експорт у файл Png успішно виконано!", "Повідомлення", MessageBoxButton.OK, MessageBoxImage.Information); } } //Експорт в ExcelML if (comboItem.Name != null && comboItem.Name.ToString() == "ExcelMl") { SaveFileDialog dialog = new SaveFileDialog(); dialog.RestoreDirectory = true; dialog.DefaultExt = "*.xlsx"; dialog.Title = "Збереження"; dialog.Filter = "Таблиця Excel (*.xlsx)|*.xlsx"; if (dialog.ShowDialog() == true) { //збереження файлу Stream fileStream = dialog.OpenFile(); Chart.ExportToExcelML(fileStream); fileStream.Close(); //Повідомлення про успішне експортування MessageBox.Show("Експорт у файл ExcelMl успішно виконано!", "Повідомлення", MessageBoxButton.OK, MessageBoxImage.Information); } } //Експорт в xps if (comboItem.Name != null && comboItem.Name.ToString() == "Xps") { SaveFileDialog dialog = new SaveFileDialog(); dialog.RestoreDirectory = true; dialog.DefaultExt = "*.xps"; dialog.Title = "Збереження"; dialog.Filter = "Документ (*.xps )|*.xps "; if (dialog.ShowDialog() == true) { //збереження файлу Stream fileStream = dialog.OpenFile(); Chart.ExportToXps(fileStream); fileStream.Close(); //Повідомлення про успішне експортування MessageBox.Show("Експорт у файл Xps успішно виконано!", "Повідомлення", MessageBoxButton.OK, MessageBoxImage.Information); } } }
private void ChartCursorMoved(Chart sender, ChartCursor cursor) { // txtChartValue.Text = x.ToString("F4") + ", " + y.ToString("F4"); }
/// <summary> /// Gets the heat map of the selected project and competency. /// </summary> /// <param name="projectId"></param> /// <param name="competency"></param> /// <returns></returns> public async Task <ActionResult> HeatMap(int projectId, string competency) { var imgStream = new MemoryStream(); var heatMapChart = new Chart() { Width = 600, Height = 300 }; try { InitializeServiceClient(); UserProjectRequest userProjectInfo = new UserProjectRequest(); userProjectInfo.ProjectId = projectId; userProjectInfo.ClientInfo = req.ClientInfo; HttpResponseMessage trainingResponse = await client.PostAsJsonAsync("Project/GetResourceDetailsByProjectID", userProjectInfo); Resource prjRes = await trainingResponse.Content.ReadAsAsync <Resource>(); List <string> xValues = new List <string>(); List <double> yValues = new List <double>(); List <double> yValues2 = new List <double>(); for (int k = 0; k < prjRes.allResources.Count; k++) { xValues.Add(prjRes.allResources[k].skill); if (competency.ToUpper() == "BEGINNER" || competency.ToUpper() == "NOVICE") { yValues.Add(prjRes.allResources[k].expectedBeginnerCount); yValues2.Add(prjRes.allResources[k].availableBeginnerCount); } else if (competency.ToUpper() == "ADVANCEDBEGINNER") { yValues.Add(prjRes.allResources[k].expectedAdvancedBeginnerCount); yValues2.Add(prjRes.allResources[k].availableAdvancedBeginnerCount); } else if (competency.ToUpper() == "COMPETENT") { yValues.Add(prjRes.allResources[k].expectedCompetentCount); yValues2.Add(prjRes.allResources[k].availableCompetentCount); } else if (competency.ToUpper() == "PROFICIENT") { yValues.Add(prjRes.allResources[k].expectedProficientCount); yValues2.Add(prjRes.allResources[k].availableProficientCount); } else if (competency.ToUpper() == "EXPERT") { yValues.Add(prjRes.allResources[k].expectedExpertCount); yValues2.Add(prjRes.allResources[k].availableExpertCount); } } Series s1 = new Series(); s1.Name = "Expected"; s1.ChartType = SeriesChartType.Radar; s1.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); s1.MarkerSize = 9; s1.BorderColor = System.Drawing.Color.FromArgb(180, 26, 59, 105); s1.Color = System.Drawing.Color.FromArgb(220, 65, 140, 240); s1.ShadowOffset = 1; heatMapChart.Series.Add(s1); Series s2 = new Series(); s2.Name = "Available"; s2.ChartType = SeriesChartType.Radar; s2.MarkerBorderColor = System.Drawing.Color.FromArgb(64, 64, 64); s2.MarkerSize = 9; s2.BorderColor = System.Drawing.Color.FromArgb(180, 26, 59, 105); s2.Color = System.Drawing.Color.FromArgb(220, 252, 180, 65); s2.ShadowOffset = 1; heatMapChart.Series.Add(s2); heatMapChart.Series["Expected"].Points.DataBindXY(xValues, yValues); heatMapChart.Series["Available"].Points.DataBindXY(xValues, yValues2); heatMapChart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss; Legend l = new Legend(); l.IsTextAutoFit = false; l.Name = "Default"; l.BackColor = System.Drawing.Color.Transparent; l.Font = new System.Drawing.Font("Trebuchet MS", 8, System.Drawing.FontStyle.Bold); l.Alignment = System.Drawing.StringAlignment.Far; l.Position.Y = 74; l.Position.Height = 14; l.Position.Width = 19; l.Position.X = 74; heatMapChart.Legends.Add(l); ChartArea c = new ChartArea(); c.BorderColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); c.BackSecondaryColor = System.Drawing.Color.White; c.BackColor = System.Drawing.Color.OldLace; c.ShadowColor = System.Drawing.Color.Transparent; c.Area3DStyle.Rotation = 10; c.Area3DStyle.Perspective = 10; c.Area3DStyle.Inclination = 15; c.Area3DStyle.IsRightAngleAxes = false; c.Area3DStyle.WallWidth = 0; c.Area3DStyle.IsClustered = false; c.Position.Y = 15; c.Position.Height = 78; c.Position.Width = 88; c.Position.X = 5; c.AxisY.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); c.AxisY.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 8, System.Drawing.FontStyle.Bold); c.AxisY.MajorGrid.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); c.AxisX.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); c.AxisX.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 8, System.Drawing.FontStyle.Bold); c.AxisX.MajorGrid.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64); heatMapChart.ChartAreas.Add(c); // Save the chart to a MemoryStream heatMapChart.SaveImage(imgStream, ChartImageFormat.Png); imgStream.Seek(0, SeekOrigin.Begin); } catch (Exception ex) { // UserManager users = (UserManager)Session["CurrentUser"]; // LogHelper.AddLog("ChartsController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID); TelemetryClient telemetry = new TelemetryClient(); telemetry.TrackException(ex); } // Return the contents of the Stream to the client return(File(imgStream, "image/png")); }
private void toolQuery_Click(object sender, EventArgs e) { if (toolcbxBaseType.SelectedItem != null) { DataRow dr = null; Chart chart = new Chart(); int? intAmount = null; DataTable dtTemp = new DataTable(); string strTableMeanings = toolcbxBaseType.Text; //某个类别表的名称(如:信用等级表、客户等级表等等) string strTable = dicKeyValue[toolcbxBaseType.SelectedIndex].ToString(); //某个具体的类别表(共有两个字段:*Code和*Name) try { //添加“代码”“名称”“数量”三个列于内存表(dtTemp) DataColumn dc1 = new DataColumn("Code", typeof(string)); dtTemp.Columns.Add(dc1); DataColumn dc2 = new DataColumn("Name", typeof(string)); dtTemp.Columns.Add(dc2); DataColumn dc3 = new DataColumn("Amount", typeof(Int32)); dtTemp.Columns.Add(dc3); DataTable dtBaseType = db.GetDataTable("Select * From " + strTable, strTable); string strCodeColumn = dtBaseType.Columns[0].ColumnName; string strNamecolumn = dtBaseType.Columns[1].ColumnName; foreach (DataRow row in dtBaseType.Rows) { dr = dtTemp.NewRow(); //得到与该DataTable具有相同结构的一个DataRow对象 dr["Code"] = row[strCodeColumn]; dr["Name"] = row[strNamecolumn]; intAmount = db.GetSingleObject("Select Count(*) From BSCustomer Where " + strCodeColumn + " = '" + row[strCodeColumn] + "'") as int?; if (!intAmount.HasValue) { intAmount = 0; } dr["Amount"] = intAmount.Value; dtTemp.Rows.Add(dr); } //增加客户档案中未设置情况的信息 dr = dtTemp.NewRow(); dr["Code"] = DBNull.Value; dr["Name"] = "未设定"; intAmount = db.GetSingleObject("Select Count(*) From BSCustomer Where " + strCodeColumn + " is null ") as int?; if (!intAmount.HasValue) { intAmount = 0; } dr["Amount"] = intAmount.Value; dtTemp.Rows.Add(dr); //绘制饼形图 if (dtTemp.Rows.Count > 0) { picPie.Image = chart.CreatePieChart("类型分析", "——" + strTableMeanings, 679, 384, dtTemp, 2); } } catch (Exception ex) { throw ex; } } }
private void ChartCursorSelected(Chart sender, ChartCursor cursor) { //txtChartSelect.Text = x.ToString("F4") + ", " + y.ToString("F4"); }
//Estadisticas y clasificacion de nivel de gastos public async Task <IActionResult> ExpensesAndIncomes() { //Chart instance Chart chart = new Chart(); Chart chartIncomes = new Chart(); Chart chartBalance = new Chart(); //Getting the user and setting the userId var user = await _userManager.GetUserAsync(HttpContext.User); var userId = user.Id; //User expenses List <Expense> listagastos = _db.Expenses.Where(x => x.UserId == userId).ToList(); //User profile List <Profile> listasalario = _db.Profiles.Where(x => x.UserId == userId).ToList(); //User incomes List <Income> listaentradas = _db.Incomes.Include(x => x.IncomeSource).Where(x => x.IncomeSource.UserId == userId).ToList(); //Setting the chart type chart.Type = Enums.ChartType.Line; chartIncomes.Type = Enums.ChartType.Line; chartBalance.Type = Enums.ChartType.Line; //Extracting the expenses data List <double> total = listagastos.Select(x => Convert.ToDouble(x.Total)).ToList(); List <double> totalsalario = listasalario.Select(x => Convert.ToDouble(x.Salary)).ToList(); double salariototal = totalsalario[0]; ViewBag.salariototal = salariototal; //Extracting the incomes data List <double> totalIncomes = listagastos.Select(x => Convert.ToDouble(x.Total)).ToList(); List <double> totalmes = new List <double>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; List <double> totalEntradasMes = new List <double>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; List <double> totalBalance = new List <double>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; foreach (Expense item in listagastos) { for (int i = 0; i <= 11; i++) { if (item.CreationDate.Month - 1 == i) { var elemento = totalmes.ElementAt(i); elemento += Convert.ToDouble(item.Total); totalmes.RemoveAt(i); totalmes.Insert(i, elemento); } } } foreach (Income item in listaentradas) { for (int i = 0; i <= 11; i++) { if (item.CreationDate.Month - 1 == i) { var elemento = totalEntradasMes.ElementAt(i); elemento += Convert.ToDouble(item.Total); totalEntradasMes.RemoveAt(i); totalEntradasMes.Insert(i, elemento); } } } for (int i = 0; i <= 11; i++) { double monthBalance = salariototal - totalmes.ElementAt(i) - totalEntradasMes.ElementAt(i); totalBalance.RemoveAt(i); totalBalance.Insert(i, monthBalance); } int indicemes = DateTime.Now.Month; double gastototal = totalmes[indicemes - 1]; double a = salariototal - gastototal; double porcentaje = (a * 100) / salariototal; ViewBag.porcentaje = porcentaje; //Data object for expenses ChartJSCore.Models.Data data = new ChartJSCore.Models.Data(); //Data object for incomes ChartJSCore.Models.Data dataIncomes = new ChartJSCore.Models.Data(); //Data object for balance ChartJSCore.Models.Data dataBalance = new ChartJSCore.Models.Data(); List <string> months = new List <string>() { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }; data.Labels = months; dataIncomes.Labels = months; dataBalance.Labels = months; //Dataset for expenses chart LineDataset dataset = new LineDataset() { Label = "Gastos por mes", Data = totalmes, Fill = "false", LineTension = 0.1, BackgroundColor = ChartColor.FromRgba(75, 192, 192, 0.4), BorderColor = ChartColor.FromRgb(75, 192, 192), BorderCapStyle = "butt", BorderDash = new List <int> { }, BorderDashOffset = 0.0, BorderJoinStyle = "miter", PointBorderColor = new List <ChartColor> { ChartColor.FromRgb(75, 192, 192) }, PointBackgroundColor = new List <ChartColor> { ChartColor.FromHexString("#ffffff") }, PointBorderWidth = new List <int> { 1 }, PointHoverRadius = new List <int> { 5 }, PointHoverBackgroundColor = new List <ChartColor> { ChartColor.FromRgb(75, 192, 192) }, PointHoverBorderColor = new List <ChartColor> { ChartColor.FromRgb(220, 220, 220) }, PointHoverBorderWidth = new List <int> { 2 }, PointRadius = new List <int> { 1 }, PointHitRadius = new List <int> { 10 }, SpanGaps = false }; //Dataset for incomes chart LineDataset datasetIncomes = new LineDataset() { Label = "Entradas por mes", Data = totalEntradasMes, Fill = "false", LineTension = 0.1, BackgroundColor = ChartColor.FromRgba(75, 192, 192, 0.4), BorderColor = ChartColor.FromRgb(75, 192, 192), BorderCapStyle = "butt", BorderDash = new List <int> { }, BorderDashOffset = 0.0, BorderJoinStyle = "miter", PointBorderColor = new List <ChartColor> { ChartColor.FromRgb(75, 192, 192) }, PointBackgroundColor = new List <ChartColor> { ChartColor.FromHexString("#ffffff") }, PointBorderWidth = new List <int> { 1 }, PointHoverRadius = new List <int> { 5 }, PointHoverBackgroundColor = new List <ChartColor> { ChartColor.FromRgb(75, 192, 192) }, PointHoverBorderColor = new List <ChartColor> { ChartColor.FromRgb(220, 220, 220) }, PointHoverBorderWidth = new List <int> { 2 }, PointRadius = new List <int> { 1 }, PointHitRadius = new List <int> { 10 }, SpanGaps = false }; //Dataset for balance chart LineDataset datasetBalance = new LineDataset() { Label = "Balance por mes", Data = totalBalance, Fill = "false", LineTension = 0.1, BackgroundColor = ChartColor.FromRgba(75, 192, 192, 0.4), BorderColor = ChartColor.FromRgb(75, 192, 192), BorderCapStyle = "butt", BorderDash = new List <int> { }, BorderDashOffset = 0.0, BorderJoinStyle = "miter", PointBorderColor = new List <ChartColor> { ChartColor.FromRgb(75, 192, 192) }, PointBackgroundColor = new List <ChartColor> { ChartColor.FromHexString("#ffffff") }, PointBorderWidth = new List <int> { 1 }, PointHoverRadius = new List <int> { 5 }, PointHoverBackgroundColor = new List <ChartColor> { ChartColor.FromRgb(75, 192, 192) }, PointHoverBorderColor = new List <ChartColor> { ChartColor.FromRgb(220, 220, 220) }, PointHoverBorderWidth = new List <int> { 2 }, PointRadius = new List <int> { 1 }, PointHitRadius = new List <int> { 10 }, SpanGaps = false }; data.Datasets = new List <Dataset>(); data.Datasets.Add(dataset); chart.Data = data; dataIncomes.Datasets = new List <Dataset>(); dataIncomes.Datasets.Add(datasetIncomes); chartIncomes.Data = dataIncomes; dataBalance.Datasets = new List <Dataset>(); dataBalance.Datasets.Add(datasetBalance); chartBalance.Data = dataBalance; //Sending data to the view ViewData["expenses"] = chart; ViewData["incomes"] = chartIncomes; ViewData["balance"] = chartBalance; return(View()); }
private void zoomChanged(Chart sender) { }
public void Dispose() { Chart.Dispose(); }
//柱 public void CreateChartColumn(string name, string[] valuex, int[] valuey) { //创建一个图标 Chart chart = new Chart(); //设置图标的宽度和高度 chart.Width = 1130; chart.Height = 480; chart.Margin = new Thickness(350, 250, 10, 5); //是否启用打印和保持图片 chart.ToolBarEnabled = false; //设置图标的属性 chart.ScrollingEnabled = false; //是否启用或禁用滚动 chart.View3D = true; //3D效果显示 //创建一个标题的对象 Title title = new Title(); //设置标题的名称 title.Text = Name; title.Padding = new Thickness(0, 10, 5, 0); //向图标添加标题 chart.Titles.Add(title); Axis yAxis = new Axis(); //设置图标中Y轴的最小值永远为0 yAxis.AxisMinimum = 0; //设置图表中Y轴的后缀 yAxis.Suffix = "次"; chart.AxesY.Add(yAxis); // 创建一个新的数据线。 DataSeries dataSeries = new DataSeries(); // 设置数据线的格式 dataSeries.RenderAs = RenderAs.StackedColumn;//柱状Stacked // 设置数据点 DataPoint dataPoint; for (int i = 0; i < arrayNo.Length; i++) { // 创建一个数据点的实例。 dataPoint = new DataPoint(); // 设置X轴点 dataPoint.AxisXLabel = arrayDate[i]; //设置Y轴点 dataPoint.YValue = double.Parse(arrayNo[i].ToString()); //添加一个点击事件 dataPoint.MouseLeftButtonDown += new MouseButtonEventHandler(dataPoint_MouseLeftButtonDown); //添加数据点 dataSeries.DataPoints.Add(dataPoint); } // 添加数据线到数据序列。 chart.Series.Add(dataSeries); //将生产的图表增加到Grid,然后通过Grid添加到上层Grid. Grid gr = new Grid(); gr.Children.Add(chart); Simon.Children.Add(gr); }
private void draw_chart(Chart mychart, int machine_num) { //将对应的开始时间读出来 if (true) { if (mychart.InvokeRequired) { ThreadWork tw = new ThreadWork(draw_chart); try { this.Invoke(tw, new object[2] { mychart, machine_num }); } catch { } } else { try { DataSet ds = mv.mysqlconnection.sql_search_database("Select * from start_time where machine_num=" + machine_num.ToString()); DataRow dr = ds.Tables[0].Rows[0]; DateTime starttime = DateTime.Parse(dr[1].ToString()); // 将历史记录中相相应的都读出来 ds = mv.mysqlconnection.sql_search_database("Select machine_num,value,save_time from history where machine_num=" + machine_num.ToString() + " and save_time>" + "'" + starttime.ToString() + "' and save_time<'" + starttime.AddHours(5).ToString() + "' order by save_time"); int count = ds.Tables[0].Rows.Count; mychart.Series[0].Points.Clear(); for (int i = 0; i < count; i++) { DataRow mydr = ds.Tables[0].Rows[i]; int myvalue = int.Parse(mydr[1].ToString()); DateTime mytime = DateTime.Parse(mydr[2].ToString()); mychart.Series[0].Points.AddXY(mytime, myvalue); } } catch { mychart.Series[0].Points.Clear(); } // 画设定曲线 try { // int datagridview_row_count = dataGridView1.Rows.Count; DataSet ds = mv.mysqlconnection.sql_search_database("Select * from start_time where machine_num=" + machine_num.ToString()); DataRow dr = ds.Tables[0].Rows[0]; DateTime starttime = DateTime.Parse(dr[1].ToString()); //开始时间 DataSet gongyi_ds = mv.mysqlconnection.sql_search_database("Select * from craft_machine" + machine_num.ToString()); int datagridview_row_count = gongyi_ds.Tables[0].Rows.Count; mychart.Series[1].Points.Clear(); for (int i = 0; i < datagridview_row_count; i++) { if (gongyi_ds.Tables[0].Rows[i][4].ToString() == "温控") { int wendu = int.Parse(gongyi_ds.Tables[0].Rows[i][1].ToString()); mychart.Series[1].Points.AddXY(starttime, wendu); int timespan = int.Parse(gongyi_ds.Tables[0].Rows[i][3].ToString()); starttime = starttime.AddMinutes(timespan); } } } catch { } } } }
private void InitChart() { ConcChart.Children.Clear(); chart = new Chart { Margin = new Thickness(5, 5, 5, 5), ToolBarEnabled = false, ScrollingEnabled = false, View3D = true }; Title title = new Title { Text = "浓度曲线", Padding = new Thickness(0, 10, 5, 0) }; chart.Titles.Add(title); chart.ZoomingEnabled = true; chart.ZoomingMode = ZoomingMode.MouseDragAndWheel; Axis xAxis = new Axis { Title = "时间", ValueFormatString = "MM-dd HH:mm:ss", Interval = 5, IntervalType = IntervalTypes.Minutes }; chart.AxesX.Add(xAxis); Axis yAxis = new Axis { Title = "浓度(ppm)" }; chart.AxesY.Add(yAxis); series1 = new DataSeries { RenderAs = RenderAs.Line, LegendText = "气体一", XValueType = ChartValueTypes.DateTime }; series2 = new DataSeries { RenderAs = RenderAs.Line, LegendText = "气体二", XValueType = ChartValueTypes.DateTime }; series3 = new DataSeries { RenderAs = RenderAs.Line, LegendText = "气体三", XValueType = ChartValueTypes.DateTime }; series4 = new DataSeries { RenderAs = RenderAs.Line, LegendText = "气体四", XValueType = ChartValueTypes.DateTime }; chart.Series.Add(series1); chart.Series.Add(series2); chart.Series.Add(series3); chart.Series.Add(series4); Grid gr = new Grid(); gr.Children.Add(chart); ConcChart.Children.Add(gr); }
public bool IsPieChartDrawn() { return(Chart.HasDrawnPie()); }
private void InitAndDrawIndexes() { baseDS.priceDataDataTable tbl1 = Gateway.PriceData.GetPriceData("VN-IDX", "D1", DateTime.Now.AddDays(-20), DateTime.Now); baseDS.priceDataDataTable tbl2 = Gateway.PriceData.GetPriceData("HNX-IDX", "D1", DateTime.Now.AddDays(-20), DateTime.Now); #region VNINDEX decimal[] yValues = new decimal[tbl1.Count]; string[] xValues = new string[tbl1.Count]; for (int idx = 0; idx < tbl1.Count; idx++) { yValues[idx] = tbl1[idx].closePrice; xValues[idx] = tbl1[idx].onDate.ToShortDateString(); } Chart lineChart = lineCurvesChartType1.getChart(); lineChart.Series["Series1"].LegendText = "VN-Index"; lineChart.Series["Series1"].XValueType = ChartValueType.Date; lineChart.Series["Series1"].YValueType = ChartValueType.Int32; //lineChart.Legends["Series1"].Title = "VN-Index"; //lineChart.Legends["Series1"].DockedToChartArea = "Default"; lineChart.Series["Series1"].MarkerStyle = MarkerStyle.None; lineChart.Series["Series1"].Points.DataBindXY(xValues, yValues); lineChart.Series["Series1"].Color = System.Drawing.Color.Red; lineChart.Series["Series1"].IsValueShownAsLabel = true; // Set Doughnut chart type lineChart.Series["Series1"].ChartType = SeriesChartType.Line; // Set labels style lineChart.Series["Series1"]["PieLabelStyle"] = "Inside"; // Set Doughnut radius percentage lineChart.Series["Series1"]["DoughnutRadius"] = "99"; // Explode data point with label "Italy" lineChart.Series["Series1"].Points[yValues.Length - 1]["Exploded"] = "true"; // Enable 3D lineChart.ChartAreas["Default"].Area3DStyle.Enable3D = false; lineChart.ChartAreas["Default"].AxisX.IsMarginVisible = true; // Set drawing style lineChart.Series["Series1"]["PieDrawingStyle"] = "SoftEdge"; #endregion VNINDEX //HNX series #region HNX //decimal[] yValues2 = new decimal[tbl2.Count]; //string[] xValues2 = new string[tbl2.Count]; //for (int idx = 0; idx < tbl2.Count; idx++) //{ // yValues2[idx] = tbl2[idx].closePrice; // xValues2[idx] = tbl2[idx].onDate.ToShortDateString(); //} //lineChart.Series["Series2"].XValueType = ChartValueType.Date; //lineChart.Series["Series2"].YValueType = ChartValueType.Int32; //lineChart.Series["Series2"].Points.DataBindXY(xValues2, yValues2); //lineChart.Series["Series2"].Color = Color.Green; //lineChart.Series["Series2"].IsValueShownAsLabel = true; //lineChart.Series["Series2"].LegendText = "HNX-Index"; ////lineChart.Series["Series2"].Label = //// Set Doughnut chart type //lineChart.Series["Series2"].ChartType = SeriesChartType.Line; //// Set labels style //lineChart.Series["Series2"]["PieLabelStyle"] = "Inside"; //// Explode data point with label "Italy" //lineChart.Series["Series2"].Points[yValues2.Length - 1]["Exploded"] = "true"; #endregion HNX //END HNX series Title title4 = new Title(); title4.Font = new System.Drawing.Font("Trebuchet MS", 14.25F, System.Drawing.FontStyle.Bold); title4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105))))); title4.Name = "Title1"; title4.ShadowColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); title4.ShadowOffset = 1; title4.Text = "BIỂU ĐỒ CHỈ SỐ VN-INDEX TUẦN QUA"; lineChart.Titles.Clear(); lineChart.Titles.Add(title4); }
public bool IsColumnChartDrawn() { return(Chart.HasDrawnColumn()); }
public int GetPiesNumber() { return(Chart.GetPieDistributions()); }
public override void SetSignalsXAxisSignalSeriesForEventCount(List <Models.Signal> signals, Chart chart) { var eventCountOptions = new ApproachEventCountAggregationOptions(this); Series series = eventCountOptions.GetSignalsXAxisSignalSeries(signals, "Event Count"); chart.Series.Add(SetEventCountSeries(series)); }
public int GetColumnChartColumns() { return(Chart.GetColumnChartColumns()); }
protected void GetPhaseXAxisChart(Models.Signal signal, Chart chart) { Series series = GetPhaseXAxisPhaseSeries(signal, 0); chart.Series.Add(series); }
public int GetTrendChartLines() { return(Chart.GetTrendChartLines()); }