This is a migrated thread and some comments may be shown as answers.

Issue in displaying properly the Line Chart Programmatically

1 Answer 77 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Vipin
Top achievements
Rank 1
Vipin asked on 26 Sep 2012, 03:24 PM

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.

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 01 Oct 2012, 08:51 AM
Hi,

If I understand you correctly the issue you have is related with the X-Aaxis range as shown in the Result.jpg image. I tried to reproduce the issue using a sample data table and the information provided but with no avail. In order to provide you with an appropriate solution, could you attach a sample runnable project isolating the issue. As this is a forum post you can use a third party web site to upload and share the example.

Regards,
Peshito
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Chart (Obsolete)
Asked by
Vipin
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or