PowerPlotPercolation logo

Interactive business model graph

This is a graph with unified appearance, i.e., all boxes look the same. The nodes have dark shadows.

This page describes the class “BusinessModelGraphInteractive” in the PowerPlot demo app.

Interactive business model graph

To add a gesture recognizer that allows selection of charts, simply add the following code to the existing business model demo:

    // Manually add a gesture recognizer.
    UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
                                                                                    action:@selector(userDidTap:)];
    [gChart addGestureRecognizer:tapRecognizer];

Identifiation of the node is then done in the callback userDidTap: of that view controller:

- (void)userDidTap:(UITapGestureRecognizer *)sender
{
    WSPlotGraph *graph = (WSPlotGraph *)[[(WSChart *)sender.view plotAtIndex:0] view];
    CGPoint tap = [sender locationInView:sender.view];
    NSInteger nodeNum = [graph nodeForPoint:tap];
    if (nodeNum > -1) {
        // User tapped on a node.
        WSDatum *node = [[DemoData demoGraphNodes] datumAtIndex:nodeNum];
        self.selection.text = [NSString stringWithFormat:@"Tap on: %@.",
                               node.annotation];
    } else {
        // User tapped elsewhere.
        self.selection.text = @"Tap outside of nodes.";
    }
}