Gradient strokes: across or along

A stroke's gradient can run across its width, along its length, or over the whole box.

Try this

  1. Press play. The rainbow is one path with one stroke.
  2. Click the rainbow, then its Stroke swatch under Shape.
  3. On the Gradient tab, change Placement from Across the stroke to Across the box.
  4. The rings below compare Across the box, Across the stroke and Along the stroke.