This is a migrated thread and some comments may be shown as answers.

RadChart

3 Answers 93 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Prakash
Top achievements
Rank 1
Prakash asked on 02 Dec 2013, 08:52 AM
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);
            }
        }
       

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 03 Dec 2013, 01:11 PM
Hello,

The best way to achieve this is to use MVVM and to put your custom logic in your models. This approach is demonstrated in the help topic you mentioned. Once you incorporate it you can use it with any control - RadChart, RadChartView, etc. By the way, the RadChartView is our new charting solution, which is designed with performance and simplicity in mind. You can try it out and see how easier it is.

Regards,
Yavor
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Arun
Top achievements
Rank 1
answered on 28 Jul 2016, 12:42 PM

hello,
Am using radchart in my wpf application and showing the data for three years like current year, last year and 2 year ago.

Graphs is working fine for 2 year ago but when we open same for current year or last year getting below errors -

{"No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. "}

Trace file details-
   at System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)
   at System.Linq.Expressions.Expression.Call(Type type, String methodName, Type[] typeArguments, Expression[] arguments)
   at Telerik.Windows.Data.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilderBase.CreateMethodCallExpression(LambdaExpression memberSelectorExpression) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Expressions\Grouping\Aggregates\EnumerableSelectorAggregateFunctionExpressionBuilderBase.cs:line 36

 

Above path is also not available in my machine.
please help to find the solution...


0
Martin Ivanov
Telerik team
answered on 01 Aug 2016, 08:09 AM
Hi Arun,

Without your set up I cannot be sure what is causing the error. This is why would ask you to send me runnable code snippets that isolates the exception, here in the forum. Or open a new support ticket and attach a sample project.

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Chart
Asked by
Prakash
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Arun
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or