Hello:
Okay,the code is below
Code: Select all
public Form4()
{
InitializeComponent();
InitializeChart();
}
class Student
{
public string Name { get; set; }
public double? Value { get; set; }
public Student(string name, double? value)
{
Name = name;
Value = value;
}
}
private void InitializeChart()
{
List<Student> list = new List<Student>();
var age = new Line(tChart1.Chart);
age.YValues.DataMember = "Value";
age.LabelMember = "Name";
age.Title = "Age";
age.LinePen.Width = 3;
list.Add(new Student("A", 10));
list.Add(new Student("B", null));
list.Add(new Student("C", 11));
list.Add(new Student("D",14));
age.Add(list as IList);
(tChart1[0] as Steema.TeeChart.Styles.CustomPoint).TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
}
Maybe TeeChart think when value is null,then process it to 0 . Can i set it to DoNotPaint but
not use SetNull(int valueIndex) function. So I don't need know the null value is which valueIndex. I hope TeeChart can process null value automatic. Does TeeChart has which function can do it?
The below code execute result is what i expect.
Code: Select all
public Form4()
{
InitializeComponent();
InitializeChart();
}
class Student
{
public string Name { get; set; }
public double? Value { get; set; }
public Student(string name, double? value)
{
Name = name;
Value = value;
}
}
private void InitializeChart()
{
List<Student> list = new List<Student>();
var age = new Line(tChart1.Chart);
age.YValues.DataMember = "Value";
age.LabelMember = "Name";
age.Title = "Age";
age.LinePen.Width = 3;
list.Add(new Student("A", 10));
list.Add(new Student("B", null));
list.Add(new Student("C", 11));
list.Add(new Student("D",14));
age.Add(list as IList);
for (var i = 0; i < list.Count; i++)
{
if (list[i].Value is null)
{
tChart1[0].SetNull(i);
}
}
(tChart1[0] as Steema.TeeChart.Styles.CustomPoint).TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
}
Maybe my datalist is large, then I don't need to iterator the list can reduce the code rendering time
Do I make myself clear?