How could I edit the color of axis text of qml ChartView?
-
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 } } }
-
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.
-
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.