如何在QML中删除chartview和它的绘图区之间的间距

时间:2019-03-22 07:10:35

标签: qt qml qtquick2 qchart qchartview

1)我的要求是Qml中的chartview绘图区应获取整个空间。 2)我不希望在chartview和plotarea网格之间留有间距。 3)为此,我做了

_t

4)完成此操作后,网格和统计图视图之间的间距仍然很小。 5)然后我通过给x,y轴减值并增加宽度和高度来做到这一点。

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

6)完成此操作后,对其进行了适当的调整。 7)但是当我改变Valueaxis(max)时,它再次追赶它的位置。 8)在图表视图内的Valueaxis,存在最小值最大值,如果max = 5,则为    正确显示,如果我将max = 10更改为某值,则它正在更改其位置    它显示正确,在某些情况下却不显示

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
 }
   }

任何可能的解决方案?

1 个答案:

答案 0 :(得分:0)

操作方法如下:

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

您正在强迫plotAreaChartView处于同一位置并具有相同的尺寸。 可能是Qt.rect(0, 0, width, height)。我没有用您的电话号码尝试过。我假设它是0,0,因为那是与parent ChartView的偏移量。