A
A
Anton Artyomov2017-10-23 15:58:36
QML
Anton Artyomov, 2017-10-23 15:58:36

How to change font options in BarChart QML value labels?

Good time. I've been trying for weeks to change the font settings for value labels in BarChart chart bars
59ede5e2bbedd702826832.png
Using QtCharts 2.2
Creating a chart from JS

function drawBar(){
        barChartView.removeAllSeries();
        barChartView.titleFont = Qt.font({bold:true,pixelSize:20});

        var barAbstractSeries = barChartView.createSeries(ChartView.SeriesTypeBar); // AbstractSeries object
        barAbstractSeries.clear();
        barAbstractSeries.append(qsTr("Resource Consumption"),getData());
        barAbstractSeries.labelsVisible = true;
        barAbstractSeries.labelsAngle = 270;
        barAbstractSeries.barWidth = 0.8;
        
        barChartView.axisX().categories = getCats();
        barChartView.axisX().labelsAngle = 270;
        barChartView.axisX().labelsFont = Qt.font({bold:true,pixelSize:15});
        barChartView.axisX().gridLineColor = "#b1b1b1";
        barChartView.axisY().gridLineColor = "#b1b1b1";
        ...
    }

where barChartView is
ChartView {
    id: barChartView
    width: parent.width
    height: 400
    antialiasing: false
    legend.visible: false
    backgroundColor: "#85FFFFFF"
    animationOptions: ChartView.SeriesAnimations
    animationDuration: 50
    titleFont: Qt.font({pointSize: 15})    
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question