How can I change the color of a certain point in the chart?

4 posts, 1 answers
  1. Chenkai
    Chenkai avatar
    3 posts
    Member since:
    Jul 2015

    Posted 22 Jul 2015 Link to this post

    When a point exceed a certain value, how can I change it's color ?

    The follow is my partial code :

    TKChartLineSeries *temperatureSeries = [[TKChartSplineSeries alloc] initWithItems:points];
    temperatureSeries.style.pointShape = [[TKPredefinedShape alloc] initWithType:TKShapeTypeCircle andSize:CGSizeMake(7, 7)];
    temperatureSeries.xAxis = timeXAxis;
    temperatureSeries.yAxis = temperatureYAxis;
    temperatureSeries.selectionMode = TKChartSeriesSelectionModeDataPoint;
    temperatureSeries.style.shapeMode = TKChartSeriesStyleShapeModeAlwaysShow; 

    I didn't use the datasource delegate, can I realize it?

    By the way, if I use the delegate, how can I make it?

  2. Answer
    Jack
    Admin
    Jack avatar
    2333 posts

    Posted 22 Jul 2015 Link to this post

    Hi Chenkai,

    Yes, in this scenario you should use the chart delegate. The chart:paletteItemForPoint:inSeries: method will do the job. Consider the following sample:
    - (TKChartPaletteItem *)chart:(TKChart *)chart paletteItemForPoint:(NSUInteger)index inSeries:(TKChartSeries *)series
    {
        id<TKChartData> point = (id<TKChartData>)series.items[index];
        if ([[point dataYValue] floatValue] > 50) {
            TKChartPaletteItem *item = [[TKChartPaletteItem alloc] initWithFill:[TKSolidFill solidFillWithColor:[UIColor redColor]]];
            return item;
        }
        return nil;
    }

    I hope this helps. Should you have further questions, do not hesitate to ask.

    Regards,
    Jack
    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. DevCraft banner
  4. Chenkai
    Chenkai avatar
    3 posts
    Member since:
    Jul 2015

    Posted 22 Jul 2015 in reply to Jack Link to this post

    Thank you for reply, I will try.
  5. Chenkai
    Chenkai avatar
    3 posts
    Member since:
    Jul 2015

    Posted 22 Jul 2015 in reply to Jack Link to this post

    Hi, jack 

    It really work ! thank​s again!

Back to Top
DevCraft banner