Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
360
Reporting With Dynamically Created Chart
posted

I am creating a chart in code and then adding it to a List of EmbeddedVisualReportSection for it to get printed.  Once my List is complete i create a preview dialog with this code in the constructor:

// Create report and add visual to print

            Report reportObj = new Report();

 

            foreach(EmbeddedVisualReportSection section in sections)

            {

                reportObj.Sections.Add(section);

            }

           

            // Put report to preview control

            XamReportPreview1.GeneratePreview(reportObj, true, true);

 

It never displays in the print preview, and never prints.  All I get is the grid scene background color, but no chart??  Anyone see anything wrong with the code below other than it is ugly :)...I haven't had a chance to clean it up because as it stands, it doesn't work

 

I create the chart like so:

if (selectedSchedule.budgetReport != null && selectedSchedule.budgetReport.TotalCost != 0)

            {               

                Series series = new Series();               

                series.Label = "Total Cost";

                series.Marker = new Marker();

                DataPoint dataPt0 = new DataPoint();

                dataPt0.Label = "Total Cost";

                dataPt0.Value = Convert.ToDouble(selectedSchedule.budgetReport.TotalCost);

                DataPoint dataPt1 = new DataPoint();

                dataPt1.Label = "Total Billing";

                dataPt1.Value = Convert.ToDouble(selectedSchedule.budgetReport.TotalBilling);

                DataPoint dataPt2 = new DataPoint();

                dataPt2.Label = "Total OT Cost";

                dataPt2.Value = Convert.ToDouble(selectedSchedule.budgetReport.TotalOTCost);

                DataPoint dataPt3 = new DataPoint();

                dataPt3.Label = "Total OT Billing";

                dataPt3.Value = Convert.ToDouble(selectedSchedule.budgetReport.TotalOTBilling);

                series.DataPoints.Add(dataPt0);

                series.DataPoints.Add(dataPt1);

                series.DataPoints.Add(dataPt2);

                series.DataPoints.Add(dataPt3);

                series.DataPointColor = DataPointColor.Different;

                mainPage.totalCostControl.chart.Series.Add(series);               

                mainPage.TotalCostContentPane.IsPinned = true;

                mainPage.totalCostControl.chartTitle.Text = "Total Cost";

                mainPage.totalCostControl.chart.Visibility = Visibility.Visible;

            }

Parents
No Data
Reply
  • 360
    posted

     if the chart is in xaml and on a page and i add the chart that way it works.  I can't really do that though because i have to loop through the record in the grid and build the charts for the printing.  They are not displayed on the screen normally.

Children