In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how to use DevExpress's ChartControl to achieve polar coordinates in C#. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Background
In the development of industrial control software, many business scenarios use chart controls to display equipment and process parameters. The following figure is an example:
Realization idea
Usually a simple approach is to use chart controls, commonly used chart controls are open source ZedGraph, and paid TeeChart and DevExpress. Conventional graph, bar chart, pie chart implementation, the three controls can be well implemented, it is recommended to use open source ZedGraph. However, in the implementation of radar charts, polar charts and other specific charts, ZedGraph can not support, TeeChart is not so perfect to use, after comparison, it is found that the ChartControl implementation of DevExpress is still good.
Reference code
This case uses DevExpress 18.1.3 version, which has been tried before on version 14, but there is a disadvantage that when realizing the polar graph, the first point and the last point always automatically have a closed line, which forms a closed polygon, so I upgraded the version. In DevExpress, radar map and polar coordinate map use the relationship between parent and child, and many attributes are the same. In order to define the scale range on the disk, radar map is used to realize the custom polar coordinate map.
Using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Diagnostics;using DevExpress.XtraCharts;namespace WinTest {public partial class Form1: Form {private Stopwatch sw = new Stopwatch (); public Form1 () {InitializeComponent () } private void button1_Click (object sender, EventArgs e) {sw.Restart (); int fontSize = 9; / / font size int count = 1; / / number of curves int points = 8 / / the number of points per curve int angleMaxValue = 24; / / the maximum angle int maxShowPints = 30; / / the maximum number of points displayed for (int I = 0; I < this.Controls.Count) ) {if (this.Controls [I] is ChartControl) {this.Controls.RemoveAt (I); break;}} / / Create a new chart. ChartControl RadarLineChart = new ChartControl (); / / Add a radar series to it. Series [] seriesArr = new Series [count]; List [] pintValuesList = new List [count]; for (int I = 0; I < seriesArr.Length; iTunes +) {pintValuesList [I] = new List (); seriesArr [I] = new Series ("Series" + I, ViewType.RadarLine) / / use radar line chart to instantiate Series RadarLineSeriesView radLineSeriesView = (seriesArr [I] .View as RadarLineSeriesView); radLineSeriesView.MarkerVisibility = DevExpress.Utils.DefaultBoolean.False; / / remove dots from the line radLineSeriesView.Closed = false; / / the line does not form a closed loop Arr (seriesArr [I]) } / / Flip the diagram (if necessary). RadarDiagram radarDiagram = RadarLineChart.Diagram as RadarDiagram; radarDiagram.StartAngleInDegrees = 0; / / start angle radarDiagram.AxisX.WholeRange.MinValue = 0; / / set the minimum angle range value radarDiagram.AxisX.WholeRange.MaxValue = 23; / / set the maximum angle range value radarDiagram.RotationDirection = RadarDiagramRotationDirection.Clockwise / / whether the data is clockwise or counterclockwise / / Add a title to the chart and hide the legend. ChartTitle chartTitle1 = new ChartTitle (); chartTitle1.Text = "RadarLineChart"; RadarLineChart.Titles.Add (chartTitle1); RadarLineChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; / / hide legend / / Add the chart to the form. RadarLineChart.Dock = DockStyle.Fill; this.Controls.Add (RadarLineChart); / / Populate the series with points. Random r = new Random ((int) DateTime.Now.Ticks); r.NextDouble (); for (int I = 0; I < seriesArr.Length; iTunes +) {for (int k = 0; k < points; knot +) {double yValue = 100 * r.NextDouble () PintValuesList [I] .add (new SeriesPoint (k * 24.0 / points, yValue));} seriesArr [I] .Points.AddRange (pintValuesList.AddRange (pintValuesList [I]. ToArray ()); seriesArr [I] .LabelsVisibility = DevExpress.Utils.DefaultBoolean.False; / / the label of hidden data point shows}
Run the effect diagram as follows:
These are all the contents of the article "how to use DevExpress's ChartControl to achieve Polar Graph in C#". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.