Telerik Forums
UI for Xamarin Forum
21 answers
258 views

Hello guys, 

I was looking in the documentation of the Charts whether it is possible to show data points in the line like this in the attached picture ? I was not able to find it. Could you please provide some information.

 

 

Lance | Senior Manager Technical Support
Telerik team
 answered on 05 Nov 2020
1 answer
67 views
Hello.
Tell me how to get the items that are currently displayed on the chart after zooming and scrolling?
I use custom renderer to get native control and handle pan and zoom events using PanZoomListener, but in the handler I can only get relative offset.

here is my renderer

    class ChartPointRenderer : CartesianChartRenderer
    {
        public ChartPointRenderer(Context context) :base(context)
        {
        }
        protected override RadCartesianChartView CreateNativeControl()
        {
             Control = base.CreateNativeControl();
             return Control;
        }
        protected override void OnAttachedToWindow()
        {
            base.OnAttachedToWindow();
            var beh = Control.Behaviors.ToArray();
            for (int j = 0; j < beh.Length; j++)
            {
                if (beh[j].GetType() == typeof(Telerik.XamarinForms.ChartRenderer.Android.AndroidChartPanAndZoomBehavior))
                {
                    var zoomBehavior = (Telerik.XamarinForms.ChartRenderer.Android.AndroidChartPanAndZoomBehavior)beh[j];
                    zoomBehavior.AddPanZoomListener(new Listeners.ChartPanZoomListener());
                }
            }
        }
    }



and listener

    public class ChartPanZoomListener :Java.Lang.Object, IPanZoomListener
    {

        public IntPtr Handle => throw new NotImplementedException();

        public void OnPan(double p0, double p1)
        {
            //do something
        }

        public void OnZoom(double p0, double p1)
        {
            //do something
        }
    }
Yana
Telerik team
 answered on 20 Oct 2020
7 answers
160 views
Hi i have problem creating multi axes chart for iOS.

Im trying to do something like the image attached and i read a lot of documentation but all of that is using native controller for iOS.
I have done creating this on android using customrenderer.

Is there any way to show the bar series YAXIS to right side of the chart? 
Here's how my approach using custom renderer on iOS.

<telerikChart:RadCartesianChart
              x:Name="multiAxesGraph"
              Grid.Row="1"
              BackgroundColor="{OnPlatform iOS=Transparent}"
              HorizontalOptions="FillAndExpand"
              Zoom="1,1">
              <telerikChart:RadCartesianChart.HorizontalAxis>
                  <telerikChart:DateTimeContinuousAxis
                      LabelFitMode="Rotate"
                      LabelFontSize="9"
                      LabelFormat="MM/d"
                      LabelTextColor="White"
                      LineColor="White"
                      MajorStep="7"
                      MajorStepUnit="Day"
                      MajorTickThickness="5"
                      PlotMode="OnTicks" />
              </telerikChart:RadCartesianChart.HorizontalAxis>
              <telerikChart:RadCartesianChart.VerticalAxis>
                  <telerikChart:NumericalAxis
                      LabelFontSize="9"
                      LabelTextColor="White"
                      LineColor="White"
                      MajorStep="5"
                      Maximum="{Binding MaxWeight, Mode=TwoWay}"
                      Minimum="{Binding MinWeight, Mode=TwoWay}" />
              </telerikChart:RadCartesianChart.VerticalAxis>
              <telerikChart:RadCartesianChart.Series>
 
                  <telerikChart:LineSeries
                      CategoryBinding="Category"
                      DisplayName="Weight"
                      ItemsSource="{Binding WeightGraph, Mode=TwoWay}"
                      ValueBinding="Value" />
 
                  <telerikChart:BarSeries
                      CategoryBinding="Category"
                      DisplayName="Water"
                      ItemsSource="{Binding WaterGraph, Mode=TwoWay}"
                      ValueBinding="Value" />
 
              </telerikChart:RadCartesianChart.Series>
              <telerikChart:RadCartesianChart.Palette>
                  <telerikChart:ChartPalette>
                      <telerikChart:ChartPalette.Entries>
                          <telerikChart:PaletteEntry FillColor="White" StrokeColor="White" />
                          <telerikChart:PaletteEntry FillColor="#8cc63f" StrokeColor="#8cc63f" />
                      </telerikChart:ChartPalette.Entries>
                  </telerikChart:ChartPalette>
              </telerikChart:RadCartesianChart.Palette>
              <telerikChart:RadCartesianChart.ChartBehaviors>
                  <telerikChart:ChartPanAndZoomBehavior
                      HandleDoubleTap="True"
                      PanMode="Horizontal"
                      ZoomMode="Horizontal" />
              </telerikChart:RadCartesianChart.ChartBehaviors>
          </telerikChart:RadCartesianChart>




