当前位置:编程学习 > C#/ASP.NET >>

mschart实时显示数据的程序 为何运行后没有曲线出现 没有报错 没有警告 只生成一个空的图表

使用C#仿照别人的代码写了一个实时显示数据的程序 但是运行后只得到一个空的图标
没有报错
没有警告
请教一下,为什么会这样?谢谢大家!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
                 
        SetChart();

        timer1.Interval = 1000;

        timer1.Start();
        }

        private Random rand = new Random();

        public void SetChart()
        {
            ChartArea cha = new ChartArea("ChartArea1");
            cha.Area3DStyle.Enable3D = true;
            chart1.ChartAreas.Add(cha);

            Legend lgY = new Legend("Legend1");
            lgY.IsTextAutoFit = true;
            lgY.Docking = Docking.Bottom;
            chart1.Legends.Add(lgY);

            Series SerY = new Series("Series1");
            SerY.ChartArea = "ChartArea1";
            SerY.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            SerY.IsVisibleInLegend = true;
            SerY.Legend = "Legend1";
            SerY.LegendText = "Yvalue";
            SerY.YValueMembers = "Yvalue";
           
            chart1.Series.Add(SerY);
            chart1.Series[0].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
            //chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss" + "yy/MM/dd";
        }

        private void timer1_tick(object sender, System.EventArgs e)
        {
            double doubledate = DateTime.Now.ToOADate();
            double doubledate2 = DateTime.Now.AddSeconds(-13).ToOADate();
            chart1.ChartAreas[0].AxisX.Maximum = doubledate;
            chart1.ChartAreas[0].AxisX.Minimum = doubledate2;

            chart1.Series[0].Points.AddXY(DateTime.Now, rand.Next(1, 101));
            
        }

        protected void Chart1_Click(object sender, System.EventArgs e) { }  
    }
}

--------------------编程问答-------------------- 楼主  你的那个chart程序解决了吗  那个minValue和maxValue是什么意思怎么添加??谢谢
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,