I am trying to generate a .net ActiveReport chart with 3 different series
Series1 type = line, series2 type = line and series3 type = bar. Datatable has been used to pull data from database and then each column data is converted into list collection so as to use DataBindXY() method. Problem, I am facing are :
1) Each series uses its own x-axis labels they are not sharing the x-axis label range, so there are duplicate data in x-axis label.
2) Series2 (Bar 2D) is not started with proper x axis data i,e my data for bar chart is (2004,-25), (2030,-65). Rather it starts from (1000,-25) and (2004,-65)
I also tried plotting series by passing static values in Databindxy method, code is commented below.
I am new to activereports and I am facing lots of problems
----------------------------------------------------------------
What I have tried:
private void reportHeader1_Format(object sender, EventArgs e)
{
if (dbConnection == null || inspectionID < 1)
{
return;
}
GrapeCity.ActiveReports.Chart.Series series1 = new GrapeCity.ActiveReports.Chart.Series();
series1.Type = GrapeCity.ActiveReports.Chart.ChartType.Bar2D;
DataSet tds = GetDetail(inspectionID);
if (tds != null)
{
if (tds.Tables[0].Rows.Count > 0)
{
DataRow tdr = tds.Tables[0].Rows[0];
if (tdr != null)
{
List<double> bentSounding = new List<double>();
List<double> bentDistance = new List<double>();
for (int index = 0; index < tds.Tables[0].Rows.Count; index++)
{
string bentValue = tds.Tables[0].Rows[index]["Bent"].ToString();
if (bentValue != "")
{
bentSounding.Add(0);
bentDistance.Add(Double.Parse(tds.Tables[0].Rows[index]["station"].ToString()));
}
}
Double MinWSDist = 0D, MaxWSDist = 0D, MinWSSounding = 0D, MaxWSSounding = 0D;
int MinIndex = 0;
int MaxIndex = 0;
List<double> wsSounding = new List<double>();
List<double> wsDistance = new List<double>();
for (int index = 0; index < tds.Tables[0].Rows.Count; index++)
{
string waterSurfaceValue = tds.Tables[0].Rows[index]["Water_Surface"].ToString();
if (waterSurfaceValue != "")
{
wsSounding.Add(Double.Parse(tds.Tables[0].Rows[index]["downstream"].ToString())*-1);
wsDistance.Add(Double.Parse(tds.Tables[0].Rows[index]["station"].ToString()));
}
}
MaxWSDist = wsDistance.Max();
MaxIndex = wsDistance.FindIndex(s => s == MaxWSDist);
MinWSDist = wsDistance.Min();
MinIndex = wsDistance.FindIndex(s => s == MinWSDist);
MaxWSSounding = wsSounding.ElementAt(MaxIndex);
MinWSSounding = wsSounding.ElementAt(MinIndex);
List<double> sounding = new List<double>();
List<double> distance = new List<double>();
for (int index = 0; index < tds.Tables[0].Rows.Count; index++)
{
sounding.Add(Double.Parse(tds.Tables[0].Rows[index]["downstream"].ToString()) * -1);
}
for (int index = 0; index < tds.Tables[0].Rows.Count; index++)
{
distance.Add(Double.Parse(tds.Tables[0].Rows[index]["station"].ToString()));
}
this.chartControl1.Series[0].Points.DataBindXY(distance, sounding);
this.chartControl1.Series[1].Points.DataBindXY(new[] { MinWSDist, MaxWSDist }, new[] { MinWSSounding, MaxWSSounding });
this.chartControl1.Series[2].Points.DataBindXY(bentDistance, bentSounding);
}
}
tds.Dispose();
}
}