// METHODS internal override void Set(DataPointCustomProperties element) { if (element is Series) { ((Series)element).MarkerStep = Step; } base.Set(element); }
/// <summary> /// Gets marker border size. /// </summary> /// <param name="point">Data point.</param> /// <returns>Marker border size.</returns> override protected int GetMarkerBorderSize(DataPointCustomProperties point) { if (point.series != null) { return(point.series.BorderWidth); } return(1); }
// METHODS internal virtual void Set(DataPointCustomProperties element) { element.MarkerBorderColor = BorderColor; element.MarkerBorderWidth = BorderWidth; element.MarkerColor = Color; element.MarkerImage = Image; element.MarkerImageTransparentColor = ImageTransparentColor; element.MarkerSize = Size; element.MarkerStyle = Style; }
// METHODS internal virtual void Set(DataPointCustomProperties element) { element.Label = Text; element.LabelAngle = Angle; element.LabelBackColor = BackColor; element.LabelBorderColor = BorderColor; element.LabelBorderDashStyle = BorderDashStyle; element.LabelBorderWidth = BorderWidth; element.LabelForeColor = ForeColor; element.LabelFormat = Format; element.LabelToolTip = ToolTip; }
public void addSeriesParams(int numSamples, List <Tuple <string, Color> > seriesParams) { // record the capacity of X-axis _numSamples = numSamples; foreach (var param in seriesParams) { string seriesName = param.Item1; var series = new Series(seriesName); series.Color = param.Item2; series.ChartArea = _chartAreaName; series.ChartType = SeriesChartType.Line; // type series.BorderWidth = 2; series.XValueType = ChartValueType.Int32; //x axis type series.YValueType = ChartValueType.Double; //y axis type // series.YValuesPerPoint = 6; //Marker series.MarkerStyle = MarkerStyle.Star4; series.MarkerSize = 10; series.MarkerStep = 1; series.MarkerColor = Color.Red; series.LabelFormat = "{0:N4}"; //Label series.IsValueShownAsLabel = true; series.SmartLabelStyle.Enabled = false; series.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes; series.LabelForeColor = Color.Gray; //Empty Point Style DataPointCustomProperties p = new DataPointCustomProperties(); p.Color = Color.Green; series.EmptyPointStyle = p; //Legend series.LegendText = seriesName; series.LegendToolTip = @"LegendToolTip"; _seriesList.Add(series); _chart.Series.Add(series); _chart.Legends.Add(new Legend(seriesName)); } }
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { string stringValue = value as string; if (stringValue != null && context != null && context.Instance != null) { // Create new custom attribute class with a reference to the DataPointCustomProperties if (context.Instance is DataPointCustomProperties) { ((DataPointCustomProperties)context.Instance).CustomProperties = stringValue; CustomProperties newAttributes = new CustomProperties(((DataPointCustomProperties)context.Instance)); return(newAttributes); } else if (context.Instance is CustomProperties) { CustomProperties newAttributes = new CustomProperties(((CustomProperties)context.Instance).DataPointCustomProperties); return(newAttributes); } else if (context.Instance is IDataPointCustomPropertiesProvider) { CustomProperties newAttributes = new CustomProperties(((IDataPointCustomPropertiesProvider)context.Instance).DataPointCustomProperties); return(newAttributes); } else if (context.Instance is Array) { DataPointCustomProperties attributes = null; foreach (object obj in ((Array)context.Instance)) { if (obj is DataPointCustomProperties) { attributes = (DataPointCustomProperties)obj; attributes.CustomProperties = stringValue; } } if (attributes != null) { CustomProperties newAttributes = new CustomProperties(attributes); return(newAttributes); } } } return(base.ConvertFrom(context, culture, value)); }
private void firstSeries() { // chartArea ChartArea chartArea = new ChartArea(); chartArea.Name = "First Area"; chart1.ChartAreas.Add(chartArea); chartArea.BackColor = Color.Azure; chartArea.BackGradientStyle = GradientStyle.HorizontalCenter; chartArea.BackHatchStyle = ChartHatchStyle.LargeGrid; chartArea.BorderDashStyle = ChartDashStyle.Solid; chartArea.BorderWidth = 1; chartArea.BorderColor = Color.Red; chartArea.ShadowColor = Color.Purple; chartArea.ShadowOffset = 0; // chart1.ChartAreas[0].Axes[0].MajorGrid.Enabled = false;//x axis // chart1.ChartAreas[0].Axes[1].MajorGrid.Enabled = false;//y axis //Cursor:only apply the top area chartArea.CursorX.IsUserEnabled = true; chartArea.CursorX.AxisType = AxisType.Primary;//act on primary x axis chartArea.CursorX.Interval = 1; chartArea.CursorX.LineWidth = 1; chartArea.CursorX.LineDashStyle = ChartDashStyle.Dash; chartArea.CursorX.IsUserSelectionEnabled = true; chartArea.CursorX.SelectionColor = Color.Yellow; chartArea.CursorX.AutoScroll = true; chartArea.CursorY.IsUserEnabled = true; chartArea.CursorY.AxisType = AxisType.Primary;//act on primary y axis chartArea.CursorY.Interval = 1; chartArea.CursorY.LineWidth = 1; chartArea.CursorY.LineDashStyle = ChartDashStyle.Dash; chartArea.CursorY.IsUserSelectionEnabled = true; chartArea.CursorY.SelectionColor = Color.Yellow; chartArea.CursorY.AutoScroll = true; // Axis chartArea.AxisY.Minimum = -10d;//Y axis Minimum value chartArea.AxisY.Title = @"Consumption Value"; //chartArea.AxisY.Maximum = 100d;//Y axis Maximum value chartArea.AxisX.Minimum = 0d; //X axis Minimum value chartArea.AxisX.Maximum = 12d; chartArea.AxisX.IsLabelAutoFit = true; //chartArea.AxisX.LabelAutoFitMaxFontSize = 12; chartArea.AxisX.LabelAutoFitMinFontSize = 5; chartArea.AxisX.LabelStyle.Angle = -20; chartArea.AxisX.LabelStyle.IsEndLabelVisible = true;//show the last label chartArea.AxisX.Interval = 1; chartArea.AxisX.IntervalAutoMode = IntervalAutoMode.FixedCount; chartArea.AxisX.IntervalType = DateTimeIntervalType.NotSet; chartArea.AxisX.Title = @"Month"; chartArea.AxisX.TextOrientation = TextOrientation.Auto; chartArea.AxisX.LineWidth = 2; chartArea.AxisX.LineColor = Color.DarkOrchid; chartArea.AxisX.Enabled = AxisEnabled.True; chartArea.AxisX.ScaleView.MinSizeType = DateTimeIntervalType.Months; chartArea.AxisX.ScrollBar = new AxisScrollBar(); //Series Series series = new Series(); series.ChartArea = "First Area"; chart1.Series.Add(series); //Series style series.Name = @"series:Test One"; series.ChartType = SeriesChartType.Line; // type series.BorderWidth = 2; series.Color = Color.Green; series.XValueType = ChartValueType.Int32; //x axis type series.YValueType = ChartValueType.Int32; //y axis type // series.YValuesPerPoint = 6; //Marker series.MarkerStyle = MarkerStyle.Star4; series.MarkerSize = 10; series.MarkerStep = 1; series.MarkerColor = Color.Red; series.ToolTip = @"ToolTip"; //Label series.IsValueShownAsLabel = true; series.SmartLabelStyle.Enabled = false; series.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes; series.LabelForeColor = Color.Gray; series.LabelToolTip = @"LabelToolTip"; //Empty Point Style DataPointCustomProperties p = new DataPointCustomProperties(); p.Color = Color.Green; series.EmptyPointStyle = p; //Legend series.LegendText = "LegendText:Test One"; series.LegendToolTip = @"LegendToolTip"; float[] values = { 0, 70, 90, 20, 70, 220, 30, 60, 30, 81, 10, 39 }; int x = 1; foreach (float v in values) { series.Points.AddXY(x, v); x++; } }
private void firstSeries() { ChartArea chartArea = new ChartArea(); chartArea.Name = "First Area"; chart.ChartAreas.Add(chartArea); chartArea.BackColor = Color.Azure; chartArea.BackGradientStyle = GradientStyle.HorizontalCenter; chartArea.BackHatchStyle = ChartHatchStyle.LargeGrid; chartArea.BorderDashStyle = ChartDashStyle.Solid; chartArea.BorderWidth = 1; chartArea.BorderColor = Color.Red; chartArea.ShadowColor = Color.Purple; chartArea.ShadowOffset = 0; chart.ChartAreas[0].Axes[0].MajorGrid.Enabled = false; chart.ChartAreas[0].Axes[1].MajorGrid.Enabled = false; chartArea.CursorX.IsUserEnabled = true; chartArea.CursorX.AxisType = AxisType.Primary; chartArea.CursorX.Interval = 1; chartArea.CursorX.LineWidth = 1; chartArea.CursorX.LineDashStyle = ChartDashStyle.Dash; chartArea.CursorX.IsUserSelectionEnabled = true; chartArea.CursorX.SelectionColor = Color.Yellow; chartArea.CursorX.AutoScroll = true; chartArea.CursorY.IsUserEnabled = true; chartArea.CursorY.AxisType = AxisType.Primary; chartArea.CursorY.Interval = 1; chartArea.CursorY.LineWidth = 1; chartArea.CursorY.LineDashStyle = ChartDashStyle.Dash; chartArea.CursorY.IsUserSelectionEnabled = true; chartArea.CursorY.SelectionColor = Color.Yellow; chartArea.CursorY.AutoScroll = true; chartArea.AxisY.Title = @"Adım Sayısı - Kazanç"; chartArea.AxisX.Minimum = 0d; chartArea.AxisX.Maximum = Convert.ToDouble(Game.SuccessScore.Count); chartArea.AxisX.IsLabelAutoFit = true; chartArea.AxisX.LabelAutoFitMinFontSize = 5; chartArea.AxisX.LabelStyle.Angle = -20; chartArea.AxisX.LabelStyle.IsEndLabelVisible = true; chartArea.AxisX.Interval = 1; chartArea.AxisX.IntervalAutoMode = IntervalAutoMode.FixedCount; chartArea.AxisX.IntervalType = DateTimeIntervalType.NotSet; chartArea.AxisX.Title = @"İterasyonlar"; chartArea.AxisX.TextOrientation = TextOrientation.Auto; chartArea.AxisX.LineWidth = 2; chartArea.AxisX.LineColor = Color.DarkOrchid; chartArea.AxisX.Enabled = AxisEnabled.True; chartArea.AxisX.ScaleView.MinSizeType = DateTimeIntervalType.Months; chartArea.AxisX.ScrollBar = new AxisScrollBar(); Series series1 = new Series(); series1.ChartArea = "First Area"; chart.Series.Add(series1); series1.Name = @"series:Test One"; series1.ChartType = SeriesChartType.Line; series1.BorderWidth = 2; series1.Color = Color.Blue; series1.XValueType = ChartValueType.Int32; series1.YValueType = ChartValueType.Int32; series1.MarkerStyle = MarkerStyle.Circle; series1.MarkerSize = 8; series1.MarkerStep = 1; series1.MarkerColor = Color.Blue; series1.ToolTip = @"ToolTip"; series1.IsValueShownAsLabel = true; series1.SmartLabelStyle.Enabled = true; series1.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes; series1.LabelForeColor = Color.Gray; series1.LabelToolTip = @"LabelToolTip"; series1.Label = "#VALY{#.###}"; DataPointCustomProperties p = new DataPointCustomProperties(); p.Color = Color.Blue; series1.EmptyPointStyle = p; series1.IsVisibleInLegend = true; series1.LegendText = "Kazanç"; series1.LegendToolTip = @"LegendToolTip"; int x = 0; foreach (float v in Game.SuccessScore) { series1.Points.AddXY(x, v); x++; } }
public static Chart MakeChart(double[] alphas) { Chart chart1 = new Chart(); chart1.Location = new Point(10, 10); chart1.Width = 1200; chart1.Height = 600; // chartArea ChartArea chartArea = new ChartArea(); chartArea.Name = "First Area"; chart1.ChartAreas.Add(chartArea); chartArea.BackColor = Color.Azure; chartArea.BackGradientStyle = GradientStyle.HorizontalCenter; chartArea.BackHatchStyle = ChartHatchStyle.LargeGrid; chartArea.BorderDashStyle = ChartDashStyle.Solid; chartArea.BorderWidth = 1; chartArea.BorderColor = Color.Red; chartArea.ShadowColor = Color.Purple; chartArea.ShadowOffset = 0; chart1.ChartAreas[0].Axes[0].MajorGrid.Enabled = false; //x axis chart1.ChartAreas[0].Axes[1].MajorGrid.Enabled = false; //y axis //Cursor:only apply the top area chartArea.CursorX.IsUserEnabled = true; chartArea.CursorX.AxisType = AxisType.Primary;//act on primary x axis chartArea.CursorX.Interval = 1; chartArea.CursorX.LineWidth = 1; chartArea.CursorX.LineDashStyle = ChartDashStyle.Dash; chartArea.CursorX.IsUserSelectionEnabled = true; chartArea.CursorX.SelectionColor = Color.Yellow; chartArea.CursorX.AutoScroll = true; chartArea.CursorY.IsUserEnabled = true; chartArea.CursorY.AxisType = AxisType.Primary;//act on primary y axis chartArea.CursorY.Interval = 1; chartArea.CursorY.LineWidth = 1; chartArea.CursorY.LineDashStyle = ChartDashStyle.Dash; chartArea.CursorY.IsUserSelectionEnabled = true; chartArea.CursorY.SelectionColor = Color.Yellow; chartArea.CursorY.AutoScroll = true; // Axis chartArea.AxisY.Minimum = 0d;//Y axis Minimum value chartArea.AxisY.Title = @"Percentage of rotations with lower alpha (from 1000)"; //chartArea.AxisY.Maximum = 100d;//Y axis Maximum value chartArea.AxisX.Minimum = 0d; //X axis Minimum value chartArea.AxisX.Maximum = 180d; chartArea.AxisX.IsLabelAutoFit = true; //chartArea.AxisX.LabelAutoFitMaxFontSize = 12; chartArea.AxisX.LabelAutoFitMinFontSize = 5; chartArea.AxisX.LabelStyle.Angle = -20; chartArea.AxisX.LabelStyle.IsEndLabelVisible = true;//show the last label chartArea.AxisX.Interval = 1; chartArea.AxisX.IntervalAutoMode = IntervalAutoMode.FixedCount; chartArea.AxisX.IntervalType = DateTimeIntervalType.NotSet; chartArea.AxisX.Title = @"Alpha"; chartArea.AxisX.TextOrientation = TextOrientation.Auto; chartArea.AxisX.LineWidth = 2; chartArea.AxisX.LineColor = Color.DarkOrchid; chartArea.AxisX.Enabled = AxisEnabled.True; chartArea.AxisX.ScaleView.MinSizeType = DateTimeIntervalType.Months; chartArea.AxisX.ScrollBar = new AxisScrollBar(); //Series Series series1 = new Series(); series1.ChartArea = "First Area"; chart1.Series.Add(series1); //Series style series1.Name = @"series:Test One"; series1.ChartType = SeriesChartType.Line; // type series1.BorderWidth = 2; series1.Color = Color.Green; series1.XValueType = ChartValueType.Int32; //x axis type series1.YValueType = ChartValueType.Int32; //y axis type // series.YValuesPerPoint = 6; //Marker //series1.MarkerStyle = MarkerStyle.Star4; //series1.MarkerSize = 10; //series1.MarkerStep = 1; //series1.MarkerColor = Color.Red; //series1.ToolTip = @"ToolTip"; //Label series1.IsValueShownAsLabel = true; series1.SmartLabelStyle.Enabled = false; series1.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes; series1.LabelForeColor = Color.Gray; series1.LabelToolTip = @"LabelToolTip"; //Empty Point Style DataPointCustomProperties p = new DataPointCustomProperties(); p.Color = Color.Green; series1.EmptyPointStyle = p; //Legend series1.LegendText = "Normal matcher"; series1.LegendToolTip = @"LegendToolTip"; for (int i = 0; i <= 180; i += 1) { int count = 0; for (int j = 0; j < 1000; j++) { if (alphas[j] <= i) { count++; } } double a = count / 10.0; series1.Points.AddXY(i, a); } return(chart1); }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value is MarkerStyle) { // Create chart graphics object if (_chartGraph == null) { _chartGraph = new ChartGraphics(null); } _chartGraph.Graphics = e.Graphics; // Get marker properties DataPointCustomProperties attributes = null; if (e.Context != null && e.Context.Instance != null) { // Check if several object selected object attrObject = e.Context.Instance; if (e.Context.Instance is Array) { Array array = (Array)e.Context.Instance; if (array.Length > 0) { attrObject = array.GetValue(0); } } // Check what kind of object is selected if (attrObject is Series) { attributes = (DataPointCustomProperties)attrObject; } else if (attrObject is DataPoint) { attributes = (DataPointCustomProperties)attrObject; } else if (attrObject is DataPointCustomProperties) { attributes = (DataPointCustomProperties)attrObject; } else if (attrObject is LegendItem) { attributes = new DataPointCustomProperties(); attributes.MarkerColor = ((LegendItem)attrObject).markerColor; attributes.MarkerBorderColor = ((LegendItem)attrObject).markerBorderColor; attributes.MarkerSize = ((LegendItem)attrObject).markerSize; } } // Draw marker sample if (attributes != null && (MarkerStyle)e.Value != MarkerStyle.None) { PointF point = new PointF(e.Bounds.X + ((float)e.Bounds.Width) / 2F - 0.5F, e.Bounds.Y + ((float)e.Bounds.Height) / 2F - 0.5F); Color color = (attributes.MarkerColor == Color.Empty) ? Color.Black : attributes.MarkerColor; int size = attributes.MarkerSize; if (size > (e.Bounds.Height - 4)) { size = e.Bounds.Height - 4; } _chartGraph.DrawMarkerAbs( point, (MarkerStyle)e.Value, size, color, attributes.MarkerBorderColor, attributes.MarkerBorderWidth, "", Color.Empty, 0, Color.Empty, RectangleF.Empty, true); } } }