protected override void OnElementChanged(ElementChangedEventArgs<RadCartesianChart> e)
{
    base.OnElementChanged(e);
    var series = Control.Series.ToArray();
 
    if (series.Length == 2)
    {
        TKChartNumericAxis nativeAxis = series[1].YAxis as TKChartNumericAxis;
        nativeAxis.Position = TKChartAxisPosition.Right;
        nativeAxis.Style.LabelStyle.TextColor = UIColor.Green;
        nativeAxis.Style.LineHidden = false;
        nativeAxis.Style.LineStroke = new TKStroke(UIColor.White);
        series[1].YAxis = nativeAxis;
    }
 
}

I'm stuck here for 2 days creating custom renderer for iOS but none of them succeed.

Thanks
Yana
Telerik team
 answered on 02 Jun 2020
5 answers
161 views
Is there any properties about Palette for xaml ?
I want to change the bar color. But I only find the method which use code behind(custom palette).
My practice is not like the example provided on the official website.(http://docs.telerik.com/devtools/xamarin/controls/chart/how-to/chart-how-to-create-custom-palette)
Can you help me if I want to change the bar color which use xaml?
I hope it can be implemented like this:

<telerikChart:ChartPalette>
    <telerikChart:PaletteEntry FillColor="Green"/>
    <telerikChart:PaletteEntry FillColor="Blue"/>
</telerikChart:ChartPalette>
Lance | Senior Manager Technical Support
Telerik team
 answered on 28 Feb 2020
5 answers
111 views

"  at playing.Views.Dashboard.ConstructUtilisationBarGraph () [0x0014f] in /Users/marshallhp/Projects/playing/playing/Views/Dashboard.xaml.cs:50 \n  at playing.Views.Dashboard..ctor () [0x0002f] in /Users/marshallhp/Projects/playing/playing/Views/Dashboard.xaml.cs:25 \n  at playing.Views.MainPage.NavigateFromMenu (System.Int32 id) [0x000a0] in /Users/marshallhp/Projects/playing/playing/Views/MainPage.xaml.cs:42 \n  at playing.Views.MenuPage.<.ctor>b__3_1 (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) [0x0004b] in /Users/marshallhp/Projects/playing/playing/Views/MenuPage.xaml.cs:47 \n  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 \n  at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.21/src/Xamarin.iOS/Foundation/NSAction.cs:178 \n--- End of stack trace from previous location where exception was thrown ---\n\n  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)\n  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.21/src/Xamarin.iOS/UIKit/UIApplication.cs:86 \n  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.21/src/Xamarin.iOS/UIKit/UIApplication.cs:65 \n  at playing.iOS.Application.Main (System.String[] args) [0x00001] in /Users/marshallhp/Projects/playing/playing.iOS/Main.cs:17 "

 

Hi team, followed the example here (https://docs.telerik.com/devtools/xamarin/controls/chart/series/cartesian/line-series) and get this error in iOS simulator.

 

Any help would be greatly appreciated. 

Heath
Top achievements
Rank 1
 answered on 27 Feb 2020
5 answers
270 views
Hi!

I'm using RadCartesianChartView in my Xamarin.Android project. When there are no data to display I see "No Data" message. How can i customize it? I need to change text and textcolor for this message.
Didi
Telerik team
 answered on 04 Feb 2020
1 answer
82 views

When our data is loaded and have a null value it causes crash to our app and catches an "Object reference not set to an instance of an object". 
But this issue is only happening on iOS platform. Can someone help me this is a crucial issue for me and my team. 

public class NumericalData
{
    public object XData { get; set; }
 
    public double? YData { get; set; }
}


{System.NullReferenceException: Object reference not set to an instance of an object
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.AddPoints (TelerikUI.TKChartSeries series, System.Collections.IList newItems) [0x00196] in <22603cf6132d4ae9966514a9a3d3a88a>:0 
  at Telerik.XamarinForms.ChartRenderer.iOS.BaseChartRenderer`1[T].Telerik.XamarinForms.Chart.IChartRenderer.OnSeriesSourceCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Object series) [0x0004e] in <22603cf6132d4ae9966514a9a3d3a88a>:0 
  at Telerik.XamarinForms.Chart.ChartSeries.OnItemsSourceCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00017] in <22603cf6132d4ae9966514a9a3d3a88a>:0 
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 
  at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:196 
  at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:71 
  at NutritionalFitness.Mobile.ViewModels.ProgramPhaseViewModel.SetGraphsData (System.Collections.Generic.IEnumerable`1[T] weightIns, System.Collections.Generic.IEnumerable`1[T] waterIntakes) [0x00152] in D:\Work\NutritionalFitness\NutritionalFitness.Dev\NutritionalFitnessMobile\NutritionalFitness.Mobile\ViewModels\ProgramPhaseViewModel.cs:184 
  at NutritionalFitness.Mobile.ViewModels.ProgramPhaseViewModel.SetProgramPhaseComponents () [0x002d4] in D:\Work\NutritionalFitness\NutritionalFitness.Dev\NutritionalFitnessMobile\NutritionalFitness.Mobile\ViewModels\ProgramPhaseViewModel.cs:90 }


Yana
Telerik team
 answered on 27 Jan 2020
8 answers
156 views

Starting from 2018.3.912.1 (was not able to reproduce in 2018.2.821.1 or earlier), loading charts on iOS crashes the device. This happens in the sample project SDKBrowser provided as well, when opening any of the Series charts (specifically the Vertical Bar which is what we have been using).

Stack trace of the crash:

 

System.InvalidCastException: Specified cast is not valid.
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetDataPoint (TelerikUI.TKChart chart, System.nuint dataIndex, System.nuint seriesIndex) [0x0002a] in <94eed00967c543f5a13e0605d41bd543>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.ManagedChartDataSource.GetPoint (TelerikUI.TKChart chart, System.nuint dataIndex, System.nuint seriesIndex) [0x0002c] in <94eed00967c543f5a13e0605d41bd543>:0
  at (wrapper managed-to-native) ApiDefinition.Messaging.void_objc_msgSendSuper_IntPtr(intptr,intptr,intptr)
  at TelerikUI.TKChart.set_XAxis (TelerikUI.TKChartAxis value) [0x00047] in <44e9726d5f6f4545a2e89f7d32ff2c9f>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.CartesianChartAdapter.UpdateXAxis (Telerik.XamarinForms.Chart.RadCartesianChart sourceOwner, TelerikUI.TKChart targetOwner) [0x0002e] in <94eed00967c543f5a13e0605d41bd543>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.CartesianChartAdapter.UpdateCore (Telerik.XamarinForms.Chart.RadCartesianChart sourceOwner, Telerik.XamarinForms.ChartRenderer.iOS.TKExtendedChart targetOwner, System.String propertyName, Telerik.XamarinForms.Common.IParentElement sourceOwnerRoot, System.Object targetOwnerRoot) [0x0003f] in <94eed00967c543f5a13e0605d41bd543>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.BaseChartAdapter`1[S].Update (System.Object sourceOwner, System.Object targetOwner, System.String propertyName, System.Object sourceOwnerRoot, System.Object targetOwnerRoot) [0x00000] in <94eed00967c543f5a13e0605d41bd543>:0
  at Telerik.XamarinForms.Common.XamarinToNativeControlExtensions.Update[T,K] (T nativeElement, K xfЕlement, System.String propertyName, System.Object sourceOwnerRoot, System.Object targetOwnerRoot) [0x00031] in <e2f1740c30914d7ea94cb9f8115f6f61>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.BaseChartRenderer`1[T].OnElementAttached (T newElement) [0x00068] in <94eed00967c543f5a13e0605d41bd543>:0
  at Telerik.XamarinForms.ChartRenderer.iOS.CartesianChartRenderer.OnElementAttached (Telerik.XamarinForms.Chart.RadCartesianChart newElement) [0x00000] in <94eed00967c543f5a13e0605d41bd543>:0
  at Telerik.XamarinForms.Common.iOS.IosRendererBase`2[S,T].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x0003f] in <e2f1740c30914d7ea94cb9f8115f6f61>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x0012a] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003d] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000de] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003d] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000de] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003d] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x0000f] in <0da03a4594684a9bbf17d4a99d39fbc2>:0
  at Xamarin.Forms.Element.OnChildAdded (Xamarin.Forms.Element child) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:332
  at Xamarin.Forms.VisualElement.OnChildAdded (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:742
  at Xamarin.Forms.Layout.OnInternalAdded (Xamarin.Forms.View view) [0x0001d] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:453
  at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00078] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:443
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338
  at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:196
  at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:71
  at Xamarin.Forms.ContentPresenter.OnContentChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0004e] in D:\a\1\s\Xamarin.Forms.Core\ContentPresenter.cs:88
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
  at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.16.1.24/src/Xamarin.iOS/Foundation/NSAction.cs:178
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.16.1.24/src/Xamarin.iOS/UIKit/UIApplication.cs:86
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.16.1.24/src/Xamarin.iOS/UIKit/UIApplication.cs:65
  at SDKBrowser.iOS.Application.Main (System.String[] args) [0x00001] in /Users/username/Downloads/613233149246cf225930444fa4e25dc3_Telerik_UI_for_Xamarin_2019_3_913_1_Trial/Examples/Forms/SDKBrowser/SDKBrowser.iOS/Main.cs:14

 

This is happening on iOS Simulator 12.4, and on device on iOS 13.0. The current workaround is to stay on the old version of 2018.2.*, but this is not really a good workaround.

Yana
Telerik team
 answered on 21 Jan 2020
1 answer
174 views

I have a graph with a time scale of hours, and in the tooltip I am interested to see also the hours.

They asked something similar in 2016 and it was answered that it was not possible, any news?

https://www.telerik.com/forums/formatting-of-the-tooltip-text 

 

thanks in advance :-)

Yana
Telerik team
 answered on 19 Nov 2019
1 answer
75 views

Hi there,

I have a question regarding pie chart redrawing. I am not sure if it works, but is it possible to dynamically update the values of an existing pie chart?

I was able to display the chart when page started(image1 in attach files). I am trying to trigger an event through Xamarin Picker and update the number of the same chart.I was able to change the variable(an ObservableCollection), but the chart never changed.

Is there anything I missed?

Yana
Telerik team
 answered on 24 Oct 2019
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?