How do I get rid of the margin around a ChartView?

  • QtQuickControls 2 app using 5.10...

    I've got a ChartView inside a Rectangle, and I'd like the ChartView to fill the Rectangle, but there's a mysterious border around the ChartView...

            ChartView {
                title: "My Graph"
                titleColor: Qt.rgba(.5,.5,.5,1)
                anchors.fill: parent
                antialiasing: true
                backgroundColor: "black"

    0_1519158063349_Screen Shot 2018-02-20 at 12.17.18 PM.png

    What's causing this? How can I get the black background of the chart to fill the yellow rectangle?

    It's clearly an issue with ChartView, as placing another rectangle inside the yellow rectangle, and asking it to fill creates a new rectangle that covers the yellow completely, as expected.

  • It looks like the work-around that others have used is to set anchorMargins to -15, which works.

    It would be nice to find a more beautiful solution. Why should a chart behave any different than a Rectangle with regards to positioning?

  • I've had support already raise this as:

  • @6thC

    Thanks for submitting the bug!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.