TKChartDelegate - paletteItemForPoint

3 posts, 0 answers
  1. Matt
    Matt avatar
    8 posts
    Member since:
    Aug 2015

    Posted 14 Sep 2015 Link to this post

    I'm trying to create a spark line chart, and for the chart, I want only the last data point to be a red circle.  To do this, I need to use the paletteItemForPoint delegate method.  I am able to get the chart drawn with the correct range background, however, the paletteItemForPoint is not called, but paletteItemForSeries is called.  Is there a reason why paletteItemForPoint would not be called.

     

    - (id)initWithFrame:(CGRect) frame
    {
        self = [super initWithFrame:frame];
        
        if(self) {
            self.sparkLineChart = [[TKChart alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
            [self.sparkLineChart setBackgroundColor:[UIColor clearColor]];
            [self.sparkLineChart setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
            
            self.sparkLineChart.legend.hidden = YES;
            self.sparkLineChart.delegate = self;
            self.sparkLineChart.dataSource = self;
            self.sparkLineChart.title.hidden = YES;
            self.sparkLineChart.backgroundColor = [UIColor clearColor];
            self.sparkLineChart.plotViewInsets = UIEdgeInsetsMake(0, 0, 0, 0);
            self.sparkLineChart.insets = UIEdgeInsetsMake(0, 0, 0, 0);
            self.sparkLineChart.gridStyle.horizontalLinesHidden = YES;
            self.sparkLineChart.gridStyle.horizontalAlternateFill = nil;
            self.sparkLineChart.gridStyle.horizontalFill = nil;
            self.sparkLineChart.gridStyle.verticalLinesHidden = YES;
            self.sparkLineChart.gridStyle.verticalAlternateFill = nil;
            self.sparkLineChart.gridStyle.verticalFill = nil;
            [self addSubview:self.sparkLineChart];
        }
        
        return self;
    }​

  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 15 Sep 2015 Link to this post

    Hi Matt,

    Thank you for contacting us.

    You should first set the pointShape in order to use the chart:paletteItemForPoint:inSeries: method. Consider the sample below:
    - (TKChartSeries *)seriesForChart:(TKChart *)chart atIndex:(NSUInteger)index
    {
        TKChartLineSeries *series = [TKChartLineSeries new];
        series.style.pointShape = [TKPredefinedShape shapeWithType:TKShapeTypeCircle andSize:CGSizeMake(10, 10)];
        return series;
    }

    I hope this helps.

    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. Matt
    Matt avatar
    8 posts
    Member since:
    Aug 2015

    Posted 15 Sep 2015 in reply to Jack Link to this post

    That was the step I was missing, Thanks!
Back to Top