Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Adding Trend Line to Report Chart

C# Script

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

{

            Series aSeries = ((XRChart)sender).Series[0];

            TrendLine aTredLine = ((LineSeriesView)aSeries.View).FinancialIndicators.TrendLines[0];

            aTredLine.Point1.Argument = aSeries.Points[0].Argument;

            aTredLine.Point2.Argument = aSeries.Points[aSeries.Points.Count - 1].Argument;

}

 

If your chart is a bar chart change ‘LineSeriesView’ to ‘BarSeriesView’ in the second line of code

Click on Chart Line you want to add trendline for in the designer

Image Added

 

In the property grid for the line go to the elements section, expand View.  Select Indicators and a pop up box will appear.

Select Add and another pop up will appear.

Select Trend Line and hit ok

Image Added

It will then give you a trend line property grid.  Make appropriate changes such as changing the trend line color and hit close.

Image Added

Save and run your report.

 

Example:

Image Added