Point Color

4 posts, 0 answers
  1. Ruben
    Ruben avatar
    2 posts
    Member since:
    Aug 2007

    Posted 04 Sep Link to this post

    Is there a way to have a different colors for different point on a single line for TKChartLineSeries?
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    503 posts

    Posted 06 Sep Link to this post

    Hi Ruben,

    We have a demo in the iOS Samples application that shows how to create custom point labels. I believe with the proper modifications it will fit your requirement. Please have a look at it, you can find it in your local Telerik UI for Xamarin installation. Simply navigate to the Examples/iOS folder and have a look at the Chart/PointLabels/CustomPointLabel implementation once you have opened the solution.

    Regards,
    Stefan Nenchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Ruben
    Ruben avatar
    2 posts
    Member since:
    Aug 2007

    Posted 06 Sep Link to this post

    Thanks for the reply. However, my question is about points themselves, not point labels. I already figured out how to have different colors for points on a single series but now can't find a way to do the same for point shapes? Can I have points of different shapes on a single series?

  4. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    503 posts

    Posted 08 Sep Link to this post

    Hello Ruben,

    You can change the color of the points as well by overriding the PaletteItemForPoint(shown in the demo - CustomPointLabels.cs):

    public override TKChartPaletteItem PaletteItemForPoint (TKChart chart, nuint index, TKChartSeries series)
                {
                    if (series.Index == (nuint)this.selectedSeriesIndex && index == (nuint)this.selectedDataPointIndex) {
                        return new TKChartPaletteItem (new TKStroke (UIColor.Black, 2.0f), new TKSolidFill (UIColor.White));
                    }
     
                    if (series.Index == 0) {
                        return new TKChartPaletteItem (new TKSolidFill (new UIColor ((float)(108 / 255.0), (float)(181 / 255.0), (float)(250 / 255.0), (float)1.0)));
                    }
     
                    return new TKChartPaletteItem (new TKSolidFill(UIColor.Green));
                }
    You can return different palette item according to your custom logic.

    Unfortunately, it would not be possible to assign different shapes for the points of the same series.

    Have a great weekend.

    Regards,
    Stefan Nenchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top