No chart x-axis label when exported

9 posts, 0 answers
  1. Joe
    Joe avatar
    48 posts
    Member since:
    Dec 2007

    Posted 03 Nov 2009 Link to this post

    I can see the x-axis labels on my chart in the report viewer, but when I export to PDF or TIFF they have vanished...

    Any logical reason why this might be happening?
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 04 Nov 2009 Link to this post

    Hi Joe,

    I'm afraid that the provided information is insufficient for us to determine what might be the problem and we would need more info on how you create your chart, how you bind it etc. A sample runnable report would be appreciated and usually the fastest way to resolve an issue.

    Kind regards,
    Steve
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Joe
    Joe avatar
    48 posts
    Member since:
    Dec 2007

    Posted 11 Nov 2009 Link to this post

    Sorry Steve,

    I was forced to go with an alternate solution due to time constraints. I don't know for a fact that I could reduce it to a simple example. The same chart displayed in a different report in a slightly different manner worked as expected. It does seem to be a problem in some cases, though.

     

    Thanks,

    Joe

  5. Jason
    Jason avatar
    19 posts
    Member since:
    Mar 2009

    Posted 18 Jan 2010 Link to this post

    I'm having the same problem.
  6. John Hughes
    John Hughes avatar
    15 posts
    Member since:
    Mar 2010

    Posted 11 Feb 2011 Link to this post

    I am having the same issue.  I see the labels in the HTML ReportViewer, but when I export to PDF the labels are not there.

    Code snippets below from my need_datasource method.  Please let me know if you see a glaring error in what I am doing.
    I have also attached 2 screen shots of what I am seeing.

    Thanks,

    John

                    chart1.DataSource = msList;

                    decimal maxHits = (long)currentSession["maxHits"];
                    using (ChartSeries serie = new ChartSeries())
                    {
                        serie.Type = ChartSeriesType.Bar;

                        serie.Clear();
                        decimal numSteps = Math.Round((maxHits / 10) + 1);
                        chart1.PlotArea.YAxis.MaxValue = (double)maxHits;
                        chart1.PlotArea.YAxis.Step = (double)numSteps;
                        serie.Appearance.LegendDisplayMode = Telerik.Reporting.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
                        foreach (MediaServiceResolverActivity lst in msList)
                        {
                            using (ChartSeriesItem item = new ChartSeriesItem())
                            {
                                item.YValue = (double)lst.RequestCount;
                                item.Name = (string)lst.MediaServiceName;
                                chart1.PlotArea.XAxis.DataLabelsColumn = "MediaServiceName";
                                chart1.PlotArea.YAxis.AutoScale = false;
                               
                                item.Appearance.Exploded = true;
                                item.Label.TextBlock.Text = (string)lst.MediaServiceName;
                               

                                serie.Items.Add(item);
                                serie.DefaultLabelValue = "D";
                            }
                           
                            chart1.Series.Add(serie);

                        }

                    }
      
  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 15 Feb 2011 Link to this post

    Hi John,

    Where is that code executed? As you probably know, every time the report is previewed, paged or exported through the viewer it is processed and rendered from scratch. Check whether upon export your code is executed again and whether it goes in the foreach loops as expected.
    If you are unable to pinpoint the issue, please open a support ticket and attach a runnable sample that exhibits the problem and we would advise you accordingly.

    Greetings,
    Steve
    the Telerik team
    Get started with Telerik Reporting with numerous videos and detailed documentation.
  8. John Hughes
    John Hughes avatar
    15 posts
    Member since:
    Mar 2010

    Posted 15 Feb 2011 Link to this post

    Sorry about that.  This is in my method for NeedDataSource.   This code does NOT get executed when I export the chart report to PDF.  Not only do the labels disappear, but all of the other programmatic settings do too.  i.e. Size of chart, step size, etc.

    Is there another method that gets called for exporting that I need similar code in?  I went in and hand edited the designer created CS file and got it to work.  i.e. I added this line to the designer file.

        this.chart1.PlotArea.XAxis.DataLabelsColumn = "MediaServiceName";



    Any suggestions would be appreciated.

    Thanks,

    John
  9. John Hughes
    John Hughes avatar
    15 posts
    Member since:
    Mar 2010

    Posted 15 Feb 2011 Link to this post

    I switched from using the NeedDataSource event to ItemDataBinding and that seems to have fixed it.  Does this seem like the right solution?

    Thanks,

    John
  10. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 16 Feb 2011 Link to this post

    Hello John,

    Yes, the ItemDataBinding event is a valid solution as it would be fired regardless whether the chart has data source set. Here is more info if you are interested:
    The chart NeedDataSource event is fired only when the chart does not have data source set. So when in your code you set chart1.DataSource = msList; the chart accepts this as the data source and the event is not fired anymore. The reason is that chart1 is the definition report item i.e. the same as setting data source directly in the designer. When you're in the context of NeedDataSource, you should work with the processing report item instead - more information is available in the Understanding Events help article.

    Kind regards,
    Steve
    the Telerik team
    Get started with Telerik Reporting with numerous videos and detailed documentation.
Back to Top
DevCraft banner