Qt 5.7 | Qt Charts | QML Types | Legend QML Type

Qt 5.7.1 Reference Documentation

# Legend QML Type

Legend is part of Qt Chart QML API. More...

Import Statement: | import QtCharts 2.1
Instantiates: | QLegend

- List of all members, including inherited members

## Properties

- alignment : Qt.Alignment
- backgroundVisible : bool
- borderColor : color
- color : color
- font : Font
- labelColor : color
- reverseMarkers : bool
- showToolTips : bool
- visible : bool

## Detailed Description

Legend is a graphical object, which displays legend of the chart. Legend state is updated by ChartView, when series have been changed. Legend is used via ChartView class. For example:

      ChartView {
          legend.visible: true
          legend.alignment: Qt.AlignBottom
          // Add a few series...
      }

Please note that there is no QML API available for modifying legend markers, unlike in the Qt API of Charts. The use case of modifying markers can be implemented for example by creating your own custom legend. For an example on how to do this, see Qml Custom Example application.

## Property Documentation

alignment : Qt.Alignment

The alignment of the legend.

Legend paints on the defined position in the chart. The following alignments are supported: Qt.AlignTop, Qt.AlignBottom, Qt.AlignLeft, Qt.AlignRight. If you set more than one flag the result is undefined.

backgroundVisible : bool

Whether the legend background is visible or not.

borderColor : color

The border color of the legend, i.e. the line color.

color : color

The color of the legend, i.e. the background (brush) color.

font : Font

The font of markers used by legend.

labelColor : color

The color of brush used to draw labels.

reverseMarkers : bool

Whether reverse order is used for the markers in legend or not. False by default.

showToolTips : bool

Whether tooltips are shown when the text is truncated. This is false by default. This currently has no effect as there is no support for tooltips in QML.

visible : bool

Whether the legend is visible or not.

By default, this property is `true`.

See also QGraphicsObject::visible.