rdlc图表的x轴问题
public void LoadReport()
{
DataTable dt = new DataTable();
DataTable dt2 = new DataTable();
dt.Columns.Add("时间", typeof(string));
dt.Columns.Add("平均值", typeof(string));
dt.Columns.Add("最大值", typeof(string));
dt.Columns.Add("最小值", typeof(string));
dt.Columns.Add("变化量", typeof(string));
string date = dayDTP.Value.ToShortDateString();
string date2 = dayDTP.Value.AddDays(1).ToShortDateString();
string[] time = new string[24];
for(int i = 0; i < 24; i++)
{
time[i] = string.Format("{0:D2}:00:00", i);
}
for(int i = 0; i < 23; i++)
{
try
{
string sqlstr = string.Format("select avg(Up_pressure),avg(Down_pressure),max(Up_pressure),max(Down_pressure)," +
"min(Up_pressure),min(down_pressure) from [{0}] where Datetimes between '{1}' and '{2}'"
, dayIDCBB.SelectedValue.ToString(), date + " " + time[i], date + " " + time[i + 1]);
SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlstr, con);
DataSet ds1 = new DataSet();
dataAdapter.Fill(ds1);
int Up_diff = Convert.ToInt32(ds1.Tables[0].Rows[0][2]) - Convert.ToInt32(ds1.Tables[0].Rows[0][4]);
int Down_diff = Convert.ToInt32(ds1.Tables[0].Rows[0][3]) - Convert.ToInt32(ds1.Tables[0].Rows[0][5]);
Console.WriteLine("深变化量:{0},浅变化量:{1}", Up_diff, Down_diff);
dt.Rows.Add(new string[] {time[i]+"-"+time[i+1],
"深" +ds1.Tables[0].Rows[0][0].ToString()+"浅"+ ds1.Tables[0].Rows[0][1].ToString(),
"深"+ds1.Tables[0].Rows[0][2].ToString()+"浅"+ ds1.Tables[0].Rows[0][3].ToString(),
"深"+ds1.Tables[0].Rows[0][4].ToString()+"浅"+ ds1.Tables[0].Rows[0][5].ToString(),
"深"+Up_diff.ToString()+"浅"+Down_diff.ToString()});
Console.WriteLine(dt.Rows[i][0].ToString() + " " + dt.Rows[i][1].ToString() + " " + dt.Rows[i][2].ToString() + " " + dt.Rows[i][3].ToString() + " " + dt.Rows[i][4].ToString() + " ");
}catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
string sqlStr = string.Format("select Datetimes,Up_pressure,Down_pressure from [{0}] where Datetimes between '{1}' and '{2}'"
, dayIDCBB.SelectedValue.ToString(), date + " 00:00:00", date2 + " 00:00:00");
SqlDataAdapter adapter = new SqlDataAdapter(sqlStr, con);
DataSet ds2 = new DataSet();
adapter.Fill(ds2, "chart");
dt2 = ds2.Tables[0];
List<ChartData> list = new List<ChartData>();
for(int i = 0; i < dt2.Rows.Count; i++)
{
//string[] s = dt2.Rows[i][0].ToString().Split(' ');
list.Add(new ChartData()
{
时间 = Convert.ToDateTime(dt2.Rows[i][0].ToString().Replace('/', '-')),
基点值 = dt2.Rows[i][1].ToString()
,
基点类 = "深基点",
标题= dayIDCBB.SelectedValue.ToString()
});
list.Add(new ChartData()
{
时间 = Convert.ToDateTime(dt2.Rows[i][0].ToString().Replace('/', '-')),
基点值 = dt2.Rows[i][2].ToString()
,
基点类 = "浅基点",
标题 = dayIDCBB.SelectedValue.ToString()
});
}
foreach(ChartData cd in list)
{
Console.WriteLine(cd.时间 + " " + cd.基点值 + " " + cd.基点类);
}
this.DayreportViewer.LocalReport.ReportPath = Directory.GetCurrentDirectory() + @"DayReport.rdlc";
this.DayreportViewer.LocalReport.DataSources.Clear();
this.DayreportViewer.LocalReport.DataSources.Add(new ReportDataSource("dayDataSet", dt));
this.DayreportViewer.LocalReport.DataSources.Add(new ReportDataSource("dayChartDataSet", list));
this.DayreportViewer.RefreshReport();
}
public class ChartData
{
public DateTime _time;
public string _value;
public string _category;
public string _title;
public DateTime 时间
{
get { return this._time; }
set { this._time = value; }
}
public string 基点值
{
get { return this._value; }
set { this._value = value; }
}
public string 基点类
{
get { return this._category; }
set { this._category = value; }
}
public string 标题
{
get { return this._title; }
set { this._title = value; }
}
}
求助啊,我的折线图为什么X轴那里是那样的,我想要均匀分布的间隔时间啊,比如2018-11-15 00:00:00,2018-11-15 01:00:00之类的,有木有大神帮帮忙,项目卡在这里两天了
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的x轴时间怎么都是一样的,是不是数据有问题?