SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

0
0

There’s a build error when implementing IPointMarkerPaletteProvider, IFillPaletteProvider, or IStrokePaletteProvider.

MainActivity_P.java:50: error: isAttached() in MainActivity_P cannot override isAttached() in PaletteProviderBase
    public boolean isAttached ()
                   ^
    overridden method is final



 MainActivity_P.java:58: error: attachTo(IServiceContainer) in MainActivity_P cannot override attachTo(IServiceContainer) in       PaletteProviderBase
    public void attachTo (com.scichart.core.IServiceContainer p0)
                ^
    overridden method is final



MainActivity_P.java:66: error: detach() in MainActivity_P cannot override detach() in PaletteProviderBase
    public void detach ()
                ^
    overridden method is fina

What’s wrong with it? See the attached project to reproduce the issue.

Version
2.1.0.615
Attachments
  • You must to post comments
0
0

Hi there,

It looks like that it’s caused by some kind of limitation in Xamarin.Android which doesn’t allow to implement IPointMarkerPaletteProvider interface in class which extends PaletteProviderBase because it contains final methods. I’m going to log it into our bugtracker for further investigation and for now you can workaround it by implementing IPointMarkerPaletteProvider interface from scratch in class which inherits from Java Object class:

    class P : Java.Lang.Object, IPointMarkerPaletteProvider
    {
        private readonly IRenderableSeries _renderableSeries;
        private readonly IntegerValues _pointMarkerColors = new IntegerValues();

        public P(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {
        }

        public P(IRenderableSeries renderableSeries)
        {
            _renderableSeries = renderableSeries;
        }

       public void Update()
       {
              // update colors
              var count = _renderableSeries.CurrentRenderPassData.PointsCount();

              _pointMarkerColors.Clear();
              for (int i = 0; i < count; i++)
              {
                    _pointMarkerColors.Add((int)(0xFFFFFF00 | (i % 255)));
               }
        }

        public IntegerValues PointMarkerColors
        {
            get { return _pointMarkerColors; }
        }

        public void AttachTo(IServiceContainer services)
        {
            IsAttached = true;
        }

        public void Detach()
        {
            IsAttached = false;
        }

        public bool IsAttached { get; private set; }
    }

Is this suitable for your needs? Hope that this will help you!


EDIT:
I’ve added simple Update() method implementation which worked for me. NOTE we can’t use ItemsArray property because Xamarin bindings generator wraps it in a such way that when you get it a new C# array is created and when you try change its elements original Java array remains intact (initialized with 0 values). Maybe that’s why you got an empty chart when use palete provider and in this case you just need to use Add/Set methods which modify original Java array.

Best regards,
Yura

  • rubs00
    Any updates on this issue? I couldn’t make this work.
  • rubs00
    Implementing this way draws no point at all. The update method is invoked but no point is visible. When I remove my palette provider, points appear.
  • rubs00
    Anyone?
  • Yura Khariton
    Can you post code of your palette provider? Also how do you update your colors?
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.