Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-137982

Consistent and intuitive API for controlling tick interval in DateTimeAxis and ValueAxis

    XMLWordPrintable

Details

    Description

      Currently,

      • ValueAxis.tickInterval means "difference in value between 2 adjacent ticks" (OK)
      • DateTimeAxis.tickInterval means "Number of divisions shown in GraphsView.plotArea between DateTimeAxis.min and DateTimeAxis.max" (Not OK)

      This meaning of DateTimeAxis.tickInterval is unintuitive and doesn't match our documentation (see https://doc.qt.io/qt-6/qml-qtgraphs-datetimeaxis.html#tickInterval-prop)

       

      Test Code

      import QtQuick
      import QtQuick.Layouts
      import QtQuick.Controls.Basic
      import QtGraphs
      
      ApplicationWindow {
          width: 800
          height: 600
          visible: true
      
          header: GridLayout {
              columns: 2
      
              Label { text: `Tick Interval (${tickSlider.value})`}
              Slider {
                  id: tickSlider
                  from: 1
                  value: 5
                  to: 10
                  stepSize: 1
                  Layout.fillWidth: true
              }
      
              Label { text: `X Range (${xSlider.value})` }
              Slider {
                  id: xSlider
                  from: 1
                  value: 5
                  to: 10
                  stepSize: 1
                  Layout.fillWidth: true
              }
          }
      
          GraphsView {
              id: valueGraph
              anchors.fill: parent
              anchors.bottomMargin: parent.height/2
      
              property real startX: 0
              property real finalX: xSlider.value
      
              axisY: ValueAxis { min: 0; max: 10 }
              axisX: ValueAxis {
                  min: valueGraph.startX
                  max: valueGraph.finalX
                  tickInterval: tickSlider.value
              }
          }
      
          GraphsView {
              id: dateGraph
              anchors.fill: parent
              anchors.topMargin: parent.height/2
      
              property date startX: new Date("2000-01-01T00:00:00Z")
              property date finalX: {
                  let d = startX
                  d.setDate(d.getDate() + xSlider.value)
                  console.log(d)
                  return d
              }
      
              axisY: ValueAxis { min: 0; max: 10 }
              axisX: DateTimeAxis {
                  labelsAngle: 45
                  labelFormat: "yyyy-MM-dd"
                  min: dateGraph.startX
                  max: dateGraph.finalX
                  tickInterval: tickSlider.value
              }
          }
      }
      

       

      Suggestions

      • The current functionality provided by DateTimeAxis.tickInterval should be transferred to a new property (DateTimeAxis.divisionsInPlotArea?)
      • ValueAxis could get the same property too, along with a way to select between the new property or tickInterval
      • DateTimeAxis.tickInterval in its current form should be deprecated
      • DateTimeAxis should get a new property that behaves like ValueAxis.tickInterval. Its datatype should be something like std::chrono::duration or Temporal.Duration (requires QTBUG-134787)

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kagro Kaj Grönholm
            skoh-qt Sze Howe Koh
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes