hello,
Am using radchart in my wpf application, my requirement is based on Y axis value i have to set the different color for point marks in same line series chart.
for example am having values from 50 to 100, let say i want to set point mark Redfor values between 50 to 75, and remaining green in the same line series chart area..
please help to find the solution...
i have try the below option but it not works,,
foreach (var item in qry)
{
if(condition)
{
line.Appearance.Fill = new SolidColorBrush(Colors.Green);
}
else if (condition)
{
line.Appearance.Fill = new SolidColorBrush(Colors.Red);
}}
i need like this kind of effect in my wpf application ...
http://www.telerik.com/help/wpf/radchart-howto-set-custom-fill-for-pointmarks-depending-on-condition.html
my code below...
******************************
public void chartmain()
{
listStackPanel.Visibility = System.Windows.Visibility.Hidden;
try
{
var qry = (from s in SWindow.HBList
where (s.User_id.Equals(W.Profile.UserId))
orderby s.Test_date ascending
select new { s.HB_score, s.Test_date }).ToList();
if (qry.Count == 0)
{
SMessageBox.MessageBox.ShowInformation("No Records Found...");
radChart.Visibility = System.Windows.Visibility.Hidden;
listStackPanel.Visibility = System.Windows.Visibility.Hidden;
}
else
{
radChart.Visibility = System.Windows.Visibility.Visible;
radChart.DefaultView.ChartArea.AxisX.IsDateTime = true;
radChart.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Auto;
radChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
radChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd-MMM";
DataSeries lineSeries1 = new DataSeries();
foreach (var item in qry)
{
SMessageBox.MessageBox.ShowInformation(item.ToString());
lineSeries1.Add(new DataPoint() {
YValue = Convert.ToDouble(item.HB_score), XValue = item.Test_date.ToOADate()
});
}
LineSeriesDefinition line = new LineSeriesDefinition();
radChart.DefaultSeriesDefinition = line;
line.Appearance.Fill = new SolidColorBrush(Colors.Black);
line.Appearance.Stroke = new SolidColorBrush(Colors.DarkGreen);
line.Appearance.PointMark.Stroke = new SolidColorBrush(Colors.Black);
line.ShowPointMarks = true;
line.ShowItemLabels = true;
lineSeries1.Definition = line;
this.BHGridView.ItemsSource = qry;
this.radChart.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;
this.radChart.DefaultView.ChartArea.DataSeries.Add(lineSeries1);
}
}
catch (Exception ex) {
SMessageBox.MessageBox.ShowError(ex.Message);
}
}
Am using radchart in my wpf application, my requirement is based on Y axis value i have to set the different color for point marks in same line series chart.
for example am having values from 50 to 100, let say i want to set point mark Redfor values between 50 to 75, and remaining green in the same line series chart area..
please help to find the solution...
i have try the below option but it not works,,
foreach (var item in qry)
{
if(condition)
{
line.Appearance.Fill = new SolidColorBrush(Colors.Green);
}
else if (condition)
{
line.Appearance.Fill = new SolidColorBrush(Colors.Red);
}}
i need like this kind of effect in my wpf application ...
http://www.telerik.com/help/wpf/radchart-howto-set-custom-fill-for-pointmarks-depending-on-condition.html
my code below...
******************************
public void chartmain()
{
listStackPanel.Visibility = System.Windows.Visibility.Hidden;
try
{
var qry = (from s in SWindow.HBList
where (s.User_id.Equals(W.Profile.UserId))
orderby s.Test_date ascending
select new { s.HB_score, s.Test_date }).ToList();
if (qry.Count == 0)
{
SMessageBox.MessageBox.ShowInformation("No Records Found...");
radChart.Visibility = System.Windows.Visibility.Hidden;
listStackPanel.Visibility = System.Windows.Visibility.Hidden;
}
else
{
radChart.Visibility = System.Windows.Visibility.Visible;
radChart.DefaultView.ChartArea.AxisX.IsDateTime = true;
radChart.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Auto;
radChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
radChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd-MMM";
DataSeries lineSeries1 = new DataSeries();
foreach (var item in qry)
{
SMessageBox.MessageBox.ShowInformation(item.ToString());
lineSeries1.Add(new DataPoint() {
YValue = Convert.ToDouble(item.HB_score), XValue = item.Test_date.ToOADate()
});
}
LineSeriesDefinition line = new LineSeriesDefinition();
radChart.DefaultSeriesDefinition = line;
line.Appearance.Fill = new SolidColorBrush(Colors.Black);
line.Appearance.Stroke = new SolidColorBrush(Colors.DarkGreen);
line.Appearance.PointMark.Stroke = new SolidColorBrush(Colors.Black);
line.ShowPointMarks = true;
line.ShowItemLabels = true;
lineSeries1.Definition = line;
this.BHGridView.ItemsSource = qry;
this.radChart.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;
this.radChart.DefaultView.ChartArea.DataSeries.Add(lineSeries1);
}
}
catch (Exception ex) {
SMessageBox.MessageBox.ShowError(ex.Message);
}
}