【问题标题】:How to Remove Spacing between chartview and it's Plotarea in QML如何在 QML 中删除图表视图与其 Plotarea 之间的间距
【发布时间】:2019-03-22 07:10:34
【问题描述】:

1)我的要求是Qml中chartview的Plotarea应该获得整个空间。 2) 我不希望图表视图和绘图区域网格之间有间距。 3)为此,我做了

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

4) 执行此操作后,网格和图表视图之间的间距仍然很小。 5) 然后我通过给 x,y 轴赋予负值并增加宽度和高度来做到这一点。

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) 这样做后,它得到了适当的调整。 7) 但是当我改变 Valueaxis(max) 时,它会再次链接它的位置。 8)图表视图内的Valueaxis,有最小最大值,如果max = 5那么它是 正确显示,如果我改变 max=10 那么它会改变它的位置,在某个值上 显示正常,有些则不显示

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
    }

任何可能的解决方案?

【问题讨论】:

标签: qt qml qtquick2 qchart qchartview


【解决方案1】:

这是如何做到这一点的:

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 的偏移量。

【讨论】:

  • 32 和 15 是启发式数字吗?
  • 我只是从问题中复制了数字。不应该影响 plotArea。
猜你喜欢
  • 1970-01-01
  • 2020-01-20
  • 1970-01-01
  • 2020-05-01
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 2023-03-08
  • 1970-01-01
相关资源
最近更新 更多