Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74173

Vertical axis of bar chart does not clip category labels

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.11.2
    • Charts
    • None
    • Linux/X11

    Description

      When I create a horizontal bar chart with long category labels, the labels along the Y axis are not clipped and stretch beyond the chart area, as shown on the right side of the following image.

      The following fix resolved the issue:

      --- a/qt-everywhere-src-5.11.2/qtcharts/src/charts/axis/verticalaxis.cpp
      +++ b/qt-everywhere-src-5.11.2/qtcharts/src/charts/axis/verticalaxis.cpp
      @@ -105,7 +105,7 @@ void VerticalAxis::updateGeometry()
           //title
           QRectF titleBoundingRect;
           QString titleText = axis()->titleText();
      -    qreal availableSpace = axisRect.height() - labelPadding();
      +    qreal availableSpace = axisRect.width() - labelPadding();
           if (!titleText.isEmpty() && titleItem()->isVisible()) {
               availableSpace -= titlePadding() * 2.0;
               qreal minimumLabelWidth = ChartPresenter::textBoundingRect(axis()->labelsFont(),
      

      The test program is attached.

      I'm using qt-5.11.2, but I believe this bug may affect at least qt-5.12.1 because its verticalaxis.cpp also uses axisRect.height() to compute availableSpace.

      Attachments

        1. main.cpp
          2 kB
        2. qt-verticalaxis-bug.png
          qt-verticalaxis-bug.png
          18 kB
        3. qt-verticalaxis-bug-fixed.png
          qt-verticalaxis-bug-fixed.png
          17 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            e0348803 Miikka Heikkinen
            olegsyrel Oleg Syrel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes