Small historical note for people: Cavalry did not have any more success charging straight at line than they would have charging straight at a square. The difference is a line can be flanked and attacked in the rear, whereas a square could not.
Furthermore, there are very few instances of horses charging straight into a fixed line of bayonets, be they formed in square or line. If you are charging straight at a loaded musket with bayonet fixed, your most likely doing something wrong.
Cavalry has two strengths. The first is speed, in essence, being able to get from one part of the battlefield to another in a fraction of the time it takes an infantryman.
The second is maneuverability. A infantryman needs to either engage at range with musketry or charge straight at an opposing force and hope not to get shot down, anything else gets him killed. Cavalry can choose their moment to attack, as well as their approach - use this.