C#winform怎么用chart控件实时绘制采集到的速度和扭力曲线

 我来答
就烦条0o
2017-09-07 · 知道合伙人软件行家
就烦条0o
知道合伙人软件行家
采纳数:33315 获赞数:46487
从事多年系统运维,喜欢编写各种小程序和脚本。

向TA提问 私信TA
展开全部
给你一个例子
private void button1_Click(object sender, EventArgs e)
{
chart1.DataSource = GetData();
// Set series members names for the X and Y values
chart1.Series["Series1"].XValueMember = "Time";
chart1.Series["Series1"].YValueMembers = "City";

chart1.Series["Series2"].XValueMember = "Time";
chart1.Series["Series2"].YValueMembers = "Count";

// Data bind to the selected data source
chart1.DataBind();

// Set series chart type
chart1.Series["Series1"].ChartType = SeriesChartType.Line;
chart1.Series["Series2"].ChartType = SeriesChartType.Spline;
// Set point labels
chart1.Series["Series1"].IsValueShownAsLabel = true;
chart1.Series["Series2"].IsValueShownAsLabel = true;
// Enable X axis margin
chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;
// Enable 3D, and show data point marker lines
//chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
chart1.Series["Series1"]["ShowMarkerLines"] = "True";
chart1.Series["Series2"]["ShowMarkerLines"] = "True";

}

private DataTable GetData()
{
DataTable tableInfo = new DataTable();

DataColumn dctime = new DataColumn("Time", Type.GetType("System.String"));
DataColumn dcCity = new DataColumn("City", Type.GetType("System.String"));
DataColumn dcCount = new DataColumn("Count", Type.GetType("System.Int32"));
tableInfo.Columns.Add(dctime);
tableInfo.Columns.Add(dcCity);
tableInfo.Columns.Add(dcCount);
DataRow dr = tableInfo.NewRow();
dr["Time"] = "1:00";
dr["City"] = "10";
dr["Count"] = "15";
tableInfo.Rows.Add(dr);
DataRow dr1 = tableInfo.NewRow();
dr1["Time"] = "2:00";
dr1["City"] = "12";
dr1["Count"] = "19";
tableInfo.Rows.Add(dr1);
DataRow dr2 = tableInfo.NewRow();
dr2["Time"] = "3:00";
dr2["City"] = "13";
dr2["Count"] = "25";
tableInfo.Rows.Add(dr2);
DataRow dr3 = tableInfo.NewRow();
dr3["Time"] = "4:00";
dr3["City"] = "14";
dr3["Count"] = "10";
tableInfo.Rows.Add(dr3);

DataRow dr4 = tableInfo.NewRow();
dr4["Time"] = "5:00";
dr4["City"] = "15";
dr4["Count"] = "11";
tableInfo.Rows.Add(dr4);

DataRow dr5 = tableInfo.NewRow();
dr5["Time"] = "6:00";
dr5["City"] = "16";
dr5["Count"] = "17";
tableInfo.Rows.Add(dr5);

DataRow dr6 = tableInfo.NewRow();
dr6["Time"] = "7:00";
dr6["City"] = "17";
dr6["Count"] = "20";
tableInfo.Rows.Add(dr6);

DataRow dr7 = tableInfo.NewRow();
dr7["Time"] = "8:00";
dr7["City"] = "12";
dr7["Count"] = "13";
tableInfo.Rows.Add(dr7);
return tableInfo;
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
光点科技
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件... 点击进入详情页
本回答由光点科技提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式