Silverlight Teechart - DataUpdates rendered incorrectly
Posted: Thu Feb 26, 2009 4:41 am
I have Teechart Version 4 Silverlight Teechart Beta.
I have Line series which is binded to ObservableCollection. Data update to a series point adds new point in the series. Instead it should update the existing point.
I know it is in Beta version.
The code for same is given Below. On click of button 'Button_Click', the third item in observable collection is updated. And it adds new point in series which is incorrect.
public partial class Teechart2 : UserControl
{
public Teechart2()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Silverlight.Styles.Line line;
private NameList observable;
private int count;
private void Button_Click(object sender, RoutedEventArgs e)
{
count += 20;
observable[2].Height = 300 + count;
tChart1.Series[0].CheckDataSource();
//observable.RemoveAt(3);
//tChart1.Series[0].CheckDataSource();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(line = new
Steema.TeeChart.Silverlight.Styles.Line());
line.XValues.DataMember = "DateOfBirth";
line.XValues.DateTime = true;
line.YValues.DataMember = "Height";
line.LabelMember = string.Empty;
line.Pointer.Visible = true;
observable = new NameList();
line.DataSource = observable;
}
}
public class NameList : ObservableCollection<Person>
{
public NameList()
: base()
{
Add(new Person("Willa", "Cather", DateTime.Today.AddYears(1), Colors.Red, 171));
Add(new Person("Isak", "Dinesen", DateTime.Today.AddYears(2), Colors.Green, 189));
Add(new Person("Victor", "Hugo", DateTime.Today.AddYears(3), Colors.Blue, 196));
Add(new Person("Jules", "Verne", DateTime.Today, Colors.Orange, 175));
Add(new Person("H", "Priya", DateTime.Today.AddYears(4), Colors.Red, 134));
Add(new Person("G", "Vipul", DateTime.Today.AddYears(5), Colors.Green, 189));
}
}
public class Person
{
private string firstName;
private string lastName;
private DateTime dob;
private Color favorite;
private int height;
public Person(string first, string last, DateTime dob, Color favorite, int height)
{
this.firstName = first;
this.lastName = last;
this.dob = dob;
this.favorite = favorite;
this.height = height;
}
public string FirstName
{
get { return firstName; }
set
{
firstName = value;
}
}
public string LastName
{
get { return lastName; }
set
{
lastName = value;
}
}
public DateTime DateOfBirth
{
get { return dob; }
set
{
dob = value;
}
}
public Color FavoriteColor
{
get { return favorite; }
set
{
favorite = value;
}
}
public int Height
{
get { return height; }
set
{
height = value;
}
}
}
Regards,
Priya
I have Line series which is binded to ObservableCollection. Data update to a series point adds new point in the series. Instead it should update the existing point.
I know it is in Beta version.
The code for same is given Below. On click of button 'Button_Click', the third item in observable collection is updated. And it adds new point in series which is incorrect.
public partial class Teechart2 : UserControl
{
public Teechart2()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Silverlight.Styles.Line line;
private NameList observable;
private int count;
private void Button_Click(object sender, RoutedEventArgs e)
{
count += 20;
observable[2].Height = 300 + count;
tChart1.Series[0].CheckDataSource();
//observable.RemoveAt(3);
//tChart1.Series[0].CheckDataSource();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(line = new
Steema.TeeChart.Silverlight.Styles.Line());
line.XValues.DataMember = "DateOfBirth";
line.XValues.DateTime = true;
line.YValues.DataMember = "Height";
line.LabelMember = string.Empty;
line.Pointer.Visible = true;
observable = new NameList();
line.DataSource = observable;
}
}
public class NameList : ObservableCollection<Person>
{
public NameList()
: base()
{
Add(new Person("Willa", "Cather", DateTime.Today.AddYears(1), Colors.Red, 171));
Add(new Person("Isak", "Dinesen", DateTime.Today.AddYears(2), Colors.Green, 189));
Add(new Person("Victor", "Hugo", DateTime.Today.AddYears(3), Colors.Blue, 196));
Add(new Person("Jules", "Verne", DateTime.Today, Colors.Orange, 175));
Add(new Person("H", "Priya", DateTime.Today.AddYears(4), Colors.Red, 134));
Add(new Person("G", "Vipul", DateTime.Today.AddYears(5), Colors.Green, 189));
}
}
public class Person
{
private string firstName;
private string lastName;
private DateTime dob;
private Color favorite;
private int height;
public Person(string first, string last, DateTime dob, Color favorite, int height)
{
this.firstName = first;
this.lastName = last;
this.dob = dob;
this.favorite = favorite;
this.height = height;
}
public string FirstName
{
get { return firstName; }
set
{
firstName = value;
}
}
public string LastName
{
get { return lastName; }
set
{
lastName = value;
}
}
public DateTime DateOfBirth
{
get { return dob; }
set
{
dob = value;
}
}
public Color FavoriteColor
{
get { return favorite; }
set
{
favorite = value;
}
}
public int Height
{
get { return height; }
set
{
height = value;
}
}
}
Regards,
Priya