1

I have 2 series (2016 and 2017) in column chart and all datapoints values are showing fine. but I need to differentiate two series values by showing thick border line between two series.

because , now it seems to combining the 2017 values with 2016 series values since no separator line not there.

FYI.

Current Column Chart Image

EDIT: After used vertical line in my column chart the output as like below,

enter image description here

But i need only one Line that should present between the two series .

how do i remove other lines.

Finally , Got the expected Output.

enter image description here

Thanks in advance.

Abu Muhammad
  • 421
  • 2
  • 13
  • You cn use a StripLine, a VerticalLineAnnotation or draw the line in the PostPaint event. – TaW Jan 04 '17 at 08:11
  • @TaW, As i displayed in my image , I need to differentiate the two series, so i need to show the strip line after first series END. how can i do the same? Help appreciated – Abu Muhammad Jan 04 '17 at 08:17
  • if anyone knows answer, Please update the same. Help Appreciated. – Abu Muhammad Jan 04 '17 at 12:35
  • 1
    Got the answer. thanks for all your comments. Code snippet : var series = Mainchart.Series[0]; //series object var chartArea = Mainchart.ChartAreas[series.ChartArea]; chartArea.AxisX.StripLines.Add(new StripLine { BorderDashStyle = ChartDashStyle.Solid, BorderColor = Color.Black, Interval = 0, IntervalOffset = 1.5, IntervalType = DateTimeIntervalType.Years }); – Abu Muhammad Jan 04 '17 at 12:45

2 Answers2

2
var series = Mainchart.Series[0]; //series object
                var chartArea = Mainchart.ChartAreas[series.ChartArea];
                chartArea.AxisX.StripLines.Add(new StripLine
                {
                    BorderDashStyle = ChartDashStyle.Solid,
                    BorderColor = Color.Black,
                    Interval = 0, // to show only one vertical line
                    IntervalOffset = 1.5, // for showing Vertical line between 2 series 
                    IntervalType = DateTimeIntervalType.Years // for me years
                });
Abu Muhammad
  • 421
  • 2
  • 13
1

You may use StripLine:

StripLine limit_lower_strip = new StripLine();
limit_lower_strip.Interval = 0;
limit_lower_strip.IntervalOffset = v1_lower;
limit_lower_strip.StripWidth = 0.0;
limit_lower_strip.BorderColor = Color.FromArgb(100, Color.Red);
limit_lower_strip.BorderDashStyle = ChartDashStyle.Solid;
limit_lower_strip.BorderWidth = 5;
chart1.ChartAreas[0].AxisX.StripLines.Add(limit_lower_strip);
huse.ckr
  • 530
  • 12
  • 39
  • StripLine is a good idea. Can you add a screenshot to show the effect? – TaW Jan 04 '17 at 08:10
  • 2
    An example: [Win Form Charting](http://stackoverflow.com/questions/7503043/win-form-charting) – huse.ckr Jan 04 '17 at 08:11
  • @user30, Will it add all the XAxis or peritculer position, If so As i displayed in my image , I need to differentiate the two series, so i need to show the strip line after first series END. how can i do the same? Help appreciated. – Abu Muhammad Jan 04 '17 at 08:14
  • @user3060520. I have tried the same but nothing happened. No lines and nothing. – Abu Muhammad Jan 04 '17 at 08:28
  • Did you add points? For example: // Declare new random variable Random rand = new Random(); // Add data for (int i = 0; i < 7; i++) { chart1.Series[0].Points.AddXY(DateTime.Now.AddDays(i), rand.Next(20,35)); } [Further example @ MSDN](https://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.stripline(v=vs.110).aspx) – huse.ckr Jan 04 '17 at 08:35
  • If it is hard, instead use a Vertical Line [C# Line Chart How to Create Vertical Line](http://stackoverflow.com/questions/25801257/c-sharp-line-chart-how-to-create-vertical-line) – huse.ckr Jan 04 '17 at 09:05
  • @user3060520, Thanks for your reply, I have tried the vertical line drawing and its displaying for every interval but i need to show only between two series. help most welcome! See my questions for the updated image. – Abu Muhammad Jan 04 '17 at 09:43