Search code examples
c#.netwinformschartsmschart

MsChart - Rangebar marker at a specific value


I just can't find a way to add a marker at a specific value on a range bar MsChart. Let's say we have a simple range bar graph with 1 serie and 1 point. The point has 2 Y values (ex: 5-20). How can you show a triangle marker at 15?

Thank you.


Solution

  • Try this:

        private void Form1_Load(object sender, EventArgs e)
        {
            DataPoint dp1 = new DataPoint(1, new double[] { 5, 15 });
            dp1.MarkerStyle = MarkerStyle.Triangle;
            dp1.MarkerSize = 12;
            dp1.MarkerColor = Color.Red;
    
            DataPoint dp2 = new DataPoint(1, new double[] { 15, 20 });
    
            chart1.Series[0].Points.Add(dp1);
            chart1.Series[0].Points.Add(dp2);
        }
    

    enter image description here