
## Usage

Compose the legend as a child of the chart root. Pass `variant` to control the
indicator style, and `isClickable` to let each entry toggle selection of its
series.

```svelte
<EChartsLineChart {data} config={chartConfig} xDataKey="month">
	<EChartsLineChart.Legend variant="circle" isClickable />
	<EChartsLineChart.Line dataKey="desktop" />
	<EChartsLineChart.Line dataKey="mobile" />
</EChartsLineChart>
```

## Variants

Control the legend indicator style with the `variant` prop on
`<EChartsLineChart.Legend />`.

### Square

### variant='square'

```svelte
<script lang="ts">
	import { EChartsLineChart } from '$lib/components/evilcharts/charts/echarts-line-chart/index.js';
	import { type ChartConfig } from '$lib/components/evilcharts/ui/echarts-chart/index.js';

	const data = [
		{ month: 'January', desktop: 342, mobile: 184 },
		{ month: 'February', desktop: 876, mobile: 491 },
		{ month: 'March', desktop: 512, mobile: 290 },
		{ month: 'April', desktop: 629, mobile: 391 },
		{ month: 'May', desktop: 458, mobile: 309 },
		{ month: 'June', desktop: 781, mobile: 449 },
		{ month: 'July', desktop: 394, mobile: 234 },
		{ month: 'August', desktop: 925, mobile: 557 },
		{ month: 'September', desktop: 647, mobile: 367 },
		{ month: 'October', desktop: 532, mobile: 357 },
		{ month: 'November', desktop: 803, mobile: 515 },
		{ month: 'December', desktop: 271, mobile: 149 }
	];

	const chartConfig = {
		desktop: {
			label: 'Desktop',
			colors: {
				light: ['#047857'],
				dark: ['#10b981']
			}
		},
		mobile: {
			label: 'Mobile',
			colors: {
				light: ['#be123c'],
				dark: ['#f43f5e']
			}
		}
	} satisfies ChartConfig;
</script>

<EChartsLineChart {data} config={chartConfig} class="h-full w-full p-4" xDataKey="month">
	<EChartsLineChart.Grid />
	<EChartsLineChart.XAxis
		dataKey="month"
		tickFormatter={(value) => String(value).substring(0, 3)}
	/>
	<!-- [!code highlight] -->
	<EChartsLineChart.Legend variant="square" />
	<EChartsLineChart.Tooltip />
	<EChartsLineChart.Line dataKey="desktop" />
	<EChartsLineChart.Line dataKey="mobile" />
</EChartsLineChart>
```

### Circle

### variant='circle'

```svelte
<script lang="ts">
	import { EChartsLineChart } from '$lib/components/evilcharts/charts/echarts-line-chart/index.js';
	import { type ChartConfig } from '$lib/components/evilcharts/ui/echarts-chart/index.js';

	const data = [
		{ month: 'January', desktop: 342, mobile: 184 },
		{ month: 'February', desktop: 876, mobile: 491 },
		{ month: 'March', desktop: 512, mobile: 290 },
		{ month: 'April', desktop: 629, mobile: 391 },
		{ month: 'May', desktop: 458, mobile: 309 },
		{ month: 'June', desktop: 781, mobile: 449 },
		{ month: 'July', desktop: 394, mobile: 234 },
		{ month: 'August', desktop: 925, mobile: 557 },
		{ month: 'September', desktop: 647, mobile: 367 },
		{ month: 'October', desktop: 532, mobile: 357 },
		{ month: 'November', desktop: 803, mobile: 515 },
		{ month: 'December', desktop: 271, mobile: 149 }
	];

	const chartConfig = {
		desktop: {
			label: 'Desktop',
			colors: {
				light: ['#047857'],
				dark: ['#10b981']
			}
		},
		mobile: {
			label: 'Mobile',
			colors: {
				light: ['#be123c'],
				dark: ['#f43f5e']
			}
		}
	} satisfies ChartConfig;
</script>

<EChartsLineChart {data} config={chartConfig} class="h-full w-full p-4" xDataKey="month">
	<EChartsLineChart.Grid />
	<EChartsLineChart.XAxis
		dataKey="month"
		tickFormatter={(value) => String(value).substring(0, 3)}
	/>
	<!-- [!code highlight] -->
	<EChartsLineChart.Legend variant="circle" />
	<EChartsLineChart.Tooltip />
	<EChartsLineChart.Line dataKey="desktop" />
	<EChartsLineChart.Line dataKey="mobile" />
</EChartsLineChart>
```

### Circle Outline

### variant='circle-outline'

