We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

UWP and SfDateTimeRangeNavigator with Chart

Thread ID:

Created:

Updated:

Platform:

Replies:

132038 Aug 8,2017 06:17 AM Aug 15,2017 06:18 AM UWP 9
loading
Tags: SfChart
Enrico
Asked On August 8, 2017 06:17 AM

Hi guys,
I copied in my UWP project the example called GettingStartedRangeNavigator

The XAML is

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms"
             xmlns:rangenavigator="clr-namespace:Syncfusion.RangeNavigator.XForms;assembly=Syncfusion.SfChart.XForms"
             xmlns:local="clr-namespace:LifeInTheUK.Views;assembly=LifeInTheUK"
             x:Class="LifeInTheUK.Views.StatisticTimeView">
    <ContentPage.Content>
        <StackLayout x:Name="layout" Padding="10, 20, 10, 10" BackgroundColor="Transparent">
            <chart:SfChart x:Name="Chart" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <chart:SfChart.BindingContext>
                    <local:DataModel/>
                </chart:SfChart.BindingContext>
                <chart:SfChart.PrimaryAxis>
                    <chart:DateTimeAxis x:Name="dateTimeAxis" Minimum="5/1/2015" Maximum="8/1/2015">
                        <chart:DateTimeAxis.LabelStyle>
                            <chart:ChartAxisLabelStyle LabelFormat="MMM/dd" />
                        </chart:DateTimeAxis.LabelStyle>
                    </chart:DateTimeAxis>
                </chart:SfChart.PrimaryAxis>
                <chart:SfChart.SecondaryAxis>
                    <chart:NumericalAxis/>
                </chart:SfChart.SecondaryAxis>
                <chart:SfChart.Series>
                    <chart:SplineAreaSeries ItemsSource="{Binding DateTimeData}" XBindingPath="Date" YBindingPath="Value" />
                </chart:SfChart.Series>
            </chart:SfChart>
            <rangenavigator:SfDateTimeRangeNavigator x:Name="RangeNavigator" RangeChanged="nac_RangeChanged" ItemsSource="{Binding DateTimeData}"
                          XBindingPath="Date" YBindingPath="Value" HeightRequest="120" ViewRangeStart="5/1/2015" ViewRangeEnd="8/1/2015">
                <rangenavigator:SfDateTimeRangeNavigator.BindingContext>
                    <local:DataModel/>
                </rangenavigator:SfDateTimeRangeNavigator.BindingContext>
            </rangenavigator:SfDateTimeRangeNavigator>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
The code behind is

using LifeInTheUK.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace LifeInTheUK.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class StatisticTimeView : ContentPage
    {
        public StatisticTimeView()
        {
            InitializeComponent();
            dateTimeAxis.Minimum = DateTime.Now.AddDays(-2);
            dateTimeAxis.Maximum = DateTime.Now;
            RangeNavigator.Minimum = DateTime.Now.AddDays(-2);
            RangeNavigator.Maximum = DateTime.Now;
        }
        void nac_RangeChanged(object sender, Syncfusion.RangeNavigator.XForms.RangeChangedEventArgs e)
        {
            dateTimeAxis.Minimum = e.ViewRangeStartDate;
            dateTimeAxis.Maximum = e.ViewRangeEndDate;
        }
    }

    public class DataModel
    {
        public ObservableCollection<Model> DateTimeData { get; set; }
        public DataModel()
        {
            DateTimeData = new ObservableCollection<Model>
            {
                new Model (DateTime.Now.AddDays(-4), 14),
                new Model (DateTime.Now.AddDays(-3), 54),
                new Model (DateTime.Now.AddDays(-2), 23),
                new Model (DateTime.Now.AddDays(-1), 53),
                new Model (DateTime.Now, 25),
                new Model (DateTime.Now.AddDays(1), 32),
                new Model (DateTime.Now.AddDays(2), 78),
                new Model (DateTime.Now.AddDays(3), 100),
                new Model (DateTime.Now.AddDays(4), 55),
                new Model (DateTime.Now.AddDays(5), 38),
            };
        }
    }
    public class Model
    {
        public DateTime Date { get; set; }
        public double Value { get; set; }
        public Model(DateTime dateTime, double value)
        {
            Date = dateTime;
            Value = value;
        }
    }
}
The problem I have is the render of the Chart because I can see something only if I select the first part of the range. If I change the range, I don't see any graph. In attach some screenshots.


