How to draw a non-continous series

时光怂恿深爱的人放手 提交于 2020-05-08 17:03:50

问题


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


回答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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!