问题
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?
回答1:
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.
回答2:
I don't know any way to set different lines parameters for the same Series, but you can create two different lines
Chart.Series["Limit"].Points.AddXY(20000, 30);
Chart.Series["Limit"].Points.AddXY(1000000, 30);
Chart.Series["Limit"].BorderColor = Color.Red
//no plotting wanted here
Chart.Series["Limit2"].Points.AddXY(1500000, 40);
Chart.Series["Limit2"].Points.AddXY(2500000, 40);
Chart.Series["Limit2"].BorderColor = Color.Red
来源:https://stackoverflow.com/questions/43030711/how-to-draw-a-non-continous-series