Attachment: screenshot_9c48dcc5.zip

Durgadevi Selvaraj [Syncfusion]
Replied On August 9, 2017 09:06 AM

Hi Enrico, 
 
Thanks for contacting Syncfusion Support. 
 
We have tried to reproduce the reported problem based on your reference codes and unable to reproduced the issue on our end.  
Please find the output screenshots below, 
 
 
 
 
 
  
Please find the sample from below link, 
If you are still able to reproduce the reported problem, please revert us with more information or modifying the above sample it would be helpful for us to provide a solution sooner. 
  
Regards,  
Durgadevi S 


Enrico
Replied On August 10, 2017 08:15 AM

Hi,

thank you for your example. Unfortunately, it doesn't work for me. I tried to update your components but there are not on NuGet. I added my local copy but doesn't work.

Another problem is: in UWP I still have this issue with render but in Android and iOS the component doesn't show anything (in iOS I'm calling new SfChartRenderer();).

When I start my project on Android, I receive an error (in attach). Now the code is very easy:

                    <chart:SfChart x:Name="Chart" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HeightRequest="200">
                        <chart:SfChart.PrimaryAxis>
                            <chart:NumericalAxis IsVisible="False" />
                        </chart:SfChart.PrimaryAxis>
                        <chart:SfChart.Series>
                            <chart:AreaSeries ItemsSource ="{Binding TestData}" XBindingPath="Date" YBindingPath="ResultPercent" />
                        </chart:SfChart.Series>
                        <chart:SfChart.ChartBehaviors>
                            <chart:ChartZoomPanBehavior EnablePanning="true" EnableDoubleTap="false"/>
                        </chart:SfChart.ChartBehaviors>
                    </chart:SfChart>

TestData is

public ObservableCollection<DataPoint> TestData { get; set; }


And DataPoint is

    public class DataPoint
    {
        public DateTime Date { get; set; }
        public int NumberOfQuestions { get; set; }
       public int NumberOfRightAnswers { get; set; }
       public int NumberOfWrongAnswers { get; set; }
      public decimal ResultPercent { get; set; }
    }

Thank yo in advance


Attachment: android_error_log_8d96d40d.zip

Enrico
Replied On August 10, 2017 08:19 AM

Just in case, here you have the full error log


Attachment: android_full_error_log_6586c1d2.zip

Saravana Pandian Murugan [Syncfusion]
Replied On August 11, 2017 07:52 AM

Hi Enrico, 
  
S. No 
Queries 
Answer 
  
1. 
I tried to update your components but there are not on NuGet 
  
You can overcome this problem by following Nuget installation steps in the below link,   
2. 
In UWP I still have this issue with render 
If you are able to reproduce the problem when run the previous updated sample in UWP, please revert us with more information with your system details, it would be helpful for us to provide a solution sooner  
  
3. 
But in Android and iOS the component doesn't show anything (in iOS I'm calling new SfChartRenderer()) 
Sorry for the inconvenience caused.  
 
We would like to let you know that we have integrated SfChart Xamarin.Android and Xamarin.iOS source in Xamarin.Forms renderer projects in our Volume 3, 2017 release. So, could you please remove the Syncfusion.SfChart.Android.dll from your Xamarin.Forms android project and Syncfusion.SfChart.iOS.dll from your Xamarin.Forms iOS project.  
 
Also, you need to add new SfRangeNavigatorRenderer(); code in AppDelegate.cs file. 
 
After the above steps, we kindly request you to Rebuild your project before making deployment. 
 
Please let us know if you are facing any issue in this.  
 
  
 
Regards, 
Saravana Pandian M. 


Enrico
Replied On August 14, 2017 07:52 AM

Hi Saravana,

thank you for your email. In Android I found this error

