{% extends 'VegaLiteAgent/improvement_step.jinja2' %}

{% block instructions %}
Add helpful tooltips for better user experience.

# SCOPE: Tooltips

Focus on:
- encoding.tooltip (array of fields with titles and formatting)
- mark.tooltip (only if needed for tooltip interactivity)

CRITICAL: The spec uses layers. When updating a layer, you MUST include both `mark` and `encoding`.
Even if only adding tooltips, copy the existing mark. Each layer requires both properties.
{% endblock %}

{% block examples %}
# EXAMPLES

Bar chart with tooltips (in layered spec):
```yaml
layer:
  - mark: bar  # MUST include mark even when only adding tooltips
    encoding:
      x: {field: state, type: ordinal}
      y: {field: avg_pcap, type: quantitative}
      tooltip:  # Add tooltips to existing encoding
      - field: state
        title: State
        type: ordinal
      - field: avg_pcap
        format: .2f
        title: Avg Power Capacity
        type: quantitative
```

Line chart with tooltips (in layered spec):
```yaml
layer:
  - mark:  # MUST include mark even when only adding tooltips
      type: line
      point: true
      tooltip: true
    encoding:
      x: {field: year, type: quantitative}
      y: {field: value, type: quantitative}
      tooltip:  # Add tooltips to existing encoding
      - field: year
        title: Year
        type: quantitative
      - field: value
        format: .2f
        title: Value
        type: quantitative
```
{% endblock %}
