Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I get crowded QLegend items to wrap?
Forum Updated to NodeBB v4.3 + New Features

How do I get crowded QLegend items to wrap?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qchartqlegendwrap
5 Posts 3 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mmikeinsantarosa
    wrote on 15 Mar 2019, 22:48 last edited by
    #1

    I'm building a chart that can end up with many lines/series and this causes the legend area to be too packed and the text condensed and unreadable as they all show up on one line. Is there any way to get the items in the legend to wrap to multiple lines?

    J 1 Reply Last reply 16 Mar 2019, 14:50
    0
    • M mmikeinsantarosa
      15 Mar 2019, 22:48

      I'm building a chart that can end up with many lines/series and this causes the legend area to be too packed and the text condensed and unreadable as they all show up on one line. Is there any way to get the items in the legend to wrap to multiple lines?

      J Offline
      J Offline
      JonB
      wrote on 16 Mar 2019, 14:50 last edited by JonB
      #2

      @mmikeinsantarosa
      Until you get an answer from someone who knows what he's talking about...:
      If it can be done at all,

      • see https://doc.qt.io/qt-5/qlegendmarker.html#setLabel. You could try setting that, or the series name, to contain a \n, cross fingers, and if that works, it might (kind of) "wrap"?

      • https://doc.qt.io/qt-5/qlegend.html#showToolTips-prop says "This property holds whether tooltips are shown when the text is truncated.", so there must be a way to "truncate the text"?

      • https://www.qtcentre.org/threads/67441-qchart-hide-legend-for-part-of-series shows you can hide a legend completely, you could manage by showing only certain legend(s) at a time when many series or something?

      • https://doc.qt.io/qt-5/qtcharts-legend-example.html lets you display the legend elsewhere yourself, if that's of any interest. It shows setting a rectangle for the legend, I don't quite understand whether that's only when it's detached or whether you can re-attach with your own size

      Several things to look at for you :)

      M 1 Reply Last reply 16 Mar 2019, 15:22
      1
      • J JonB
        16 Mar 2019, 14:50

        @mmikeinsantarosa
        Until you get an answer from someone who knows what he's talking about...:
        If it can be done at all,

        • see https://doc.qt.io/qt-5/qlegendmarker.html#setLabel. You could try setting that, or the series name, to contain a \n, cross fingers, and if that works, it might (kind of) "wrap"?

        • https://doc.qt.io/qt-5/qlegend.html#showToolTips-prop says "This property holds whether tooltips are shown when the text is truncated.", so there must be a way to "truncate the text"?

        • https://www.qtcentre.org/threads/67441-qchart-hide-legend-for-part-of-series shows you can hide a legend completely, you could manage by showing only certain legend(s) at a time when many series or something?

        • https://doc.qt.io/qt-5/qtcharts-legend-example.html lets you display the legend elsewhere yourself, if that's of any interest. It shows setting a rectangle for the legend, I don't quite understand whether that's only when it's detached or whether you can re-attach with your own size

        Several things to look at for you :)

        M Offline
        M Offline
        mmikeinsantarosa
        wrote on 16 Mar 2019, 15:22 last edited by
        #3

        @JonB
        Thanks JonB

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mmikeinsantarosa
          wrote on 17 Mar 2019, 00:25 last edited by mmikeinsantarosa
          #4

          Well, detaching the legend does allow for for the items to wrap but then it's next to impossible to determine where the legend should show up by default without landing on top of important trend lines.

          There's got to be a way to manipulate an attached legend.

          I did see a way to create a custom legend in QML https://doc.qt.io/qt-5/qtcharts-qmlcustomlegend-example.html but I'm not using QML. Everything I have is built in creator & C++.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sachinrd
            wrote on 4 Jul 2020, 07:29 last edited by
            #5

            hi @mmikeinsantarosa .could you resolve this issue?how did u make all the legends visible ?thank you.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved