Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Multiline labels or word wrap for BarCategoryAxis labels

Multiline labels or word wrap for BarCategoryAxis labels

Scheduled Pinned Locked Moved Solved QML and Qt Quick
chartswordwrapqmllabels
3 Posts 2 Posters 678 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.
  • V Offline
    V Offline
    voltron
    wrote on last edited by
    #1

    I need to display a bar chart with QML. Everything works fine, but my categories labels are elided and not readable as in the image below
    81ebc376-5468-41a3-8042-eea3e2c4fb6d-зображення.png

    Is there a way to force showing full, not elided text for them? Or maybe enable word wrapping, or making labels multi-line. I have tried to put '\n' character inside label text but this does not work.

    My code below

    import QtQuick 2.0
    import QtCharts 2.0
    
    ChartView {
        width: 380
        height:200
        margins {top: 0; bottom: 0; left: 0; right: 0}
        backgroundColor: "#eeeeec"
        legend.alignment: Qt.AlignRight
        antialiasing: true
        ValueAxis{
            id: valueAxisY
            min: 0
            max: 100
        }
    
        BarSeries {
            id: mySeries
            axisY: valueAxisY
            axisX: BarCategoryAxis {categories: ["Productivity", "Land cover", "Soil organic carbon"] }
            BarSet { label: "Degraded"; values: [15, 30, 22] }
            BarSet { label: "Improved"; values: [4, 21, 50] }
            BarSet { label: "Stable"; values: [31, 5, 67] }
        }
    }
    
    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by Markkyboy
      #2

      Making the width and height of ChartView the same size as the project window (640x480) allows the text to display in full. Assuming you're not restricted on the size of your ChartView of course.

      Capture.PNG

      1 Reply Last reply
      0
      • MarkkyboyM Offline
        MarkkyboyM Offline
        Markkyboy
        wrote on last edited by
        #3
        This post is deleted!
        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