简体   繁体   中英

How to set line markers in C# using Microsoft Visual Studio?

I would like to set different markers to the various series plotted in my chart. How do I go about doing this since the various series are plotted only when the user selects that particular option. I currently have 7 series that can be plotted.

  for (int i = 0; i <= loop - 1; i++) {
 Chart1.Series[i].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
 Chart1.Series[i].BorderWidth = 5; }

Whether it's System.Windows.Forms.DataVisualization.Charting.MarkerStyle or System.Web.UI.DataVisualization.Charting.MarkerStyle you can set it:

  1. For each point in your series' DataPointCollection .
  2. For the whole Series ( DataPointCustomProperties.MarkerStyle ).

If you are using MarkerStyle.None you can also use a MarkerImage instead of the default predefined markers, same remarks as above, it should work for the whole series or any point. You can even manipulate those values directly with DataPointCustomProperties.SetCustomProperty , or DeleteCustomProperty , like:

dataPoint.SetCustomProperty("MarkerStyle", MarkerStyle.Circle);

or

dataPoint.DeleteCustomProperty("MarkerStyle");

Then, make sure:

  1. you have a big enough value for the MarkerSize property so that your points are visible.
  2. marker color differs from background
  3. chart type supports markers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM