Make Your Data Speak: Crafting Clear Legends in Angular Charts

syncfusionsyncfusion
7 min read

TL;DR: Poorly designed chart legends sow confusion in data visualization. This post details how thoughtful legend crafting, especially with Syncfusion Angular Charts, transforms complex data into accessible, comprehensible narratives, ensuring viewers grasp insights immediately. By applying targeted techniques like legend paging for dense datasets, custom legend templates, and interactive toggling, developers can deliver dashboards that are not only visually clean but also functionally insightful, ensuring users interpret data accurately and efficiently.

Welcome to our Weekly Data Visualization blog series!

Hey developers, ever felt your powerful data visualization charts aren’t quite hitting the mark, leaving users scratching their heads? Often, the solution isn’t more data, but a better key: the chart legend. Welcome to our latest post in the Weekly Data Visualization blog series, where we elevate this often-overlooked component. A thoughtfully crafted legend is central to transforming complex charts into accessible, insightful narratives, improving comprehension and engagement.

In this post, we’ll explore how to design intuitive chart legends using the Syncfusion® Angular Chart component, ensuring your data speaks clearly and effectively.

Let’s dive in!

What is a Chart legend?

At its core, a chart legend is the key to understanding a visualization. It links graphical elements such as lines, colors, or symbols to their real-world meanings. Effective legends bridge the gap between raw data and visual representation, acting as a narrative guide that empowers viewers to decode patterns, compare trends, and extract meaning quickly.

The Syncfusion® Angular Charts component includes a legend feature that enhances the user experience by clearly identifying data series, thereby improving chart readability and interaction. In use cases such as dashboards, comparisons, or real-time data monitoring, legends enable users to interpret complex data with minimal effort.

For more information, refer to the documentation.

Rendering a wheat production chart using Syncfusion® Angular Chart

The following steps will guide you through creating a dynamic chart using the Syncfusion® Angular Chart component to visualize annual wheat production across various countries from 2014 to 2024.

Step 1: Collecting wheat production data

Gather reliable data on wheat production across different countries over the years. The dataset should include annual production values measured in million metric tons to ensure accurate representation.

In this example, we analyze wheat production trends from 2014 to 2024, highlighting variations and key patterns among various countries.

The data was sourced from the USDA, which provides up-to-date agricultural statistics for multiple regions.

Step 2: Setting up the Angular application

To display the wheat production trends, configure the Syncfusion® Angular Chart component. You can find more information about the Angular Chart in the documentation.

Install the required Syncfusion® package in your Angular application using the following command.

npm install @syncfusion/ej2-angular-charts

Then, import the necessary modules in app.module.ts:

import { AppComponent } from './app.component';
import { ChartModule } from '@syncfusion/ej2-angular-charts';
import { LineSeriesService, LegendService, CategoryService, TooltipService } from '@syncfusion/ej2-angular-charts';
@NgModule({
    imports: [ChartModule],
    bootstrap: [AppComponent],
    providers: [LineSeriesService, LegendService, CategoryService, TooltipService]
})

Step 3: Rendering the chart with data

Integrate the wheat production data into the Syncfusion® Angular Chart component. In this example, we’ll use a Line chart to visualize production trends over time.

The chart will display data points representing each country’s wheat production from 2014 to 2024. The collected data is structured into a dataset and assigned to the dataSource property of the Angular Chart component.

For more details, refer to the Syncfusion® Line Chart documentation.

Chart implementation:

<! -- app.component.html -->
<ejs-chart [primaryXAxis]="primaryXAxis" [legendSettings]="legendSettings" [tooltip]="tooltip"> 
    <e-series-collection>
        <e-series *ngFor="let country of series" [dataSource]="wheatProductionData" type="Line" xName="year" [yName]="country.yName" [name]="country.name">
        </e-series>
    </e-series-collection>
</ejs-chart>

<! -- app.component.ts -->
export class AppComponent {
    public primaryXAxis: Object = { valueType: 'Category' };
    public legendSettings: Object = { visible: true };
    public tooltip: Object = { enable: true };
    public series = [
        { yName: 'USA', name: 'United States' },
        { yName: 'Canada', name: 'Canada' },
        { yName: 'India', name: 'India' },
       { yName: 'China', name: 'China' }
    ];
}

