This is a migrated thread and some comments may be shown as answers.

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

3 Answers 49 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chenkai
Top achievements
Rank 1
Chenkai asked on 22 Jul 2015, 10:04 AM

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?

3 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 22 Jul 2015, 11:45 AM
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
0
Chenkai
Top achievements
Rank 1
answered on 23 Jul 2015, 12:49 AM
Thank you for reply, I will try.
0
Chenkai
Top achievements
Rank 1
answered on 23 Jul 2015, 12:56 AM

Hi, jack 

It really work ! thank​s again!

Tags
Chart
Asked by
Chenkai
Top achievements
Rank 1
Answers by
Jack
Telerik team
Chenkai
Top achievements
Rank 1
Share this question
or