-
Couldn't load subscription status.
- Fork 379
Touch Reporting (Interactive Graph)
BEMSimpleLineGraph can react to the user touching the graph by two different ways:
- Popup Reporting
- Touch Reporting
On the above example, both Popup Reporting and Touch Reporting are activated.
When the user touches and drags his finger along the graph, a popup label will appear on top of the closest dot from the user's finger. The label will display the value of the point.
To enable Popup Reporting, simply set the BOOL property enablePopUpReport to YES.
self.myGraph.enablePopUpReport = YES;If the property alwaysDisplayPopUpLabels is set to YES, all of the popup up labels will always be visible (defaults to NO).
When the user touches and drags his finger along the graph, it's possible to retrive the value of the closest point.
To do so, first toggle the enableTouchReport property:
self.myGraph.enableTouchReport = YES;Next, implement the two following methods: lineGraph:didTouchGraphWithClosestIndex & lineGraph:didReleaseTouchFromGraphWithClosestIndex:.
- The
lineGraph:didTouchGraphWithClosestIndexmethod gets called when the user touches the graph. The parameterindexis the closest index (X-Axis) from the user's finger position.
- (void)lineGraph:(BEMSimpleLineGraphView *)graph didTouchGraphWithClosestIndex:(NSInteger)index {
// Here you could change the text of a UILabel with the value of the closest index for example.
}- The
lineGraph:didReleaseTouchFromGraphWithClosestIndex:method gets called when the user stops touching the graph. The parameterindexis the closest index (X-Axis) from the user's last finger position.
- (void)lineGraph:(BEMSimpleLineGraphView *)graph didReleaseTouchFromGraphWithClosestIndex:(CGFloat)index {
// Set the UIlabel alpha to 0 for example.
}

