Chart series data not displaying correctly when .AutoScale = false

Thread is closed for posting
2 posts, 0 answers
  1. Chris Ward
    Chris Ward avatar
    56 posts
    Member since:
    Jan 2010

    Posted 09 Feb 2011 Link to this post

    Hello Telerik,

    I initially posted this in the Reporint forum because I am using the chart in a Telerik Report, but I haven't recevied a response.  Seems like maybe this is a more appropiate place... 

    I am creating a chart from a SQL datasource.  I have two series that are bound to columns on the datasource.  If I preview the chart, it looks good and the chart matches the data.  My next step is to display my own custom X-Axis labels.  I do this by setting PlotArea.XAxis.AutoScale = false and create the items manually.  However when I do this and preview the chart, the chart does not look correct (the line does not match the data from the database).

    This forum post seems to be related: http://www.telerik.com/community/forums/aspnet/chart/trouble-with-custom-xaxis-labels.aspx
    It suggests that I do not set the xvalue inside my chart series.  However, I am adding the series by binding to a datasource, so I do not see how to make this work in my case.

    //set the datasource 
    chart1.DataSource = this.sqlDataSource1; 
    //COMMENT OUT THIS SECTION AND THE CHART LOOKS GOOD 
    //add new xaxis series items 
    chart1.PlotArea.XAxis.AutoScale = false
    chart1.PlotArea.XAxis.AddRange(1, 7, 1); 
    chart1.PlotArea.XAxis[0].TextBlock.Text = "12/1/10"
    chart1.PlotArea.XAxis[1].TextBlock.Text = "12/5/10"
    chart1.PlotArea.XAxis[2].TextBlock.Text = "12/10/10"
    chart1.PlotArea.XAxis[3].TextBlock.Text = "12/15/10"
    chart1.PlotArea.XAxis[4].TextBlock.Text = "12/20/10"
    chart1.PlotArea.XAxis[5].TextBlock.Text = "12/25/10"
    chart1.PlotArea.XAxis[6].TextBlock.Text = "12/30/10"
        
    //add the series 1 
    ChartSeries seriesAvg = new ChartSeries(); 
    seriesAvg.DataYColumn = "Average"
    seriesAvg.Type = ChartSeriesType.Area; 
    seriesAvg.DefaultLabelValue = ""
    chart1.Series.Add(seriesAvg); 
    //add the series 2 
    ChartSeries seriesMax = new ChartSeries(); 
    seriesMax.DataYColumn = "Max"
    seriesMax.Type = ChartSeriesType.Line; 
    seriesMax.DefaultLabelValue = ""
    chart1.Series.Add(seriesMax);

    Am I doing this totally wrong, or is there a work around?

    Thanks, Chris
  2. Missing user
    Missing user avatar

    Posted 15 Feb 2011 Link to this post

    Hello Chris Ward,

    I created a sample project with the given guidelines. You can find it in the attached file. However I was not able to reproduce this case. Can you please provide some additional information about it? I will appreciate if you send us an entire sample project. Thus we will provide more straight-to-the-point solution.

    Greetings,
    Polina
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top