```svelte
<script lang="ts">
	import { EChartsLineChart } from '$lib/components/evilcharts/charts/echarts-line-chart/index.js';
	import { type ChartConfig } from '$lib/components/evilcharts/ui/echarts-chart/index.js';

	const data = [
		{ month: 'January', desktop: 342, mobile: 184 },
		{ month: 'February', desktop: 876, mobile: 491 },
		{ month: 'March', desktop: 512, mobile: 290 },
		{ month: 'April', desktop: 629, mobile: 391 },
		{ month: 'May', desktop: 458, mobile: 309 },
		{ month: 'June', desktop: 781, mobile: 449 },
		{ month: 'July', desktop: 394, mobile: 234 },
		{ month: 'August', desktop: 925, mobile: 557 },
		{ month: 'September', desktop: 647, mobile: 367 },
		{ month: 'October', desktop: 532, mobile: 357 },
		{ month: 'November', desktop: 803, mobile: 515 },
		{ month: 'December', desktop: 271, mobile: 149 }
	];

	const chartConfig = {
		desktop: {
			label: 'Desktop',
			colors: {
				light: ['#047857'],
				dark: ['#10b981']
			}
		},
		mobile: {
			label: 'Mobile',
			colors: {
				light: ['#be123c'],
				dark: ['#f43f5e']
			}
		}
	} satisfies ChartConfig;
</script>

<EChartsLineChart {data} config={chartConfig} class="h-full w-full p-4" xDataKey="month">
	<EChartsLineChart.Grid />
	<EChartsLineChart.XAxis
		dataKey="month"
		tickFormatter={(value) => String(value).substring(0, 3)}
	/>
	<!-- [!code highlight] -->
	<EChartsLineChart.Legend variant="circle-outline" />
	<EChartsLineChart.Tooltip />
	<EChartsLineChart.Line dataKey="desktop" />
	<EChartsLineChart.Line dataKey="mobile" />
</EChartsLineChart>
```

### Rounded Square (Default)

### variant='rounded-square'

```svelte
<script lang="ts">
	import { EChartsLineChart } from '$lib/components/evilcharts/charts/echarts-line-chart/index.js';
	import { type ChartConfig } from '$lib/components/evilcharts/ui/echarts-chart/index.js';

	const data = [
		{ month: 'January', desktop: 342, mobile: 184 },
		{ month: 'February', desktop: 876, mobile: 491 },
		{ month: 'March', desktop: 512, mobile: 290 },
		{ month: 'April', desktop: 629, mobile: 391 },
		{ month: 'May', desktop: 458, mobile: 309 },
		{ month: 'June', desktop: 781, mobile: 449 },
		{ month: 'July', desktop: 394, mobile: 234 },
		{ month: 'August', desktop: 925, mobile: 557 },
		{ month: 'September', desktop: 647, mobile: 367 },
		{ month: 'October', desktop: 532, mobile: 357 },
		{ month: 'November', desktop: 803, mobile: 515 },
		{ month: 'December', desktop: 271, mobile: 149 }
	];

	const chartConfig = {
		desktop: {
			label: 'Desktop',
			colors: {
				light: ['#047857'],
				dark: ['#10b981']
			}
		},
		mobile: {
			label: 'Mobile',
			colors: {
				light: ['#be123c'],
				dark: ['#f43f5e']
			}
		}
	} satisfies ChartConfig;
</script>

<EChartsLineChart {data} config={chartConfig} class="h-full w-full p-4" xDataKey="month">
	<EChartsLineChart.Grid />
	<EChartsLineChart.XAxis
		dataKey="month"
		tickFormatter={(value) => String(value).substring(0, 3)}
	/>
	<!-- [!code highlight] -->
	<EChartsLineChart.Legend variant="rounded-square" />
	<EChartsLineChart.Tooltip />
	<EChartsLineChart.Line dataKey="desktop" />
	<EChartsLineChart.Line dataKey="mobile" />
</EChartsLineChart>
```

### Rounded Square Outline

### variant='rounded-square-outline'

```svelte
<script lang="ts">
	import { EChartsLineChart } from '$lib/components/evilcharts/charts/echarts-line-chart/index.js';
	import { type ChartConfig } from '$lib/components/evilcharts/ui/echarts-chart/index.js';

	const data = [
		{ month: 'January', desktop: 342, mobile: 184 },
		{ month: 'February', desktop: 876, mobile: 491 },
		{ month: 'March', desktop: 512, mobile: 290 },
		{ month: 'April', desktop: 629, mobile: 391 },
		{ month: 'May', desktop: 458, mobile: 309 },
		{ month: 'June', desktop: 781, mobile: 449 },
		{ month: 'July', desktop: 394, mobile: 234 },
		{ month: 'August', desktop: 925, mobile: 557 },
		{ month: 'September', desktop: 647, mobile: 367 },
		{ month: 'October', desktop: 532, mobile: 357 },
		{ month: 'November', desktop: 803, mobile: 515 },
		{ month: 'December', desktop: 271, mobile: 149 }
	];

	const chartConfig = {
		desktop: {
			label: 'Desktop',
			colors: {
				light: ['#047857'],
				dark: ['#10b981']
			}
		},
		mobile: {
			label: 'Mobile',
			colors: {
				light: ['#be123c'],
				dark: ['#f43f5e']
			}
		}
	} satisfies ChartConfig;
</script>

<EChartsLineChart {data} config={chartConfig} class="h-full w-full p-4" xDataKey="month">
	<EChartsLineChart.Grid />
	<EChartsLineChart.XAxis
		dataKey="month"
		tickFormatter={(value) => String(value).substring(0, 3)}
	/>
	<!-- [!code highlight] -->
	<EChartsLineChart.Legend variant="rounded-square-outline" />
	<EChartsLineChart.Tooltip />
	<EChartsLineChart.Line dataKey="desktop" />
	<EChartsLineChart.Line dataKey="mobile" />
</EChartsLineChart>
```

