Minor ticks for each grid in graph

18 views
Skip to first unread message

Kedar Desai

unread,
Mar 2, 2020, 7:12:19 AM3/2/20
to coreplot-discuss
Hi All,

I am trying to draw a graph similar to images attached here. My question is, Is there any way to show minor ticks with different length in different directions for each grid in the graph? if yes which class can help me to achieve this?

Thanks & Regards,
Kedar Desai
Electronic-Logbook-Driver.png
13248.jpg

Eric

unread,
Mar 2, 2020, 5:54:09 PM3/2/20
to coreplot-discuss
You can lay more than one axis on top of each other and give each one different labeling parameters (to control the tick spacing) and tick lengths. Hide the axis line (set the line style to nil) for all but one of the axes for better drawing performance and to avoid potential drawing artifacts.

Eric

Kedar Desai

unread,
Mar 4, 2020, 4:16:08 AM3/4/20
to coreplot-discuss
Hi Eric,

Thanks for your reply. I have tried and succeeded in creating this graph. I want to achieve another functionality in the same graph, when user taps anywhere in the graph. It should highlight entire plotarea for that data point range, just like higlighted area in first image.

I am using CPTPlotSpaceDelegate's shouldHandlePointingDeviceUpEvent method for detecting touch and retrieving touch point in hostview. But how can I get datapoint range in graph for touched point in hostview? And how can I highlight entire plot area for that particular data points? Can you help me with this?

Kedar Desai

unread,
Mar 4, 2020, 7:43:07 AM3/4/20
to coreplot-discuss
Hi,

I worked around the code. And found the closest visible point in plot area. Following is my code:

func plotSpace(_ space: CPTPlotSpace, shouldHandlePointingDeviceDownEvent event: UIEvent, at point: CGPoint) -> Bool {
lastPlotSpaceDownPoint = point
return true
}
    
func plotSpace(_ space: CPTPlotSpace, shouldHandlePointingDeviceUp event: UIEvent, at point: CGPoint) -> Bool {
let distance: CGFloat = CGFloat(hypotf((Float(lastPlotSpaceDownPoint.x - point.x)), (Float(lastPlotSpaceDownPoint.y - point.y))))
if abs(distance) < 5 {
let recordIndex = linePlotDS.indexOfVisiblePointClosest(toPlotAreaPoint: point)
print(recordIndex)
}
return true

}


When user taps near 3rd data point it gives me record index as 3. But how can I find whether it is tapped between 2&3 or 3&4?


On Monday, March 2, 2020 at 5:42:19 PM UTC+5:30, Kedar Desai wrote:

Eric

unread,
Mar 4, 2020, 6:55:52 PM3/4/20
to coreplot-discuss
Check the distance between the touch point and both points 2 and 4 to see which one is closer.

Eric

Kedar Desai

unread,
Mar 6, 2020, 1:41:57 AM3/6/20
to coreplot-discuss
I am unable to calculate the distance. How to calculate distance between plots? And how can I fill color only between those points in entire area fill?

Kedar Desai

unread,
Mar 6, 2020, 7:54:29 AM3/6/20
to coreplot-discuss
Hi.

Thanks for your help. I have worked around the code and got the desired output finally.

On Monday, March 2, 2020 at 5:42:19 PM UTC+5:30, Kedar Desai wrote:
Reply all
Reply to author
Forward
0 new messages