...there cannot be a perfect cure without a complete restoration of health. Now the sound health of the soul consists in the exercise of the seven virtues, namely, the three theological and the four cardinal. Hence, in order to restore their healthy exercise, it was fitting that seven sacraments be instituted. For the healing work of Baptism leads to faith, Confirmation to hope, the Eucharist to charity, Penance to justice, Extreme Unction to perserverance -- the complement and summit of fortitude, Orders to prudence, and Matrimony to the preservation of temperance, which is threatened mainly by the weakness of the flesh but is saved through honest marriage.
[St. Bonaventure, Breviloquium, Monti, ed. and tr., Franciscan Institute Publications (St. Bonaventure, NY: 2005) p. 219.]
This can be compared to St. Thomas's version (ST 3.65.1), which links it with the first remedial scheme, which we've already seen in St. Bonaventure:
Some, again, gather the number of sacraments from a certain adaptation to the virtues and to the defects and penal effects resulting from sin. They say that Baptism corresponds to Faith, and is ordained as a remedy against original sin; Extreme Unction, to Hope, being ordained against venial sin; the Eucharist, to Charity, being ordained against the penal effect which is malice; Order, to Prudence, being ordained against ignorance; Penance to Justice, being ordained against mortal sin; Matrimony, to Temperance, being ordained against concupiscence; Confirmation, to Fortitude, being ordained against infirmity.
Note that Aquinas and Bonaventure are in agreement about the virtue scheme except for Confirmation and Extreme Unction, which are switched. All of the sacraments, of course, affect all of the virtues; in assigning virtues to sacraments neither is saying that the virtue is linked only with that sacrament, but that there is some appropriate analogy or link between the virtue and the sacrament. It's easy to establish that Baptism has a special link to faith and Eucharist a special link to charity, so it would make sense that the others would be associated with virtues as well.
Aquinas's assigning of fortitude to Confirmation (the strengthening sacrament) and of hope to Extreme Unction (looking forward to the resurrection of the body) seems to me to be the more plausible version. If I'm not mistaken, though, Aquinas's version of the virtue scheme is just directly taken from Alexander of Hales; if so, Bonaventure is taking Alexander's scheme and deliberately changing it, so he must have reasons for doing so. My suspicion is that one or both of two things are going on -- first, that he sees a natural progression from Baptism to Confirmation to Eucharist, that makes hope a plausible middle term, and, second, that hope, as one of the theological virtues, is a very important virtue, and so he may be trying to associate it with a sacrament in more general use than Extreme Unction. Other possibilities are that the link between Penance and Unction is an influence, or that he sees the Gifts of the Holy Spirit, given by Confirmation, to have a direct relation to how hope works in the Christian life.