If you are familiar with ASP.NET chart controls, the Chart object contains several series objects — these are series of data that you can chart. Each series can be visualized differently (line or point or line) in one diagram.
I have a custom control that I use to create and delete and modify Series lists in the user interface. When a button is clicked, a chart is created using these Series. However, if I try to redisplay the diagram (even with identical series), it explodes and throws a NullReferenceException.
Here is the relevant code - I have a series of wrapping objects (because I have some custom properties)
public class DataSeries
{
private Series _series = new Series();
... (bunch of other properties)
public Series Series
{
get { return _series; }
set { _series = value; }
}
}
( - , , ):
private static List<DataSeries> seriesList;
public List<DataSeries> ListOfSeries
{
get { return seriesList; }
set { seriesList = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
seriesList = new List<DataSeries>();
}
}
- , DataSeries, . .
" " , , :
protected void refreshChart(object sender, EventArgs e)
{
chart.Series.Clear();
foreach (DataSeries s in seriesControl.ListOfSeries)
{
string propertyName = s.YAxisProperty;
List<Sampled_Data> sampleList = Sample.GetSamplesById(s.ComponentId);
foreach (Sampled_Data dSample in sampleList)
{
s.Series.Points.AddY(BindingLib.GetPropertyValue(dSample, propertyName));
}
chart.Series.Add(s.Series);
}
}
, , .
, , "refreshChart", NullReferenceException, "s.Series.Points" null. , Points - .
Points , ?
, , , , - DataSeries , - , , Points, . ListOfSeries , . , , Series - customfields ( - ). , , .
, ?