Reputation:
I have a table that has date and datasize. When I export the list its data appears as
11/1/10|1
11/2/10|2
11/3/10|16
I simply want to create a line graph from this data, but when I see if it's plotted or not the graph is never plotted, also is there a way to change the x axis from a 0-100 numbering to the dates that are listed?
private void CreateGraph_DataSource(ZedGraphControl zedGraphControl1)
{
string project = listBox1.SelectedItem.ToString();
string sql = "select date,datasize from dbo.x where project = '"+project+"' order by date";
DataTable projects = null;
SqlDataAdapter dataadapt = null;
SqlConnection con = new SqlConnection("Data Source= W ;Initial Catalog= ding;Integrated Security= SSPI");
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
projects = new DataTable();
dataadapt = new SqlDataAdapter(cmd);
dataadapt.Fill(projects);
con.Close();
GraphPane myPane = zedGraphControl1.GraphPane;
myPane.Title.Text = project;
myPane.YAxis.Title.Text = "Size";
myPane.XAxis.Title.Text = "Date";
DataSourcePointList dsp = new DataSourcePointList();
dsp.DataSource = projects;
dsp.XDataMember = "Date";
dsp.YDataMember = "DataSize";
LineItem myCurve = myPane.AddCurve("DataSize", dsp, Color.DarkViolet);
myCurve.Line.Fill = new Fill(Color.Red, Color.White);
LineItem myCurve2 = myPane.AddCurve("Date", dsp, Color.DarkViolet);
myCurve2.Line.Fill = new Fill(Color.Green, Color.White);
myCurve.Line.Width = 2.0F;
myCurve2.Line.Width = 2.0F;
zedGraphControl1.AxisChange();
myPane.XAxis.Type = AxisType.Date;
}
Edit:
Sorry, it does appear to be graphing but the scaling is really bad, is there a way to set the scaling to start?
Solved.
Upvotes: 0
Views: 2500