Embedded Charts in Reports Displaying Incorrectly

Embedded Charts in Reports Displaying Incorrectly

Reported: May 16, 2019

Version(s) affected: DataSight 3.5 onwards

Issue: Reports created in Report Designer with embedded charts may not display correctly when the report is previewed, printed or exported. This is due to the implementation of scripting functionality within Report Designer (see the article Handle Events via Scripts for further information on using scripts in Reports).

Resolution: The below script can be used to correct the majority of Reports which are affected by this issue. If performing the below steps does not resolve this issue, please contact us for assistance.

To implement this script in your Report, perform the following steps:

  1. Right-click your report and select Design -> With The Saved Filter from the context menu.
  2. Click the affected chart in your Report.
  3. Click Scripts at the top-right in the Report Designer Ribbon.
  4. Select and copy the Script to Handle Grouping by Level in a Chart located below.
  5. Right-click within the scripting window within Report Designer and select Paste from the context menu.
  6. Click Validate from the Ribbon to connect the chart to the script.
  7. Click Designer at the top-right of the Report Designer Ribbon and save your Report.

Your Report should now preview, print and export with the chart displayed correctly.

Last Updated: May 16, 2019

 

Script to Handle Grouping by Level in a Chart

private void chart1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {

    XRChart xrc = (XRChart)sender;

 

    // Gets the current value of the grouping field.

    // For the master-detail report, use DetailBand.GetCurrentColumnValue in the detail band instead.

    string filter_value = GetCurrentColumnValue("LEVELNAME").ToString();

 

    // Clears the filters that may have been set earlier.

    xrc.Series[0].DataFilters.Clear();

 

    // Creates and adds a new filter to the "TheGroupingField" data field 

    // that has the type System.String.

    // The condition is that the data value equals the filter_value parameter.

    xrc.Series[0].DataFilters.Add(new DataFilter("LEVELNAME", "System.String",

        DataFilterCondition.Equal, filter_value));

}