- Qt 6.11
- Qt Graphs
- QML Types
- QtGraphs
- LineSeries
- Qt Graphs | Commercial or GPLv3

# LineSeries QML Type

Presents data in line graphs. More...

Import Statement: | `import QtGraphs`
In C++: | QLineSeries
Inherits: | XYSeries

- List of all members, including inherited members
- LineSeries is part of Qt Graphs QML Types for 2D.

## Properties

- capStyle : Qt::PenCapStyle
- joinStyle : Qt::PenJoinStyle `(since 6.11)`
- lineStyle : QLineSeries::LineStyle `(since 6.11)`
- pointDelegate : Component
- width : real

## Signals

- capStyleChanged()
- joinStyleChanged() `(since 6.11)`
- lineStyleChanged() `(since 6.11)`
- widthChanged()

## Methods

- dataPointCoordinatesAt(real x, real y)

## Detailed Description

A line graph is used to show information as a series of data points connected by straight lines or steps.

Series can contain gaps using NaN values as in :

     import QtGraphs

     GraphsView {
         axisX: ValueAxis {
             max: 5
         }
         axisY: ValueAxis {
             max: 5
         }

         LineSeries {
             color: "#00ff00"
             joinStyle: Qt.RoundJoin

             XYPoint {
                 x: 0.5
                 y: 0.5
             }

             XYPoint {
                 x: 1.1
                 y: NaN
             }

             XYPoint {
                 x: 1.9
                 y: 3.3
             }

             XYPoint {
                 x: 2.1
                 y: 2.1
             }

             XYPoint {
                 x: 5
                 y: 4.9
             }
         }
     }

or

     QLineSeries *series = new QLineSeries();
     series->append(0, 2);
     series->append(2, 4);
     series->append(3, std::numeric_limits<qreal>::quiet_NaN());
     series->append(4, 1);
     series->append(5, 0);
     series->setLineStyle(QLineSeries::LineStyle::StepCenter);
     series->setColor(Qt::red);

which result in :

Note: As seen on the above example's first graph, alone points (like the first point of the series) won't be rendered as lines, unless there is a visible pointDelegate

LineSeries uses mostly the same API as ScatterSeries so see ScatterSeries documentation for further usage examples.

See also ScatterSeries.

## Property Documentation

### capStyle : Qt::PenCapStyle

Controls the cap style of the line. Set to one of Qt.FlatCap, Qt.SquareCap or Qt.RoundCap. By default the cap style is Qt.SquareCap. Invalid values are automatically set to the default value.

See also Qt::PenCapStyle.

### joinStyle : Qt::PenJoinStyle `[since 6.11]`

Controls the join style of the line. Set to one of Qt.BevelJoin, Qt.MiterJoin or Qt.RoundJoin. By default the join style is Qt.BevelJoin. Invalid values are automatically set to the default value.

This property was introduced in Qt 6.11.

See also Qt::PenJoinStyle.

### lineStyle : QLineSeries::LineStyle `[since 6.11]`

Controls the line style of the line. Set to one of LineSeries.Straight, LineSeries.StepLeft, LineSeries.StepRight or LineSeries.StepCenter. By default the line style is LineSeries.Straight. Invalid values are automatically set to the default value.

This property was introduced in Qt 6.11.

See also QLineSeries::LineStyle.

### pointDelegate : Component

Marks the point with the given QML component.

     pointDelegate: Image {
         source: "images/happy_box.png"
     }

### width : real

The width of the line. By default, the width is 2.0. Widths lower than 0 are invalid and are automatically set to 0.

## Signal Documentation

### capStyleChanged()

This signal is emitted when the line series cap style changes.

Note: The corresponding handler is `onCapStyleChanged`.

### `[since 6.11]` joinStyleChanged()

This signal is emitted when the line series cap style changes.

Note: The corresponding handler is `onJoinStyleChanged`.

This signal was introduced in Qt 6.11.

### `[since 6.11]` lineStyleChanged()

This signal is emitted when the line series line style changes.

Note: The corresponding handler is `onLineStyleChanged`.

This signal was introduced in Qt 6.11.

### widthChanged()

This signal is emitted when the line series width changes.

Note: The corresponding handler is `onWidthChanged`.

## Method Documentation

### dataPointCoordinatesAt(real x, real y)

Returns x and y rendercoordinates converted into data point coordinates.