private void MakeChart() { var chartArea = new ChartArea("Chart1"); ChartAreas.Add(chartArea); Legends.Add("Chart1"); if (graphicsSettings.ExactSolution) { MakeSeries(Algorithms.ExactSolution, "Chart1", "Точное решение", this, paletteSettings.ExactSolution, graphicsSettings.ExactSolutionBorderWidth); } if (graphicsSettings.ExplicitEulerMethod) { MakeSeries(Algorithms.ExplicitEulerMethod, "Chart1", "Явный метод Эйлера", this, paletteSettings.ExplicitEulerMethod, graphicsSettings.ExplicitEulerMethodBorderWidth); } if (graphicsSettings.RungeKuttaMethod) { MakeSeries(Algorithms.RungeKuttaMethod, "Chart1", "Метод Рунге-Кутта", this, paletteSettings.RungeKuttaMethod, graphicsSettings.RungeKuttaMethodBorderWidth); } if (graphicsSettings.TrapeziumMethod) { MakeSeries(Algorithms.TrapeziumMethod, "Chart1", "Метод трапеций", this, paletteSettings.TrapeziumMethod, graphicsSettings.TrapeziumMethodBorderWidth); } }
private void MakeChart() { var chartArea = new ChartArea("Chart1"); ChartAreas.Add(chartArea); Legends.Add("Chart1"); if (graphicsSettings.ExactSolution) { MakeSeries(Algorithms.ExactSolution, "Chart1", "Точное решение", this, paletteSettings.ExactSolution, graphicsSettings.ExactSolutionBorderWidth); } if (graphicsSettings.DifferentialSweepMethod) { MakeSeries(Algorithms.DifferentialSweepMethod, "Chart1", "Метод разностной прогонки", this, paletteSettings.DifferentialSweepMethod, graphicsSettings.DifferentialSweepMethodBorderWidth); } if (graphicsSettings.ShootingMethod) { MakeSeries(Algorithms.ShootingMethod, "Chart1", "Метод стрельбы", this, paletteSettings.ShootingMethod, graphicsSettings.ShootingMethodBorderWidth); } }
public ScaledPlotModel(double dpiXscale, double dpiYscale) { PlotMargins = new OxyThickness(PlotMargins.Left * dpiXscale, PlotMargins.Top * dpiYscale, PlotMargins.Right * dpiXscale, PlotMargins.Bottom * dpiYscale); Padding = new OxyThickness(Padding.Left * dpiXscale, Padding.Top * dpiYscale, Padding.Right * dpiXscale, Padding.Bottom * dpiYscale); TitlePadding *= dpiXscale; Legend legend = new(); legend.LegendSymbolLength *= dpiXscale; legend.LegendSymbolMargin *= dpiXscale; legend.LegendPadding *= dpiXscale; legend.LegendColumnSpacing *= dpiXscale; legend.LegendItemSpacing *= dpiXscale; legend.LegendMargin *= dpiXscale; Legends.Add(legend); }
protected virtual void ReadLegend(XmlTextReader xml) { //Int32 index = Convert.ToInt32(xml.GetAttribute("index")); iText.Kernel.Colors.DeviceRgb iTextColour = new DeviceRgb(); ReadColour(xml, ref iTextColour, "colour"); String label = xml.GetAttribute("label"); Legends.Add(new Legend(label, iTextColour)); mColours.Add(iTextColour); }
/// <summary> /// Override in derived class to add legend. /// You might wanna include execution of the base method. /// </summary> protected virtual void addLegend() { if (showLegend) { Legends.Add( new Legend("Main") { Position = new ElementPosition(0, 98 - legendHeight - SpaceUsedForInfoText, 100, legendHeight), LegendItemOrder = LegendItemOrder.ReversedSeriesOrder } ); } }
private void button1_Click(object sender, EventArgs e) { if (amount_voices >= 10) { MessageBox.Show("Превышено количество добавлений"); } else { Legends.Add(textBox3.Text); Voices.Add(int.Parse(textBox2.Text)); amount_voices++; LoadLegends(); } }
private void SetupLegend() { if (Series.Count <= 1) { return; } var legend = new Legend(); legend.LegendStyle = LegendStyle.Table; legend.TableStyle = LegendTableStyle.Auto; legend.Docking = Docking.Bottom; Legends.Add(legend); }
public ChartControl(List <Series> seriesList, string name) : base() { Name = name; MaxPoints = 1000; title = new Title(Name); ChartArea = new ChartArea("ChartArea"); ChartArea.AxisX.Enabled = AxisEnabled.False; ChartArea.AxisY.IsStartedFromZero = false; ChartArea.AxisY.Enabled = AxisEnabled.False; ChartArea.AxisY2.Enabled = AxisEnabled.False; ChartArea.AxisX.LabelStyle.Enabled = false; ChartArea.AxisY.LabelStyle.Enabled = false; ChartArea.AxisY2.LabelStyle.Enabled = false; ChartArea.Position.X = 0; ChartArea.Position.Y = 40; ChartArea.Position.Height = 60; ChartArea.Position.Width = 100; //chartArea.AxisY2.Title = "kVAR"; //chartArea.AxisY.Title = "W"; //chartArea.AxisY.LabelStyle.IsEndLabelVisible = true; Legends.Add(new Legend("LeftLegend") { Enabled = false, LegendStyle = LegendStyle.Column, }); Legends.Add(new Legend("RightLegend") { Enabled = false, LegendStyle = LegendStyle.Column, }); ChartAreas.Add(ChartArea); Titles.Add(title); if (seriesList != null) { foreach (Series series in seriesList) { Series.Add(series); } } }
/// <summary> /// Add legend /// </summary> protected override void addLegend() { if (showLegend) { LegendItemOrder order = LegendItemOrder.ReversedSeriesOrder; if ((ChartTypes.Length == 1) && (ChartTypes[0] == SeriesChartType.Pie)) { order = LegendItemOrder.SameAsSeriesOrder; } Legends.Add( new Legend("Main") { Position = new ElementPosition(0, 98 - legendHeight - SpaceUsedForInfoText - 1, 100, legendHeight), LegendItemOrder = order } ); } }
protected override void Initialize() { ChartAreas.Add(new ChartArea("Distance")); Legends.Add(new Legend { LegendStyle = LegendStyle.Row, Alignment = StringAlignment.Center, Docking = Docking.Top }); // prepare series Series.Add(new Series("Running") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Double, ChartType = SeriesChartType.StackedColumn, Color = Color.RoyalBlue }); Series.Add(new Series("Cycling") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Double, ChartType = SeriesChartType.StackedColumn, Color = Color.Green, }); // prepare axes var x = ChartAreas[0].AxisX; var y = ChartAreas[0].AxisY; // x x.IntervalAutoMode = IntervalAutoMode.FixedCount; x.IntervalOffsetType = DateTimeIntervalType.Days; // y y.IntervalAutoMode = IntervalAutoMode.VariableCount; y.LabelStyle.Format = "{0} km"; }
public FitnessGraph(Size size) { font = new Font("Microsoft Sans Serif", 8F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); CreateTitle(); Size = size; BorderlineColor = SystemColors.ControlDark; BorderlineDashStyle = ChartDashStyle.Solid; graph = CreateChart(); ChartAreas.Add(graph); graphLegend = CreateLegend(); Legends.Add(graphLegend); averageFitness = CreateAvgFitness(); bestAgent = CreateBestAgent(); topAverage = CreateTopAverage(); Series.Add(averageFitness); Series.Add(topAverage); Series.Add(bestAgent); }
private void GetLegends() { if (Legends == null) { Legends = GenerateLegends(); return; } if (Items == null) { return; } // add missed legends Random rand = new Random(DateTime.Now.Millisecond); foreach (var item in Items) { var legendValue = item.GetType().GetProperty(LegendPropertyName).GetValue(item, null); var leg = from Legend lc in Legends where lc.LegendType.Equals(legendValue) select lc; if (leg.Count() == 0) { Legend legend = new Legend(); legend.LegendType = legendValue; Color c = Color.FromRgb(Convert.ToByte(rand.Next(256)), Convert.ToByte(rand.Next(256)), Convert.ToByte(rand.Next(256))); legend.Brush = new SolidColorBrush(c); Legends.Add(legend); } } // update event handlers foreach (var legend in Legends) { legend.IsVisibleChanged += (s, e) => Draw(false); } }
public ChartTi() { BackColor = Supports.headGrey; ForeColor = Supports.textWhite; chartArea.AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount; chartArea.AxisX2.IntervalAutoMode = IntervalAutoMode.VariableCount; chartArea.AxisY.IntervalAutoMode = IntervalAutoMode.VariableCount; chartArea.AxisY2.IntervalAutoMode = IntervalAutoMode.VariableCount; chartArea.Name = "chartArea"; ChartAreas.Add(chartArea); chartArea.BackColor = Supports.headGrey; chartArea.AxisX.LineColor = Supports.textBlack; chartArea.AxisY.LineColor = Supports.textBlack; chartArea.AxisX.MajorGrid.LineColor = Supports.textBlack; chartArea.AxisY.MajorGrid.LineColor = Supports.textBlack; chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash; chartArea.AxisX.IntervalType = DateTimeIntervalType.Days; chartArea.AxisX.Interval = 1; chartArea.AxisX.ScaleView.Zoomable = true; chartArea.CursorX.AutoScroll = true; chartArea.CursorX.IsUserSelectionEnabled = true; chartArea.AxisX.LabelStyle.ForeColor = Supports.textWhite; chartArea.AxisY.LabelStyle.ForeColor = Supports.textWhite; chartArea.AxisY.MajorGrid.LineColor = Supports.textBlack; chartArea.AxisX.InterlacedColor = Supports.textBlack; chartArea.AxisY.InterlacedColor = Supports.textBlack; chartArea.AxisX.TitleForeColor = Supports.textWhite; chartArea.AxisY.TitleForeColor = Supports.textWhite; chartArea.AxisX.LabelStyle.Format = "dd.MM.yyyy"; chartArea.AxisX.TitleFont = new Font("Times New Roman", 15); chartArea.AxisY.TitleFont = new Font("Times New Roman", 15); chartArea.AxisY.TextOrientation = TextOrientation.Rotated270; Point? prevPosition = null; ToolTip toolTip = new ToolTip(); MouseMove += (s, e) => { var pos = e.Location; if (prevPosition.HasValue && pos == prevPosition.Value) { return; } toolTip.RemoveAll(); prevPosition = pos; var results = HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint); foreach (var result in results) { if (result.ChartElementType == ChartElementType.DataPoint) { var prop = result.Object as DataPoint; if (prop != null) { var pointXPixel = result.ChartArea.AxisX.ValueToPixelPosition(prop.XValue); var pointYPixel = result.ChartArea.AxisY.ValueToPixelPosition(prop.YValues[0]); if (Math.Abs(pos.X - pointXPixel) < 4) { toolTip.Show("Время - " + DateTime.FromOADate(prop.XValue), this, pos.X, pos.Y); } } } } }; legend.BackColor = Supports.headGrey; legend.ForeColor = Supports.textWhite; legend.TitleForeColor = Supports.textWhite; legend.DockedToChartArea = "chartArea"; legend.Docking = Docking.Left; legend.IsDockedInsideChartArea = false; legend.LegendStyle = LegendStyle.Column; legend.Name = "Legend"; legend.TableStyle = LegendTableStyle.Tall; legend.Title = "Обозначения"; Legends.Add(legend); }
private void InitializeComponent() { var chartArea1 = this.ChartAreas.Add("ChartArea1"); var legend1 = new Legend(); var title1 = new Title(); chartArea1.AxisX = new Axis(chartArea1, AxisName.X) { ArrowStyle = AxisArrowStyle.Lines, Crossing = 0D, InterlacedColor = Color.White, IsLabelAutoFit = false, LabelAutoFitMaxFontSize = 13, LabelStyle = new LabelStyle() { Font = new Font("Microsoft Sans Serif", 9F, FontStyle.Regular, GraphicsUnit.Point, 238) }, LineWidth = 2, MajorGrid = new Grid() { LineDashStyle = ChartDashStyle.Dash }, MajorTickMark = new TickMark() { Size = 2F, TickMarkStyle = TickMarkStyle.AcrossAxis }, MinorGrid = new Grid() { Enabled = true, LineColor = Color.DarkGray, LineDashStyle = ChartDashStyle.Dot }, MinorTickMark = new TickMark() { Enabled = true, TickMarkStyle = TickMarkStyle.AcrossAxis }, Title = "X", TitleAlignment = StringAlignment.Far, TitleFont = new Font("Microsoft Sans Serif", 18F, FontStyle.Bold, GraphicsUnit.Point, 238) }; chartArea1.AxisY = new Axis(chartArea1, AxisName.Y) { ArrowStyle = AxisArrowStyle.Lines, Crossing = 0D, InterlacedColor = Color.White, IsLabelAutoFit = false, LabelAutoFitMaxFontSize = 13, LabelStyle = new LabelStyle() { Font = new Font("Microsoft Sans Serif", 9F, FontStyle.Regular, GraphicsUnit.Point, 238) }, LineWidth = 2, MajorGrid = new Grid() { LineDashStyle = ChartDashStyle.Dash }, MajorTickMark = new TickMark() { Size = 2F, TickMarkStyle = TickMarkStyle.AcrossAxis }, MinorGrid = new Grid() { Enabled = true, LineColor = Color.DarkGray, LineDashStyle = ChartDashStyle.Dot }, MinorTickMark = new TickMark() { Enabled = true, TickMarkStyle = TickMarkStyle.AcrossAxis }, TextOrientation = TextOrientation.Horizontal, Title = "Y", TitleAlignment = StringAlignment.Far, TitleFont = new Font("Microsoft Sans Serif", 18F, FontStyle.Bold, GraphicsUnit.Point, 238) }; //By default, if I select a rectangular area using the mouse, the chart will zoom to the selected area. //But this is quite annoying because it is prone to false operation chartArea1.CursorX = new System.Windows.Forms.DataVisualization.Charting.Cursor { IsUserEnabled = false, IsUserSelectionEnabled = false }; legend1.Font = CustomFonts.GetMathFont(13.8F); //new Font("Cambria", 13.8F); legend1.IsTextAutoFit = false; legend1.Name = "Legend1"; Legends.Add(legend1); //this.N = 0D; Name = "chart2d"; title1.Font = new Font("Microsoft Sans Serif", 22.2F, FontStyle.Bold, GraphicsUnit.Point, 238); title1.Name = "Title1"; Titles.Add(title1); Dock = DockStyle.Fill; ChartAreas[0].AxisX.ScaleView.MinSize = 0.1; ChartAreas[0].AxisY.ScaleView.MinSize = 0.1; Legends[0].Font = CustomFonts.GetMathFont(Legends[0].Font.Size); const float fontsize = 17.0F; Font = CustomFonts.GetMathFont(fontsize); }
protected override void Initialize() { ChartAreas.Add(new ChartArea("Biodata")); Legends.Add(new Legend { LegendStyle = LegendStyle.Row, Alignment = StringAlignment.Center, Docking = Docking.Top }); // prepare series Series.Add(new Series("Resting Heart Rate") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Int32, ChartType = SeriesChartType.Spline, BorderWidth = 7, Color = Color.RoyalBlue }); Series.Add(new Series("Average Resting Heart Rate") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Double, ChartType = SeriesChartType.Spline, BorderWidth = 1, Color = Color.Turquoise, IsValueShownAsLabel = true }); Series.Add(new Series("Local Average Resting Heart Rate") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Double, ChartType = SeriesChartType.Spline, BorderWidth = 3, Color = Color.Purple }); Series.Add(new Series("OwnIndex") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Int32, ChartType = SeriesChartType.Spline, IsValueShownAsLabel = true, BorderWidth = 7, Color = Color.Green }); Series.Add(new Series("Weight") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Double, ChartType = SeriesChartType.Spline, BorderWidth = 7, Color = Color.Red, IsValueShownAsLabel = true }); Series.Add(new Series("Niggles") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Int32, ChartType = SeriesChartType.Point, MarkerSize = 10, MarkerStyle = MarkerStyle.Cross, Color = Color.DarkOrange }); Series.Add(new Series("Notes") { XValueType = ChartValueType.Date, YValueType = ChartValueType.Int32, ChartType = SeriesChartType.Point, MarkerSize = 10, MarkerStyle = MarkerStyle.Square, Color = Color.Yellow }); // prepare axes var x = ChartAreas[0].AxisX; var y = ChartAreas[0].AxisY; // x x.IntervalAutoMode = IntervalAutoMode.FixedCount; x.IntervalType = DateTimeIntervalType.Days; x.Interval = 1; // y y.IntervalAutoMode = IntervalAutoMode.FixedCount; y.IntervalType = DateTimeIntervalType.Number; y.Interval = 5; }
private void Gestion_legend(Legend leg) { leg.Title = "légende"; leg.Name = "legend"; leg.BackColor = Color.WhiteSmoke; leg.BackSecondaryColor = Color.White; leg.BackGradientStyle = GradientStyle.DiagonalLeft; leg.BorderColor = Color.Black; leg.BorderWidth = 2; leg.TitleSeparator = LegendSeparatorStyle.Line; leg.BorderDashStyle = ChartDashStyle.Solid; leg.ShadowOffset = 2; leg.Alignment = StringAlignment.Center; leg.InsideChartArea = ""; leg.Docking = Docking.Bottom; // Add header separator of type line leg.HeaderSeparator = LegendSeparatorStyle.Line; leg.HeaderSeparatorColor = Color.Gray; // Add Color column LegendCellColumn firstColumn = new LegendCellColumn() { ColumnType = LegendCellColumnType.SeriesSymbol, HeaderText = "Color", HeaderBackColor = Color.WhiteSmoke }; leg.CellColumns.Add(firstColumn); // Add Legend Text column LegendCellColumn secondColumn = new LegendCellColumn() { ColumnType = LegendCellColumnType.Text, HeaderText = "Name", Text = "#LEGENDTEXT", HeaderBackColor = Color.WhiteSmoke }; leg.CellColumns.Add(secondColumn); // Add AVG cell column LegendCellColumn avgColumn = new LegendCellColumn() { Text = "#AVG{N2}", HeaderText = "Avg", Name = "AvgColumn", HeaderBackColor = Color.WhiteSmoke }; leg.CellColumns.Add(avgColumn); // Add Max cell column LegendCellColumn maxColumn = new LegendCellColumn() { Text = "#MAX{N1}", HeaderText = "Max", Name = "Maxcolumn", HeaderBackColor = Color.WhiteSmoke }; leg.CellColumns.Add(maxColumn); // Set Min cell column attributes LegendCellColumn minColumn = new LegendCellColumn() { Text = "#MIN{N1}", HeaderText = "Min", Name = "MinColumn", HeaderBackColor = Color.WhiteSmoke }; leg.CellColumns.Add(minColumn); Legends.Add(leg); }
private void InitializeComponent() { var chartArea1 = new ChartArea(); var legend1 = new Legend(); var title1 = new Title(); chartArea1.AxisX.ArrowStyle = AxisArrowStyle.Lines; chartArea1.AxisX.Crossing = 0D; chartArea1.AxisX.InterlacedColor = Color.White; chartArea1.AxisX.IsLabelAutoFit = false; chartArea1.AxisX.LabelAutoFitMaxFontSize = 13; chartArea1.AxisX.LabelStyle.Font = new Font("Microsoft Sans Serif", 9F, FontStyle.Regular, GraphicsUnit.Point, 238); chartArea1.AxisX.LineWidth = 2; chartArea1.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash; chartArea1.AxisX.MajorTickMark.Size = 2F; chartArea1.AxisX.MajorTickMark.TickMarkStyle = TickMarkStyle.AcrossAxis; chartArea1.AxisX.MinorGrid.Enabled = true; chartArea1.AxisX.MinorGrid.LineColor = Color.DarkGray; chartArea1.AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot; chartArea1.AxisX.MinorTickMark.Enabled = true; chartArea1.AxisX.MinorTickMark.TickMarkStyle = TickMarkStyle.AcrossAxis; chartArea1.AxisX.Title = "X"; chartArea1.AxisX.TitleAlignment = StringAlignment.Far; chartArea1.AxisX.TitleFont = new Font("Microsoft Sans Serif", 18F, FontStyle.Bold, GraphicsUnit.Point, 238); chartArea1.AxisY.ArrowStyle = AxisArrowStyle.Lines; chartArea1.AxisY.Crossing = 0D; chartArea1.AxisY.InterlacedColor = Color.White; chartArea1.AxisY.IsLabelAutoFit = false; chartArea1.AxisY.LabelAutoFitMaxFontSize = 13; chartArea1.AxisY.LabelStyle.Font = new Font("Microsoft Sans Serif", 9F, FontStyle.Regular, GraphicsUnit.Point, 238); chartArea1.AxisY.LineWidth = 2; chartArea1.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash; chartArea1.AxisY.MajorTickMark.Size = 2F; chartArea1.AxisY.MajorTickMark.TickMarkStyle = TickMarkStyle.AcrossAxis; chartArea1.AxisY.MinorGrid.Enabled = true; chartArea1.AxisY.MinorGrid.LineColor = Color.DarkGray; chartArea1.AxisY.MinorGrid.LineDashStyle = ChartDashStyle.Dot; chartArea1.AxisY.MinorTickMark.Enabled = true; chartArea1.AxisY.MinorTickMark.TickMarkStyle = TickMarkStyle.AcrossAxis; chartArea1.AxisY.TextOrientation = TextOrientation.Horizontal; chartArea1.AxisY.Title = "Y"; chartArea1.AxisY.TitleAlignment = StringAlignment.Far; chartArea1.AxisY.TitleFont = new Font("Microsoft Sans Serif", 18F, FontStyle.Bold, GraphicsUnit.Point, 238); //By default, if I select a rectangular area using the mouse, the chart will zoom to the selected area. //But this is quite annoying because it is prone to false operation chartArea1.CursorX.IsUserEnabled = false; chartArea1.CursorX.IsUserSelectionEnabled = false; chartArea1.Name = "ChartArea1"; ChartAreas.Add(chartArea1); legend1.Font = CustomFonts.GetMathFont(13.8F); //new Font("Cambria", 13.8F); legend1.IsTextAutoFit = false; legend1.Name = "Legend1"; Legends.Add(legend1); //this.N = 0D; Name = "chart2d"; title1.Font = new Font("Microsoft Sans Serif", 22.2F, FontStyle.Bold, GraphicsUnit.Point, 238); title1.Name = "Title1"; Titles.Add(title1); Dock = DockStyle.Fill; ChartAreas[0].AxisX.ScaleView.MinSize = 0.1; ChartAreas[0].AxisY.ScaleView.MinSize = 0.1; Legends[0].Font = CustomFonts.GetMathFont(Legends[0].Font.Size); const float fontsize = 17.0F; Font = CustomFonts.GetMathFont(fontsize); }