C#中的图形表示 [英] Graph presentation in C#
本文介绍了C#中的图形表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hai
i试图在C#编码中编写用于从mysql数据库数据中呈现图形的编码,但是我得到的错误就像图表1在当前上下文中并不令人兴奋。
我不知道如何清除错误如果您有任何想法请回复我
我附上以下代码我用
hai
i have tried to write the coding for presenting a graph from mysql database data in C# coding but i get the error like chart1 is not excit in the current context.
I don''t know how to clear the error if u have any idea please reply me
I attached the following code I did
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.Web;
//using System.Web.UI;
//using System.Web.UI.WebControls;
using System.Windows.Forms.DataVisualization.Charting;
using MySql.Data.MySqlClient;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
MySqlConnection con = new MySqlConnection();
//Chart Chart1.Series["Series1"].ChartType = SeriesChartType.Column;
}
private void Form1_Load(object sender, EventArgs e)
{
Chart1.Series["Series1"].ChartType = SeriesChartType.Column;
try
{
// TODO: This line of code loads data into the 'testDataSet.periodicdata' table. You can move, or remove it, as needed.
this.periodicdataTableAdapter.Fill(this.testDataSet.periodicdata);
MySqlConnection con = new MySqlConnection();
con.ConnectionString = "server=localhost;user id=root;password=vinoth;database=test";
MySqlCommand cmd = new MySqlCommand();
//con.ConnectionString = "server=localhost;user id=root;password=******;database=test";
//con.ConnectionString = "server=.\\mysqlexpress;database=test;integrated security=true;";
con.Open();
}
catch (Exception ex) { MessageBox.Show(ex.ToString()); }
}
private void button1_Click(object sender, EventArgs e)
{
Chart1.Series["Series1"].ChartType = SeriesChartType.Column;
Chart1.Series["Series1"]["DrawingStyle"] = "Emboss";
//Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
Chart1.Series["Series1"].IsValueShownAsLabel = true;
FillData();
}
private void FillData()
{
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn();
dc.ColumnName = "date_time";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "Volt1";
dt.Columns.Add(dc);
Chart1.DataSource = dt;
Chart1.Series["Series1"].XValueMember = "date_time";
Chart1.Series["Series1"].YValueMembers = "Volt1";
Chart1.DataBind();
//throw new NotImplementedException();
}
}
}
推荐答案
尝试使用zedgraph,请看这个链接: ZedGraph在中型信任环境中的C#Web应用程序中 [ ^ ]
祝你好运,
z3ngew
Try using zedgraph, see this link: ZedGraph in a C# web application in a Medium trust environment[^]
Good Luck,
z3ngew
检查这个
ASP.NET 4.0图表控件 [< a href =http://www.codeproject.com/Articles/235117/ASP-NET-4-0-Chart-Controltarget =_ blanktitle =New Window> ^ ]
你好,你可以使用ajax new functina直接绘制图形用于绘制图形的lity。
hello you can direct draw graph by using ajax new functinality for drawing graph.
这篇关于C#中的图形表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文