What is a legend

The use of color, size, and shape in a diagram to distinguish between auxiliary elements of different data types is a legend.

The role of legend

Legends are used to filter data.

Classification of legends

  • Continuous legend
  • Classification of legend

Explain legends based on examples

Basic data

In Indian society, the caste system divides people into five classes, from the highest to the lowest: Brahmins, Kshatriyas, Vaishas, Shudras and untouchables. Use MockJS to simulate a piece of data, and each piece of data consists of three fields: Level, age, and gender.

Mock.mock('/caste-system'.function() {
  return Mock.mock({
    'list|50': [{level: '@level'.age: '@age'.gender: '@gender'
      }
    ]
  }).list;
});
Copy the code

The data analysis

Level: indicates the level field. Discrete, ordered Age: indicates the age field. Continuous, ordered Gender: gender field. Discrete, ordered

Mapping of data fields to graph properties

  • level => position x
  • age => position y
  • age => color
  • level => shape
  • gender => size

Concept to interpret

When the user expects to see information between the ages of [50, 100], the graph can block out information between [0, 50]. This is where legends come in handy. The age field maps to color, and since age is a continuous field, the legend is a continuous legend, and the effect is a slider with an adjustable age range. Since level is a discrete ordered field, a legend is a classification legend. Click the Level legend to show or hide the Level field.