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

2k views Asked by At

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; }
1

There are 1 answers

0
andrei.ciprian On

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.