### Vertical Bar

### variant='vertical-bar'

```svelte
<script lang="ts">
	import { EChartsLineChart } from '$lib/components/evilcharts/charts/echarts-line-chart/index.js';
	import { type ChartConfig } from '$lib/components/evilcharts/ui/echarts-chart/index.js';

	const data = [
		{ month: 'January', desktop: 342, mobile: 184 },
		{ month: 'February', desktop: 876, mobile: 491 },
		{ month: 'March', desktop: 512, mobile: 290 },
		{ month: 'April', desktop: 629, mobile: 391 },
		{ month: 'May', desktop: 458, mobile: 309 },
		{ month: 'June', desktop: 781, mobile: 449 },
		{ month: 'July', desktop: 394, mobile: 234 },
		{ month: 'August', desktop: 925, mobile: 557 },
		{ month: 'September', desktop: 647, mobile: 367 },
		{ month: 'October', desktop: 532, mobile: 357 },
		{ month: 'November', desktop: 803, mobile: 515 },
		{ month: 'December', desktop: 271, mobile: 149 }
	];

	const chartConfig = {
		desktop: {
			label: 'Desktop',
			colors: {
				light: ['#047857'],
				dark: ['#10b981']
			}
		},
		mobile: {
			label: 'Mobile',
			colors: {
				light: ['#be123c'],
				dark: ['#f43f5e']
			}
		}
	} satisfies ChartConfig;
</script>

<EChartsLineChart {data} config={chartConfig} class="h-full w-full p-4" xDataKey="month">
	<EChartsLineChart.Grid />
	<EChartsLineChart.XAxis
		dataKey="month"
		tickFormatter={(value) => String(value).substring(0, 3)}
	/>
	<!-- [!code highlight] -->
	<EChartsLineChart.Legend variant="vertical-bar" />
	<EChartsLineChart.Tooltip />
	<EChartsLineChart.Line dataKey="desktop" />
	<EChartsLineChart.Line dataKey="mobile" />
</EChartsLineChart>
```

### Horizontal Bar

### variant='horizontal-bar'

```svelte
<script lang="ts">
	import { EChartsLineChart } from '$lib/components/evilcharts/charts/echarts-line-chart/index.js';
	import { type ChartConfig } from '$lib/components/evilcharts/ui/echarts-chart/index.js';

	const data = [
		{ month: 'January', desktop: 342, mobile: 184 },
		{ month: 'February', desktop: 876, mobile: 491 },
		{ month: 'March', desktop: 512, mobile: 290 },
		{ month: 'April', desktop: 629, mobile: 391 },
		{ month: 'May', desktop: 458, mobile: 309 },
		{ month: 'June', desktop: 781, mobile: 449 },
		{ month: 'July', desktop: 394, mobile: 234 },
		{ month: 'August', desktop: 925, mobile: 557 },
		{ month: 'September', desktop: 647, mobile: 367 },
		{ month: 'October', desktop: 532, mobile: 357 },
		{ month: 'November', desktop: 803, mobile: 515 },
		{ month: 'December', desktop: 271, mobile: 149 }
	];

	const chartConfig = {
		desktop: {
			label: 'Desktop',
			colors: {
				light: ['#047857'],
				dark: ['#10b981']
			}
		},
		mobile: {
			label: 'Mobile',
			colors: {
				light: ['#be123c'],
				dark: ['#f43f5e']
			}
		}
	} satisfies ChartConfig;
</script>

<EChartsLineChart {data} config={chartConfig} class="h-full w-full p-4" xDataKey="month">
	<EChartsLineChart.Grid />
	<EChartsLineChart.XAxis
		dataKey="month"
		tickFormatter={(value) => String(value).substring(0, 3)}
	/>
	<!-- [!code highlight] -->
	<EChartsLineChart.Legend variant="horizontal-bar" />
	<EChartsLineChart.Tooltip />
	<EChartsLineChart.Line dataKey="desktop" />
	<EChartsLineChart.Line dataKey="mobile" />
</EChartsLineChart>
```

## API Reference

Props for the `<EChartsLineChart.Legend />` part.


  ### `variant`

type: `"square" | "circle" | "circle-outline" | "rounded-square" | "rounded-square-outline" | "vertical-bar" | "horizontal-bar"` · default: `"rounded-square"`

Style of the legend indicator icon.
  ### `align`

type: `"left" | "center" | "right"` · default: `"right"`

Horizontal placement of the legend items.
  ### `verticalAlign`

type: `"top" | "middle" | "bottom"` · default: `"top"`

Vertical placement of the legend items.
  ### `isClickable`

type: `boolean` · default: `false`

When enabled, clicking an entry toggles selection of its series.

