How to show the marker points in line graph using c#

sowjanya attaluri picture sowjanya attaluri · Dec 17, 2015 · Viewed 16.1k times · Source

I am using Line graph in my application and is working fine. I tried to draw the marker points in line graph,but the marker points are not displaying. In line chart marker properties, I have chosen markerSize as 5,markerStyle as Circle,MarkerColor as blue.Refer my code below.

 series1.Name = "Series1";
 series1.IsVisibleInLegend = false;
 series1.IsXValueIndexed = true;
 series1.XValueType = ChartValueType.Time;
 series1.YAxisType = AxisType.Primary;
 series1.ChartType = SeriesChartType.Line;
 this.chart1.Series.Add(series1);

Answer

TaW picture TaW · Dec 17, 2015

I don't see how the Markers can show up from your code.

You need to set a non-default MarkerStyle:

 series1.MarkerStyle = MarkerStyle.Circle;

If you use the debugger on that line you can see how the default is None !

Of course you will want to play with all other marker relates series properties, which all inherited from the DataPointCustomProperties

You are using ChartType.Line which is fine. Note that FastLine does not display markers!

If you only want to show some Markers simply style them for each point:

S1.Points[8].MarkerStyle = MarkerStyle.Triangle;
S1.Points[8].MarkerSize = 22;
S1.Points[8].MarkerColor = Color.Red;