private void InitializeControlSettings() { this.chartControl1.ChartArea.PrimaryXAxis.HidePartialLabels = true; this.chartControl1.BorderAppearance.SkinStyle = Syncfusion.Windows.Forms.Chart.ChartBorderSkinStyle.None; this.chartControl1.PrimaryYAxis.DrawGrid = false; this.chartControl1.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; this.chartControl1.Series[0].Style.Interior = new BrushInfo(Color.FromArgb(0xFF, 0x1B, 0xA1, 0xE2)); this.chartControl1.Series[0].Style.Border.Color = Color.FromArgb(0xFF, 0x1B, 0xA1, 0xE2); ChartStripLine thermoStripLine = new ChartStripLine(); //thermoStripLine.Enabled = true; //thermoStripLine.Vertical = true; //thermoStripLine.StartAtAxisPosition = true; //thermoStripLine.Start = 0; //thermoStripLine.Text = "Transmission Oil Temperature "; Assembly asem = this.GetType().Assembly; Stream str = asem.GetManifestResourceStream("TickMarksDemo_2005.Thermometer.png"); Image img = Image.FromStream(str); thermoStripLine.BackImage = img; thermoStripLine.Font = new System.Drawing.Font("Segeo UI", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(161))); thermoStripLine.Period = 9; thermoStripLine.Width = .5; this.chartControl1.PrimaryXAxis.StripLines.Add(thermoStripLine); this.chartControl1.ShowLegend = false; ChartCustomPoint cp1 = new ChartCustomPoint(); cp1.Text = "LOW HEAT : LONG MILEAGE"; cp1.CustomType = ChartCustomPointType.ChartCoordinates; cp1.Font.Facename = "Segeo UI"; cp1.Font.FontStyle = FontStyle.Bold; cp1.Font.Size = 7; cp1.XValue = 158; cp1.YValue = 4; this.chartControl1.CustomPoints.Add(cp1); ChartCustomPoint cp2 = new ChartCustomPoint(); cp2.Text = "HIGH HEAT : SHORT MILEAGE"; cp2.Font.Facename = "Segeo UI"; cp2.Font.FontStyle = FontStyle.Bold; cp2.Font.Size = 7; cp2.CustomType = ChartCustomPointType.ChartCoordinates; cp2.XValue = 335; cp2.YValue = 4; this.chartControl1.CustomPoints.Add(cp2); this.chartControl1.Refresh(); }
void chartControl1_ChartRegionMouseHover(object sender, ChartRegionMouseEventArgs e) { ChartPoint cpt = chartControl1.ChartArea.GetValueByPoint(e.Point); for (int i = 0; i < chartControl1.Series[0].Points.Count; i++) { chartControl1.Series[0].Styles[i].ResetSymbol(); } if (cpt != null && chartControl1.ChartArea.RenderBounds.Contains(e.Point)) { chartControl1.CustomPoints.Clear(); ChartPoint cpStock = null, cpVolume = null; Point clientPoint = Point.Empty; //Chart points for stock and volume series. stockPointIndex = GetPointIndex(cpt.DateX, 0); if (stockPointIndex != -1) { cpStock = this.chartControl1.Series[0].Points[stockPointIndex]; } int volumePointIndex = GetPointIndex(cpt.DateX, 1); if (volumePointIndex != -1) { cpVolume = this.chartControl1.Series[1].Points[volumePointIndex]; } if (cpStock != null && cpVolume != null) { //Display Date, High, Low, Open, Close and Volume values. this.label1.Text = "Date = " + cpt.DateX.ToShortDateString() + " Open = " + cpStock.YValues[3] + ", High = " + cpStock.YValues[0] + ", Low = " + cpStock.YValues[1] + ", Close = " + cpStock.YValues[2] + ", Volume = " + cpVolume.YValues[0]; //Custom Symbol at the active stock series point this.chartControl1.Series[0].Styles[stockPointIndex].Symbol.Shape = ChartSymbolShape.Square; this.chartControl1.Series[0].Styles[stockPointIndex].Symbol.Color = Color.Blue; this.chartControl1.Series[0].Styles[stockPointIndex].Symbol.Size = new Size(7, 7); //Custom Point at the active volume series point ChartCustomPoint ptVolume = new ChartCustomPoint(); ptVolume.Symbol.Color = Color.Blue; ptVolume.Symbol.Shape = ChartSymbolShape.Circle; ptVolume.Symbol.Size = new Size(7, 7); ptVolume.SeriesIndex = 1; ptVolume.PointIndex = volumePointIndex; ptVolume.CustomType = ChartCustomPointType.PointFollow; chartControl1.CustomPoints.Add(ptVolume); } } }
public static void ApplyChartStyles(ChartControl chart) { #region ApplyCustomPalette chart.Skins = Skins.Metro; #endregion #region Chart Appearance Customization chart.BorderAppearance.SkinStyle = Syncfusion.Windows.Forms.Chart.ChartBorderSkinStyle.None; chart.BorderAppearance.FrameThickness = new ChartThickness(-2, -2, 2, 2); chart.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; chart.ChartArea.PrimaryXAxis.HidePartialLabels = true; chart.PrimaryXAxis.DrawGrid = false; chart.PrimaryYAxis.DrawGrid = false; chart.ElementsSpacing = 0; chart.PrimaryXAxis.GridLineType.ForeColor = Color.Transparent; chart.PrimaryYAxis.GridLineType.ForeColor = Color.Transparent; chart.ShowToolTips = true; #endregion #region Legend Customization chart.Legend.RepresentationType = ChartLegendRepresentationType.SeriesType; chart.LegendPosition = ChartDock.Bottom; chart.LegendsPlacement = ChartPlacement.Outside; chart.LegendAlignment = ChartAlignment.Center; chart.ShowLegend = false; chart.EnableMouseRotation = true; ChartCustomPoint ccp = new ChartCustomPoint(); ccp.XValue = chart.Series[1].Points[40].X; ccp.YValue = chart.Series[1].Points[40].YValues[1]; ccp.CustomType = ChartCustomPointType.ChartCoordinates; ccp.Text = "Upper Band"; ccp.Symbol.Shape = ChartSymbolShape.Circle; ccp.Symbol.Color = Color.White; ccp.Symbol.Size = new Size(12, 12); ccp.Alignment = ChartTextOrientation.RegionUp; ccp.Color = Color.Black; ccp.Font.Facename = "Segoe UI"; ccp.Font.Size = 10f; chart.CustomPoints.Add(ccp); ChartCustomPoint ccp1 = new ChartCustomPoint(); ccp1.XValue = chart.Series[1].Points[40].X; ccp1.YValue = chart.Series[1].Points[40].YValues[0]; ccp1.CustomType = ChartCustomPointType.ChartCoordinates; ccp1.Text = "Lower Band"; ccp1.Symbol.Shape = ChartSymbolShape.Circle; ccp1.Symbol.Color = Color.White; ccp1.Images = new ChartImageCollection(); ccp1.Symbol.Size = new Size(12, 12); ccp1.Alignment = ChartTextOrientation.RegionDown; ccp1.Color = Color.Black; ccp1.Font.Facename = "Segoe UI"; ccp1.Font.Size = 10f; chart.CustomPoints.Add(ccp1); #endregion }
protected void InitializeChartData() { ChartSeries Completion = new ChartSeries("Completion", ChartSeriesType.Gantt); DateTime dt = new DateTime(2009, 1, 1); Completion.Points.Add(0, dt, dt.AddDays(2)); Completion.Points.Add(1, dt.AddDays(1), dt.AddDays(2)); Completion.Points.Add(2, dt.AddDays(3), dt.AddDays(5)); Completion.Points.Add(3, dt.AddDays(6), dt.AddDays(9)); Completion.Points.Add(4, dt.AddDays(10), dt.AddDays(13)); Completion.Points.Add(5, dt.AddDays(15), dt.AddDays(18)); Completion.Style.PointWidth = 0.5f; this.chartControl1.Series.Add(Completion); Completion.PointsToolTipFormat = "{1}{2}"; ChartSeries Task = new ChartSeries("Task", ChartSeriesType.Gantt); Task.Points.Add(0, dt, dt.AddDays(2)); Task.Points.Add(1, dt.AddDays(1), dt.AddDays(3)); Task.Points.Add(2, dt.AddDays(3), dt.AddDays(6)); Task.Points.Add(3, dt.AddDays(6), dt.AddDays(10)); Task.Points.Add(4, dt.AddDays(10), dt.AddDays(15)); Task.Points.Add(5, dt.AddDays(15), dt.AddDays(20)); // Make a note of the last day: DateTime lastDay = DateTime.FromOADate(Task.Points[Task.Points.Count - 1].YValues[1]); Task.Style.PointWidth = 0.75f; this.chartControl1.Series.Add(Task); Task.PointsToolTipFormat = "{1}{2}"; this.chartControl1.ShowToolTips = true; this.chartControl1.CalcRegions = true; this.chartControl1.PrimaryXAxis.RangeType = ChartAxisRangeType.Set; this.chartControl1.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(dt, lastDay.AddDays(2), 1, ChartDateTimeIntervalType.Days); // Displays custom into on Points for (int i = 0; i < this.chartControl1.Series[0].Points.Count; i++) { if (this.chartControl1.Series[1].Points[i].YValues[0] != this.chartControl1.Series[1].Points[i].YValues[1]) { ChartCustomPoint ccp = new ChartCustomPoint(); ChartPoint pt = this.chartControl1.Series[1].Points[i]; ccp.XValue = pt.X; ccp.YValue = pt.YValues[0] + 1; ccp.CustomType = ChartCustomPointType.ChartCoordinates; ccp.Text = String.Format("{0} days", pt.YValues[1] - pt.YValues[0]); ccp.Color = Color.White; ccp.Font.Facename = "Segoe UI"; this.chartControl1.CustomPoints.Add(ccp); } } // To indicate weekends Color[] stripLineColor = new Color[] { Color.LightGray, Color.WhiteSmoke, Color.LightGray }; //Chart Strip Lines ChartStripLine stripLine1 = new ChartStripLine(); stripLine1.Enabled = true; stripLine1.Vertical = false; stripLine1.StartDate = dt.AddDays(2); //// We know that Jan 3rd is a Saturday. stripLine1.EndDate = lastDay; stripLine1.Width = 2; // Repetition frequency: every 7 days stripLine1.PeriodDate = new TimeSpan(7, 0, 0, 0); stripLine1.Text = string.Empty; stripLine1.Interior = new BrushInfo(GradientStyle.ForwardDiagonal, stripLineColor); this.chartControl1.PrimaryXAxis.StripLines.Add(stripLine1); this.chartControl1.Series[0].PrepareStyle += new ChartPrepareStyleInfoHandler(Form1_PrepareStyle); this.chartControl1.Series[1].PrepareStyle += new ChartPrepareStyleInfoHandler(Form1_PrepareStyle); }