Search code examples
c#mschart

How to draw a non-continous series


I'm trying to figure out how to draw a discontinued (non-continous) series. This is the code for the series:

        Chart.Series["Limit"].Points.AddXY(20000, 30);
        Chart.Series["Limit"].Points.AddXY(1000000, 30);
        //no plotting wanted here
        Chart.Series["Limit"].Points.AddXY(1500000, 40);
        Chart.Series["Limit"].Points.AddXY(2500000, 40);

How do I stop it from plotting certain points, like the diagonal line shown in the image below?

image


Solution

  • You can visually break up a line chart by inserting an invisible DataPoint:

        Chart.Series["Limit"].Points.AddXY(20000, 30);
        Chart.Series["Limit"].Points.AddXY(1000000, 30);
        //no plotting wanted (from previous point to this one) here
        int index = Chart.Series["Limit"].Points.AddXY(1500000, 40);
        Chart.Series["Limit"].Points[index].Color = Color.Transparent;
        Chart.Series["Limit"].Points.AddXY(2500000, 40);
    

    This makes the line that leads to the DataPoint transparent.