How to remove spacing in ChartView?
Possible solution 1: QMargins
property designates the minimum area around the plotting area. Try filling this remaining padding by adjusting the child (plot) itself.
plotArea : rect The area on the ChartView that is used for drawing series. This is the ChartView rect without the margins.
Possible solution 2: Try to redraw the parent layout after setting the margins. If you are adjusting the margins after the window is created, it may not necessarily refresh the view immediately.
I had the same issue, but couldn't quite understand what the accepted answer meant in solution 1. I found a solution to the problem that worked for me, so I will post it as another answer here.
(I would've liked to know more specifically what the accepted soultion is, but I cannot comment on other people's answers yet.)
My solution is in any case (in addition to setting the margins to 0 as shown in the question, and having the legend and the axes not be visible):
ChartView
{
x: -10
y: -10
width: parent.width + 20
height: parent.height + 20
}
Which simply manually moves the plotting area of the Chartview to the top left corner of the parent component and resizes it appropriately. I don't know where the number 10 comes from, but that seems to be the size of the remaining margin. The "real" answer to this question would be how to set that to 0 in a more robust way.
If this answer is the same as the one refered to in the accepted answer, or if that answer is indeed a more robust one, please let me know!
Another trick is to add this following lines to ChartView
anchors { fill: parent; margins: -15 }
margins { right: 0; bottom: 0; left: 0; top: 0 }