Chart get point by value

6 posts, 0 answers
  1. Flash
    Flash avatar
    3 posts
    Member since:
    Jan 2016

    Posted 22 Mar Link to this post

    Please help,

    i need to know point on chart for specific value, and other way i want to tap on chart and get exact values for this point.

  2. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 25 Mar Link to this post

    Hi,

    Thank you for writing.

    You can get the location of data point in the chart by using locationOfPoint:inSeries method of TKChartSeriesRender. Consider the code below:
    TKChartSeriesRender *render = [[TKChartSeriesRender alloc] init];
    CGPoint point = [render locationOfPoint:dataPoint inSeries:series];

    I am not sure if I understand correctly the second part of the question. Could you please explain if you need the tap point coordinates on the chart's plot area or you need the data point that is on that location?
    I am looking forward to your reply.

    Regards,
    Adrian
    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. Stephen
    Stephen avatar
    2 posts
    Member since:
    Nov 2015

    Posted 05 Apr Link to this post

    I've not been able to get this to work.  The point returned is always at location 0:0.  Could you post the swift version of this code?  Perhaps I'm translating incorrectly.

     

    Thank you,

    -Stephen

  5. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 08 Apr Link to this post

    Hi, Stephen,

    You are correct. It returns point at location 0:0 because the render's bounds are zero rectangle. To fix this you should set its bounds property:
    let render = TKChartSeriesRender(chart: chart)
    render.bounds = chart.plotView.bounds
    let point = render.locationOfPoint(dataPoints[0], inSeries: series)

    Regards,
    Adrian
    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
  6. Stephen
    Stephen avatar
    2 posts
    Member since:
    Nov 2015

    Posted 08 Apr Link to this post

    Thanks Adrian.  This works much better!  

    However one of the instances where I'll use this functionality is to draw a custom marker on a specific point when the chart first appears.  I've found this solution will still return 0,0 unless I add a delay.  Perhaps because the renderer hasn't completed its work yet.... Is there a way to tell when the chart is finished drawing?

    Thanks,

    -Steve

  7. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 13 Apr Link to this post

    Hello, Stephen,

    TKChart does not notify when it is rendered on the screen, however you can use UIViewController's viewDidAppear method where the chart will be on screen. You can also take a look at annotations in TKChart in our documentation. Maybe using annotations would be easier to achieve your scenario.
    I hope this helps.

    Regards,
    Adrian
    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
DevCraft banner