Solved How to completely remove margins/spacing with QML ChartView
-
The question is the same as in this thread:
Re: How to remove spacings? QML ChartView.
@MikhailG posted the same question on StackOverflow and apparently this answer solves it:
Possible solution 1: QMargins property designates the minimum area around the plotting area. Try filling this remaining padding by adjusting the child (plot) itself.
But what does that mean? I've tried setting the size of the plotArea, but it's read only.
I wanted to comment on the answer in SO, but I do not have enough reuptation to do so. If anyone else wants to do so and page @MIkhailG there, feel free :)
Any ideas?
-
I found a hacky solution and posted it on SO to get a response from @MikhailG there, and he updated his answer.
My solution in short:
ChartView { x: -10 y: -10 width: parent.width + 20 height: parent.height + 20 }
In addition to setting the margins to 0 and having the legend and the axes not be visible.
See this link for the updated answer on SO.
-
It'd be great if this wasn't necessary... thanks for sharing - that's something that's bugging me right now, just not high priority yet.
I also wish we could get at the QChart* / Chart item from that ChartView there... I haven't found a way except pass a LineSeries ref to C++, QLineSeries* ptr->chart(); is just a bit annoying.
Anyhow - charts that I didn't have to handcraft - they are working very well so far for me.
Re: the legend: I'm was pleased with how it hides the legend for a series's visible set to false. That was nice to not have to work for that.