Issue in displaying properly the Line Chart Programmatically

Thread is closed for posting
2 posts, 0 answers
  1. Vipin
    Vipin avatar
    1 posts
    Member since:
    Sep 2012

    Posted 26 Sep 2012 Link to this post

    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;
        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();
            chartSeries.Type = ChartSeriesType.Line;
            foreach (DataRow item2 in dtFilteredTable.Rows)
            s = s + 1;                                   
        RadChartBiddingLineGraph.DataGroupColumn = "Hotel";
        RadChartBiddingLineGraph.DataSource = dt;
        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.

  2. Peshito
    Peshito avatar
    493 posts

    Posted 01 Oct 2012 Link to this post


    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.

    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top