I want to display Line Chart Programmatically. I do not want to display anything on X-Axis. I want to display some integer values on Y-Axis. By using the below code Line chart is getting displayed but some series are not fully getting displayed.
I am using dataTable (dt) to bind the chart.
Below are the two different approaches.
With first approach, i am getting the series in chart, but which is not using full length of x-axis irrespective of series item data for each series.
With second approach, i am not able to view the series in the chart. In order to resolve the issue with first approach, i also tried this second approach.
if
(dt !=
null
&& dt.Rows.Count > 0)
{
//First approach STARTS
RadChartBiddingLineGraph.DefaultType = Telerik.Charting.ChartSeriesType.Line;
RadChartBiddingLineGraph.PlotArea.YAxis.AutoScale =
false
;
RadChartBiddingLineGraph.PlotArea.YAxis.AddRange(Convert.ToInt32(dt.Rows[0][3]), Convert.ToInt32(dt.Rows[0][4]), 10);
RadChartBiddingLineGraph.DataGroupColumn =
"Hotel"
;
RadChartBiddingLineGraph.DataManager.ValuesYColumns =
new
String[] {
"RateValue"
};
RadChartBiddingLineGraph.DataSource = dt;
RadChartBiddingLineGraph.DataBind();
foreach
(Telerik.Charting.ChartSeries series
in
RadChartBiddingLineGraph.Series)
{
series.Appearance.LabelAppearance.Visible =
false
;
RadChartBiddingLineGraph.PlotArea.XAxis.Appearance.LabelAppearance.Visible =
false
;
}
//First approach ENDS
//Second approach STARTS
DataTable dt2 =
new
DataTable();
// Get the distinct records. HERE dt1 is the table in which there are all records(which are retrieved from SP)
dt2 = dt.DefaultView.ToTable(
true
, dt.Columns[0].ColumnName);
int
s = 0;
RadChartBiddingLineGraph.PlotArea.YAxis.AutoScale =
false
;
RadChartBiddingLineGraph.PlotArea.YAxis.AddRange(120, 185, 5);
foreach
(DataRow item
in
dt2.Rows)
//dt2 is the datatable in if have now distinct AuctionInviteIDs
{
//just get the data on basis of AuctionInviteId
//if want the result in datatable
DataTable dtFilteredTable = (from a
in
dt.AsEnumerable()
where a.Field<Int32>(
"AuctionInviteID"
).Equals(item[
"AuctionInviteID"
])
select a).CopyToDataTable();
ChartSeries chartSeries =
new
ChartSeries();
chartSeries.Name = s.ToString();
RadChartBiddingLineGraph.AddChartSeries(chartSeries);
chartSeries.Type = ChartSeriesType.Line;
foreach
(DataRow item2
in
dtFilteredTable.Rows)
{
chartSeries.AddItem(Convert.ToInt32(item2[
"RateValue"
]));
//RadChartBiddingLineGraph.Series[s].AddItem(Convert.ToInt32(item2["RateValue"]));
}
RadChartBiddingLineGraph.Series.Add(chartSeries);
s = s + 1;
}
RadChartBiddingLineGraph.DataGroupColumn =
"Hotel"
;
RadChartBiddingLineGraph.DataSource = dt;
RadChartBiddingLineGraph.DataBind();
foreach
(Telerik.Charting.ChartSeries series
in
RadChartBiddingLineGraph.Series)
{
series.Appearance.LabelAppearance.Visible =
false
;
RadChartBiddingLineGraph.PlotArea.XAxis.Appearance.LabelAppearance.Visible =
false
;
}
//Second approach ENDS
}
With first approach, i am getting the graph "Result.jpg" as in the attachment, which is not using the full length of x-axis for each series.
I need the graph to be displayed as in "Approach-1.jpg" attachment, which uses the full length of x-axis for each series.
Your help would be appreciated.