1

1) My requirement is that Plotarea of chartview in Qml should acquire whole space. 2) I don't want spacing between chartview and plotarea grids. 3) For this, i made

margins.top: 0
margins.bottom: 0
margins.left: 0
margins.right: 0

4) After Doing this, there was still little spacing between grids and chartview. 5) Then i did this, by giving minus values to x,y axis and increasing width and height.

Rectangle
{
 width : 400
 height: 200
 clip:true

 ChartView
 {
  height: parent.height+42
  width: parent.width+51
  x:-32
  y:-15
  legend.visible:false
  margins.top: 0
  margins.bottom: 0
  margins.left: 0
  margins.right: 0
 }
   }

6) After doing this it got adjusted properly. 7) But when i am chaning Valueaxis(max), then it is again chaing it's position. 8) Valueaxis which is inside chartview, there is min max value, if max=5 then it's displaying properly, if i change max=10 then it's changing its position, on some value's it's showing properly, on some it's not

ValueAxis
    {
      id:y_axis
      min: 0
      max: 5 // on 5 it's proper, if i change it to 10 grids position is changing
      tickCount: 4
      labelsVisible: false
    }

Any Possible Solution ?

  • Does this answer your question? [How to remove spacing? QML ChartView](https://stackoverflow.com/questions/41333187/how-to-remove-spacing-qml-chartview) – Aleksey Kontsevich Feb 23 '20 at 03:26

1 Answers1

1

Here's how to do that:

ChartView
 {
  height: parent.height+42
  width: parent.width+51
  x:-32
  y:-15
  legend.visible:false
  plotArea: Qt.rect(x, y, width, height)
 }

You're forcing your plotArea to be at the same position of the ChartView and to have same dimensions. It might probably be Qt.rect(0, 0, width, height). I haven't tried it with your numbers. I'm assuming it's 0, 0 because that's the offset from the parent ChartView.

bardao
  • 914
  • 12
  • 23