PowerPlotPercolation logo

US bank failures alert

This chart demonstrates the “alerting” feature of PowerPlot to inform the user visually of certain conditions. In this case the condition is if the number of bankrupts is too high. Alerting is available on iOS4.0 and later.

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

US bank failures alert

Alerting means highlighting individual information that meets a certain criteria. This is a common request in Business Intelligence applications. This example demonstrates how to use this feature in the case of the US bank failures chart.

Setting up the feature is done by defining the alertBlock property of the corresponding WSPlotController and possibly also configuring the colors to be used. In this example we set the default bar color to black (the alerted color is red by default) and set up the alerting criteria to highlight all bars in years that have more than 10 bankrupts in one year:

    // Configure alerting function.
    WSPlotBar *barPlot = ((WSPlotBar *)[barChart firstPlotOfClass:[WSPlotBar class]]);
    WSPlotController *barCtrl = barPlot.plotController;
    barPlot.style = kCustomStyleIndividual;
    ((WSBarProperties *)barPlot.plotController.standardProperties).barColor = [UIColor blackColor];
    ((WSBarProperties *)barPlot.plotController.standardProperties).outlineColor = [UIColor blackColor];
    [barCtrl setAlertBlock:(alertBlock_t)^(WSDatum *datum){ 
        return (datum.valueY > 10);
    [barCtrl updateAlertedData];

At the end, the method updateAlertedData is called which manually triggers a check of the conditions and updates the plot (if necessary).

Instead of the manual check and update, it is also possible to activate data bindings as discussed in the bindings example to automatically perform the highlighting checks and updates.