Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7581575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:14:05+00:00 2026-05-30T18:14:05+00:00

I have report page that uses dynamic xtrachart s. To dynamically create the xtrachart

  • 0

I have report page that uses dynamic xtracharts. To dynamically create the xtracharts, I used the XtraReport‘s BeforePrint event. But there are duplicate XtraCharts generated. From a scenario, the expected quantity of charts are 2, but there are 24 charts generated (creating 12 duplicates of the expected charts).

Here is my class for the report

public class SystemReport : DevExpress.XtraReports.UI.XtraReport
{
    private DevExpress.XtraReports.UI.DetailBand Detail;
    private DevExpress.XtraReports.UI.PageFooterBand PageFooter;
    private ReportHeaderBand ReportHeader;
    ...

    public SystemReport(List<SystemLog> logs)
    {
        InitializeComponent();
        Detail.Report.DataSource = logs
    }

    protected override void Dispose(bool disposing)
    {
        ...
    }

    #region Designer generated code

    private void InitializeComponent()
    {
        this.Detail = new DevExpress.XtraReports.UI.DetailBand();
        this.PageFooter = new DevExpress.XtraReports.UI.PageFooterBand();
        this.xrPageInfo1 = new DevExpress.XtraReports.UI.XRPageInfo();
        this.ReportHeader = new DevExpress.XtraReports.UI.ReportHeaderBand();
        this.xrLblSystemReport = new DevExpress.XtraReports.UI.XRLabel();
        ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
        // 
        // Detail
        // 
        this.Detail.Name = "Detail";
        this.Detail.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
        this.Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
        // 
        // PageFooter
        // 
        this.PageFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
        this.xrPageInfo1});
        this.PageFooter.HeightF = 25.83332F;
        this.PageFooter.Name = "PageFooter";
        this.PageFooter.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
        this.PageFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
        // 
        // xrPageInfo1
        // 
        this.xrPageInfo1.ForeColor = System.Drawing.Color.Gray;
        this.xrPageInfo1.Format = "Page {0} of {1}";
        this.xrPageInfo1.LocationFloat = new DevExpress.Utils.PointFloat(388.7917F, 0F);
        this.xrPageInfo1.Name = "xrPageInfo1";
        this.xrPageInfo1.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
        this.xrPageInfo1.SizeF = new System.Drawing.SizeF(120F, 25F);
        this.xrPageInfo1.StylePriority.UseForeColor = false;
        this.xrPageInfo1.StylePriority.UseTextAlignment = false;
        this.xrPageInfo1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
        // 
        // ReportHeader
        // 
        this.ReportHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
        this.xrLblSystemReport});
        this.ReportHeader.HeightF = 107.0417F;
        this.ReportHeader.Name = "ReportHeader";
        this.ReportHeader.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
        this.ReportHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
        // 
        // xrLblSystemReport
        // 
        this.xrLblSystemReport.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold);
        this.xrLblSystemReport.LocationFloat = new DevExpress.Utils.PointFloat(363.3333F, 10.00001F);
        this.xrLblSystemReport.Name = "xrLblSystemReport";
        this.xrLblSystemReport.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
        this.xrLblSystemReport.SizeF = new System.Drawing.SizeF(175F, 25F);
        this.xrLblSystemReport.Text = "System Report";
        this.xrLblSystemReport.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
        // 
        // SystemReport
        // 
        this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
        this.Detail,
        this.PageFooter,
        this.ReportHeader});
        this.Font = new System.Drawing.Font("Arial", 9.75F);
        this.ForeColor = System.Drawing.Color.Gray;
        this.Landscape = true;
        this.PageHeight = 850;
        this.PageWidth = 1100;
        this.Version = "11.2";
        this.BeforePrint += new System.Drawing.Printing.PrintEventHandler(Report_BeforePrint);
        ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
    }

    private void Report_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
        DetailBand detail = (DetailBand)((XtraReport)sender).Bands[BandKind.Detail];
        List<SystemLog> logs = (List<SystemLog>)detail.Report.DataSource;
        int chartQuantity = GetChartQuantity(logs);

        PopulateDetailWithCharts(detail, chartQuantity);
        PopulateDetailWithValues(logs, detail, chartQuantity);
    }

    #endregion

    private int GetChartQuantity(List<SystemLog> logs)
    {
        return logs.Count / 15 + (logs.Count % 15 > decimal.Zero ? 1 : 0);
    }

    private void PopulateDetailWithCharts(DetailBand detail, int chartQuantity)
    {
        for (int i = 0; i < chartQuantity; i++)
        {
            if (detail.FindControl(string.Format("xrChart{0}", i), false) == null)
            {
                XRChart chart = GetChart(i);
                detail.Controls.Add(chart);
                chart.Location = new Point(0, 300 * (i));
            }
        }
    }

    private XRChart GetChart(int i)
    {
        XRChart chart = new XRChart();

        chart.AppearanceNameSerializable = "Gray";
        chart.BackColor = System.Drawing.Color.Transparent;
        chart.BorderColor = System.Drawing.SystemColors.ControlText;
        chart.Borders = DevExpress.XtraPrinting.BorderSide.None;
        chart.ImageType = DevExpress.XtraReports.UI.ChartImageType.Bitmap;
        chart.Name = string.Format("xrChart{0}", i);
        chart.PaletteBaseColorNumber = 11;
        chart.PaletteName = "Nature Colors";
        chart.SizeF = new System.Drawing.SizeF(852.4167F, 300F);
        chart.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
        chart.Legend.Visible = false;

        return chart;
    }

    private void PopulateDetailWithValues(List<SystemLog> logs, DetailBand detail, int chartQuantity)
    {            
        for (int i = 0; i < chartQuantity; i++)
        {
            XRChart chart = (XRChart)detail.FindControl(string.Format("xrChart{0}", i), false);
            chart.DataSource = logs.SkipWhile((log, index) => index < i * 15).TakeWhile((log, index) => index < i + 15).ToList();
            InitializeChartValues(chart);
        }
    }

    private void InitializeChartValues(XRChart chart)
    {
        Series salesSeries = new Series();
        salesSeries.ArgumentDataMember = "DateTime";
        salesSeries.ValueDataMembers.AddRange(new string[] { "Quantity" });
        salesSeries.Name = "System Log Quantity";

        chart.Series.AddRange(new Series[] { salesSeries });

        XYDiagram diagram = (XYDiagram)chart.Diagram;
        diagram.AxisY.Title.Text = "Quantity of System Logs";
        diagram.AxisX.Title.Text = "Date of System Logs";
        diagram.AxisY.Title.Visible = true;
        diagram.AxisX.Title.Visible = true;
        diagram.AxisX.Label.Angle = -30;
    }
}

I do not see any logical error on my codes. Maybe there are some behaviors that I do not understand. Hope anyone can help me with this. Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:14:06+00:00Added an answer on May 30, 2026 at 6:14 pm

    Do not set the DataSource of the XtraReport. It will duplicate your chart.
    Set only the DataSource of your XtraChart.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Oracle APEX and I have a report region in a page that
I have a SQL Report that insists on printing an extra blank page at
I have a server with an asp page on it that generates a report
I have a page that uses Ryan Bates nested_form plugin . The plugin is
I have a simple page view tracker that uses a combination of PHP and
I have the following simple application page that uses the phone camera to upload
I have a page that uses jQuery tabs to tabify a set of HTML
I have a web report that uses a Django form (new forms) for fields
I have built a report using Report Builder 3.0 (that uses SQL Server 2008
I have a page on my web site that reports on the health of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.