如何绘制一个非连续的系列

时间:2017-03-26 15:32:56

标签: c# mschart

我正在试图弄清楚如何绘制已停止(非连续)的系列。这是该系列的代码:

        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);

如何阻止它绘制某些点,如下图所示的对角线?

image

2 个答案:

答案 0 :(得分:1)

您可以通过插入不可见 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);

这会使导致 DataPoint 透明的行。

答案 1 :(得分:0)

我不知道如何为同一系列设置不同的线条参数,但你可以创建两个不同的线条

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