ZedGraph 控件如何绘制出两条不连续的曲线
要求:在ZedGraph控件中实时绘制温度曲线图,并用颜易做图分。例如:第一条曲线(黑)代表正常温度范围,当温度高于某个值的时候,第一条线断开,第二条(红)跟上,代表高温。温度恢复正常的时候,红线断开换黑线,以此类推...以下是我写的代码,但有个问题:黑线断开的时候,红线无法从黑线的末端继续绘制,而是从黑线的起始位置开始画。画红线的时候X轴坐标没有读数。换成黑线后,黑线也是从原来的黑线末端继续画,没有追加到红线尾巴。不知哪位高人能帮我找一下问题吗?
float temper;
public Form1()
{
InitializeComponent();
InitGraphControl();
}
PointPairList ppl_Black = new PointPairList();
PointPairList ppl_Red = new PointPairList();
/// <summary>
/// 初始化波形图控件
/// </summary>
private void InitGraphControl()
{
this.zedGraphControl1.GraphPane.Title.Text = "温度监测图";
this.zedGraphControl1.GraphPane.YAxis.Title.Text = "温度";
this.zedGraphControl1.GraphPane.XAxis.Title.Text = "时间";
this.zedGraphControl1.GraphPane.AddCurve("K0", ppl_Black, Color.Red, SymbolType.None);
this.zedGraphControl1.GraphPane.AddCurve("K1", ppl_Red, Color.Red, SymbolType.None);
this.zedGraphControl1.GraphPane.XAxis.MajorGrid.IsVisible = true;
this.zedGraphControl1.GraphPane.YAxis.MajorGrid.IsVisible = true;
}
/// <summary>
/// 更新波形图控件
/// </summary>
private void RefreshGraph()
{
double timeValue = (double)new XDate(DateTime.Now);
if (temper > 50)
ppl_Black.Add(timeValue, DateTime.Now.Second);
else
ppl_Red.Add(timeValue, DateTime.Now.Second);
this.zedGraphControl1.AxisChange();
this.zedGraphControl1.Refresh();
}
private void timer1_Tick(object sender, EventArgs e)
{
RefreshGraph();
} ZedGraph
补充:.NET技术 , C#