Forgot password?

Question: How to create a line with gaps in MSChartObject?

Answer:

You should create base System.Windows.Forms.DataVisualization.Charting.Series object and create line there. After this should assign created series for MSChartObject base chart (MSChart1.Chart.Series.Add(series);) Don't forget add System.Windows.Forms.DataVisualization.dll in Report -> Script menu and namespace System.Windows.Forms.DataVisualization.Charting.

Example of line with gaps:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
.
.
using System.Windows.Forms.DataVisualization.Charting;
 
namespace FastReport
{
 public class ReportScript
 {
 private void MSChart1_BeforePrint(object sender, EventArgs e)
 { 
 Series series = new Series("sample");
 series.ChartType = SeriesChartType.Line;
 series.BorderWidth = 2;
 series.MarkerSize = 5;
 
 series.Points.Add(new DataPoint(0, 1));
 series.Points.Add(new DataPoint(1, 2));
 DataPoint dp = new DataPoint(2, double.NaN);
 dp.IsEmpty = true;
 series.Points.Add(dp);
 series.Points.Add(new DataPoint(3, 5));
 series.Points.Add(new DataPoint(4, 8)); 
 
 MSChart1.Chart.Series.Add(series);
 
 }
 }
}

 Result:

Line with gaps