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. How could I edit the color of axis text of qml ChartView?
Forum Updated to NodeBB v4.3 + New Features

How could I edit the color of axis text of qml ChartView?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 1.9k 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.
  • T Offline
    T Offline
    tham
    wrote on 4 Mar 2018, 07:06 last edited by
    #1

    I would like to change the color of text of the ChartView, but cannot find a way to do it, could anyone show me how to do it properly?Thanks

    Codes:

                  ChartView {
                        title: qsTr("Driving speed")
                        height: 300
                        width: 300
                        titleColor: "white"
                        antialiasing: true
                        legend.labelColor: "white"
                        //backgroundColor: "#363030"
                        theme: ChartView.ChartThemeBlueCerulean
    
                        LineSeries {
                            name: qsTr("Average speed")
                            XYPoint { x: 0; y: 10 }
                            XYPoint { x: 1; y: 15 }
                            XYPoint { x: 2; y: 20 }
                            XYPoint { x: 3; y: 13 }
                            XYPoint { x: 4; y: 19 }
                            XYPoint { x: 5; y: 18 }
                        }
                    }
    
    1 Reply Last reply
    0
    • 6 Offline
      6 Offline
      6thC
      wrote on 7 Mar 2018, 02:28 last edited by
      #2

      I would say out of the box themes would (seem to) be it. It looks like inside of QAbstractAxis - too far for me to try.

      I'd probably hide axis and make my own and overlay if I wanted it that much. Or try setting a them then changing everything else and seeing if it was enough.

      If I were to redo things entirely I might just go the direct widgets / c++ for my charts.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kongkong
        wrote on 8 Sept 2022, 07:09 last edited by
        #3

        Although this is an old question, I also met this question and I want to try to reply it.
        I use BarSeries instead of LineSeries, and I think they are the same in this question. Here is the code:

        BarSeries {
                    id: mySeries
                    property var value1: [2, 2, 3, 4, 5, 6]
                    property var value2: [5, 1, 2, 4, 1, 7]
                    property var value3: [3, 5, 8, 13, 5, 8]
                    property int valueMax
                    axisX: BarCategoryAxis { categories: ["1", "2", "3", "4", "5", "6" ] ; labelsColor: "white"; gridVisible: false; color:"#7e7e7e";}
                    axisY: ValueAxis { labelsColor: "white"; max: mySeries.valueMax; min:0; color: "#00000000";gridLineColor: "#666"}
                    BarSet { label: "Bob"; values: mySeries.value1 ; color:"#177ddc"; labelColor: "#dcdcdc"; borderColor: "#177ddc"; }
                    BarSet { label: "Susan"; values: mySeries.value2 ; color:"yellow";labelColor: "#dcdcdc"}
                    BarSet { label: "James"; values: mySeries.value3 ; color:"blue";labelColor: "#dcdcdc"}
                }
        

        Setting the color of labelsColor in both axisX and axisY with BarCategoryAxis and ValueAxis can edit the color of axis text. You can try it.

        1 Reply Last reply
        1

        • Login

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