Step 4: Enhancing readability with legends

To improve the chart’s readability, enable the legend and assign clear, descriptive names to each data series. This allows users to easily distinguish between countries based on their respective wheat production trends.

Legend configuration:

public legendSettings: Object = { visible: true, position: 'Bottom' };

This ensures that the legend appears below the chart, clearly displaying the names of each data series as shown in the following image.

Line chart of wheat production using Angular Charts

To view the live demo of the code discussed above, check out the Legend Sample.

The role of legends in data visualization

A legend isn’t merely a chart accessory; it’s a core component of narrative design. When thoughtfully crafted, legends allow viewers to focus on the story; the trends, outliers, and actionable insights, rather than spending effort deciphering labels and series.

  • Improved readability: Makes it easier for viewers to understand the chart without additional effort.

  • Efficient comparison: Helps users quickly identify and differentiate between data groups.

  • Aesthetic appeal: Enhances the overall visual appearance of the visualization.

Why choose Syncfusion® Angular Charts for legends?

Syncfusion® Angular Charts offer greater power and flexibility for customizing chart legends compared to most other libraries. You can easily modify the appearance of each legend item by adjusting its shape and text. Additionally, you can precisely control the legend’s position and manage its behaviour with features such as paging and advanced accessibility options. These unique capabilities make Syncfusion® particularly user-friendly and versatile.

With Syncfusion®, you can tailor your chart legends to look and function exactly as needed, helping users quickly understand your data. Furthermore, Syncfusion’s high performance ensures that your charts remain fast and responsive, even when handling large datasets.

For more details, refer to the documentation.

Best practices for crafting effective legends

Aim for clarity rather than cleverness. Consider your audience’s familiarity with both the subject matter and the chart type when selecting terminology.

1. Keep it simple and concise

A legend should be straightforward. Avoid lengthy descriptions and keep labels short yet meaningful. Whenever possible, use common terminology that your audience is familiar with.

2. Place legends strategically

Position the legend in a location that is easily visible but does not clutter the visualization. Common placements include:

  • Right of the chart (best for vertical bars and line charts)

  • Below the chart (ideal for horizontal bars)

  • Embedded within the chart (direct labeling works best for scatter plots and small multiples)

3. Use clear visual distinctions

Ensure that the colors, shapes, or line styles used in the legend match those in the chart. Avoid using colors that are too similar or difficult to distinguish, especially for colorblind users.

4. Direct labeling when possible

Instead of relying solely on a legend, consider adding direct labels to chart elements. This reduces cognitive load by allowing viewers to understand the data without referring back and forth to a separate legend.

5. Maintain consistency

If you’re using multiple charts in a report or dashboard, maintain a consistent legend format. This minimizes confusion and allows for seamless comparisons.

Common mistakes to avoid

  • Overloading the legend: Including too many categories in the legend can overwhelm readers. If necessary, group similar items to simplify the legend. Consider offering user-driven filtering or interactive legend toggles to let viewers control what information is displayed.

  • Using misleading labels: Labels should accurately describe the data without ambiguity. Remember, accessibility goes beyond color; ensure that font sizes are readable on all devices and that legends are perceivable by assistive technologies such as screen readers.

  • Ignoring accessibility: Use colorblind-friendly palettes and ensure that all text is legible.

Conclusion

Thanks for reading! Chart legends are far from a mere accessory; they are fundamental to compelling data visualization. By applying best practices, such as keeping them simple and concise, placing them strategically, using clear visual distinctions, and ensuring accessibility, you empower viewers to focus on the story your data tells. Leveraging the powerful customization features of Syncfusion® Angular Charts, you can ensure your charts are not just visually appealing but also immediately clear and insightful, helping users quickly understand your data.

Start crafting truly intuitive charts today! Explore the new features of Essential Studio® from the license and downloads page or take advantage of our 30-day free trial to transform your data narratives. For any questions or assistance, feel free to reach out to us through our support forums, support portal, or feedback portal. Happy coding!

This article was originally published at Syncfusion.com.

0
Subscribe to my newsletter

Read articles from syncfusion directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

syncfusion
syncfusion

Syncfusion provides third-party UI components for React, Vue, Angular, JavaScript, Blazor, .NET MAUI, ASP.NET MVC, Core, WinForms, WPF, UWP and Xamarin.