08-14 12:48:26.793 25611-25611/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: LifeInTheUK.Android, PID: 25611
                                                   java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                    Caused by: java.lang.reflect.InvocationTargetException
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
                                                    Caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
                                                     at Com.Syncfusion.Charts.AreaSegment.SetData (System.Collections.IList xValues, System.Collections.IList yValues) [0x000b7] in <619005bdcd354845b2f196e292e85bb9>:0
                                                     at Com.Syncfusion.Charts.AreaSeries.CreateSegments () [0x00094] in <619005bdcd354845b2f196e292e85bb9>:0
                                                     at Com.Syncfusion.Charts.ChartSeries.InternalCreateSegments () [0x00020] in <619005bdcd354845b2f196e292e85bb9>:0
                                                     at Com.Syncfusion.Charts.ChartBase.UpdateArea () [0x00088] in <619005bdcd354845b2f196e292e85bb9>:0
                                                     at Com.Syncfusion.Charts.ChartBase.OnMeasureChart () [0x00031] in <619005bdcd354845b2f196e292e85bb9>:0
                                                     at Com.Syncfusion.Charts.SfChart.OnMeasure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x0003e] in <619005bdcd354845b2f196e292e85bb9>:0
                                                     at Android.Views.View.n_OnMeasure_II (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00008] in <056f01a060094e3d88a61b3d647a92f3>:0
                                                       at (wrapper dynamic-method) System.Object:535034c9-f855-46c3-bed5-ed30ff445fbb (intptr,intptr,int,int)
                                                   --- End of stack trace from previous location where exception was thrown ---
                                                     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <0d6c06b57a5444608385c7dd1ce0597a>:0
                                                     at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <c6091a2e49094cdd81be08620999410f>:0
                                                     at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in <c6091a2e49094cdd81be08620999410f>:0
                                                     at Android.Views.View.Measure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00035] in <056f01a060094e3d88a61b3d647a92f3>:0
                                                     at Xamarin.Forms.Platform.Android.ViewRenderer`2[TView,TNativeView].OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00054] in <1481f85a917c4f2b882ea161e9bc082f>:0
                                                     at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean p0, System.Int32 p1, System.Int32 p2, System.Int32 p3, System.Int32 p4) [0x00008] in <509b941eb6c9409ea563416977a01cbe>:0
                                                       at (wrapper dynamic-method) System.Object:6deb39f7-3e39-4e7a-8ade-bd181396a8a5 (intptr,intptr,bool,int,int,int,int)
                                                   --- End of stack trace from previous location where exception was thrown ---
                                                     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <0d6c06b57a5444608385c7dd1ce0597a>:0
                                                     at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <c6091a2e49094cdd81be08620999410f>:0
                                                     at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <c6091a2e49094cdd81be08620999410f>:0
                                                     at Xamarin.Forms.Platform.Android.FormsViewGroup.MeasureAndLayout (System.Int32 p0, System.Int32 p1, System.Int32 p2, System.Int32 p3, System.Int32 p4, System.Int32 p5) [0x00090] in <509b941eb6c9409ea563416977a01cbe>:0
                                                     at Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout () [0x0

Enrico
Replied On August 14, 2017 07:57 AM

I followed the instruction https://help.syncfusion.com/xamarin/introduction/download-and-installation but if I use NuGet I can't find this references https://help.syncfusion.com/xamarin/introduction/download-and-installation#add-reference-to-the-project

Now also UWP doesn't show any graphs.


Enrico
Replied On August 14, 2017 08:16 AM

This error occurs when data are empty or with one element.


Enrico
Replied On August 14, 2017 09:18 AM

After updating to version 15.6.0.26, if I try with a simple collection like

                rtn.Add(new DataPoint()
                {
                    Date = DateTime.Now,
                    NumberOfQuestions = 1,
                    NumberOfRightAnswers = 1,
                    NumberOfWrongAnswers = 1,
                    ResultPercent = 1
                });
                rtn.Add(new DataPoint()
                {
                    Date = DateTime.Now,
                    NumberOfQuestions = 2,
                    NumberOfRightAnswers = 2,
                    NumberOfWrongAnswers = 2,
                    ResultPercent = 2
                });
                rtn.Add(new DataPoint()
                {
                    Date = DateTime.Now,
                    NumberOfQuestions = 3,
                    NumberOfRightAnswers = 3,
                    NumberOfWrongAnswers = 3,
                    ResultPercent = 3
                });

the result is an empty view (file in attach).


Attachment: Screenshots_69980d01.zip

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On August 15, 2017 06:18 AM

Hi Enrico, 
  
Thanks for your update. 
  
We are tried to reproduce the reported problem at our end with provided information. But we are unable to reproduce it. We have prepared a demo sample for your reference and it can be downloaded from below link, 
  
  
If you still able to reproduce the reported problem, please revert us by modifying the provided sample. It would be more helpful for us to serve you better. 
  
Regards, 
Devi 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;