Displaying tooltip for crosshair programatically


#1

I am a newbie trying to use shinobi and the amount of documentation is overwhelming

Can someone please point me to any sample code for the below simple requirement 

1)I have a bar graph and would like to display a tool tip when the user long presses on the individual bar graph. Right now using crosshair what I have is when the user long presses on any bar graph then the data on my UILabel gets updated . I would now like to add the tool tip to that 


#2

Hi Sim777,

I recently answered a very similar question to this so I have pasted my response to that question below below.

To get the basic crosshair to show when long pressed you need to set two BOOLs.

The first is the “hidden” property on your chart’s “crosshair” object, this needs to be set to NO.

Then in your SChartDatasource method “sChart:seriesAtIndex:” you need to set the “enableCrosshair” property on your series to YES.

Let me know if you have any questions.

Kind regards,
Andrew Polkinghorn


#3

Thank you for your response. However I think my problem is slightly different . My apologies that I could not explain it better earlier.
The crosshair functionality works fine for me. When I click on a data point I do see the crosshairMovedToXValue function getting invoked and I can get the new x and y values .
I  am trying to add a tool tip to this . that is when I click on a data point , I need the simple tooltip to be displayed for this data point that shows the x and y value.

In my code in the below function- crosshairMovedToXValue() this is what I do to display the tooltip but that isn’t working . 

******************************

SChartCrosshairTooltip *ttp = [[SChartCrosshairTooltip alloc] initWithFrame:CGRectMake(15, 10, 300, 20)];
chart.crosshair.tooltip = ttp;

*****************************

Is this the right way to display a simple tooltip when we invoke the individual data points using crosshair ?


#4

Hi sim777,

I would like to help with your query but I’m not sure I fully understand your usecase. Just to make sure we’re both on the same page when it comes to what a crosshair/tooltip is we can use this bit of the docs as a reference - http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiCharts/2.7.0/Premium/Normal/user_guide.html#Crosshair

Notice that the tooltip is the but that displays the data values and the crosshair are the lines that draw from the axes to the point.

It would be great if you could provide a screenshot of what you are trying to achieve. It looks like you might be trying to produce a stationary tooltip somewhere in your view hierarchy (one that doesn’t follow the user’s touch) - is my understanding correct?

Regards

Ryan 


#5

Hi,

Thank you for your response . Based on what you mentioned, yes I am looking for a basic tooltip that would display the x axis and y axis values for a data point when I long press the datapoint.

The screen shot would the same as the one shown in -

http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiCharts/2.7.0/Premium/Normal/user_guide.html#Crosshair

The tooltip requirement would be a simple rectangular box with the x, y values displayed. 

Can you please tell me the sample code to get this working 


#6

To be a bit more specific . I read the documentation at this place - 

The article mentions that the default tooltip provided by shinobi shows datapoint values as a string in a few UI labels. My question is how do I get this default tooltip itself to show. Does it come up as a  rectangular box on top of the selected crosshair or do i need to enable some specific code. Right now when I long press on a datapoint the crosshair with the small circle comes up successfully, however I do not see any tooltip coming up .


#7

Hi sim777,

You shouldn’t need to do anything to get the tooltip to show other than set series.crosshairEnabled = YES.

I also noticed above that you are creating and setting a tooltip - you don’t need to do this as the crosshair already has one by default.

If your tooltip isn’t showing can I ask if you are trying to customise the tooltip or crosshair anywhere in your code? If so it would be helpful to see how you are customising these with some sample code.

Thanks

Ryan


#8

A good example of how a basic crosshair and tooltip looks is to modify our GettingStarted sample, included in a shinobicharts download, and mofify it be adding the following line where we return a series:

        lineSeries.crosshairEnabled = YES;

You can then build and run the app and long press on the data to see a crosshair and tooltip appear.