Qt Charts PieSeries Pixelated

Viewed 85

I'm trying to create the following image in pyQt charts:

enter image description here

This is what I'm getting (the problem is the perceived low quality due to pixelation):

enter image description here

Here's my code:

ChartView {
        anchors.left: parent.left
        anchors.top: parent.top
        backgroundColor: Styles.colorTransparent
        legend.labelColor: Styles.overviewLabelText

        width: 400//411
        height: 400//250
        legend.alignment: Qt.AlignRight

        PieSeries {
            id: pieSeries
            holeSize: 0.52
            PieSlice { label: "0-35"; value: 5 ; color: Styles.age0_35_plot ; borderWidth: 5 ; borderColor : "#0c3564"}//; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "35-45"; value: 15 ; color: Styles.age35_45_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "45-55"; value: 15 ; color: Styles.age45_55_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "55-65"; value: 15 ; color: Styles.age55_65_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "65-75"; value: 20 ; color: Styles.age65_75_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "+75"; value: 30 ; color: Styles.age_over75_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
        }
    }

Can this be remedied?

1 Answers

Antialiasing is a graphics technique for smoothing jagged edges, set the property to true in your ChartView.

    ChartView {
        anchors.left: parent.left
        anchors.top: parent.top
        backgroundColor: Styles.colorTransparent
        legend.labelColor: Styles.overviewLabelText
        antialiasing: true

        width: 400//411
        height: 400//250
        legend.alignment: Qt.AlignRight

        PieSeries {
            id: pieSeries
            holeSize: 0.52
            PieSlice { label: "0-35"; value: 5 ; color: Styles.age0_35_plot ; borderWidth: 5 ; borderColor : "#0c3564"}//; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "35-45"; value: 15 ; color: Styles.age35_45_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "45-55"; value: 15 ; color: Styles.age45_55_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "55-65"; value: 15 ; color: Styles.age55_65_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "65-75"; value: 20 ; color: Styles.age65_75_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
            PieSlice { label: "+75"; value: 30 ; color: Styles.age_over75_plot ; borderWidth: 5 ; borderColor : "#0c3564"}// ; borderWidth: 0 ; borderColor : Styles.colorTransparent}
        }
    }
Related