Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. ChartView & AreaSeries
Forum Updated to NodeBB v4.3 + New Features

ChartView & AreaSeries

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 3 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chobin
    wrote on last edited by Chobin
    #1

    I'm developing an Area chart in QML an QT c++.
    I have a timer and at every timeout, my QT class (myChart object) appends a new value to the serei.
    I wanto to fill the chart area, so I'm using AreaSeries, but I've got a problem about this point: I have to use a gradient color and I don't know how do it.
    I tryed to build the color in QT like a property and passing it to the chart, but the final result is that the new color is apply on whole area and not on the new sample.

    This is my code:
    @
    ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Connections {
        target: myChart
        onWValueChanged: {
            lineSeries1.append(myChart.wValue.x, myChart.wValue.y)
        }
    }
    ChartView {
        id: chartView
        anchors.fill: parent
        antialiasing: true
    
        ValueAxis {
            id: valueAxisY
            min: 0
            max: 4
            tickCount: 5
            labelFormat: "%.0f"
        }
    
        ValueAxis {
            id: valueAxisX
            min: 2000
            max: 2000 + myChart.maxXval
            tickCount: 12
            labelFormat: "%.0f"
        }
    
        LineSeries {
            id: series
            axisX: valueAxisX
            axisY: valueAxisY
    
            Component.onCompleted: {
                for(var i = 0;i < myChart.serieSize();i ++) {
                    series.append(myChart.getX(i), myChart.getY(i));
                }
            }
        }
    
        AreaSeries {
            id: russia2
            name: "Russian2"
            color: myChart.fillColor//"#FFD52B1E"
            borderColor: myChart.fillColor//"#FF0039A5"
            borderWidth: 3
            axisX: valueAxisX
            axisY: valueAxisY
            upperSeries:LineSeries {
                id: lineSeries1
                name: "signal 1"
            }
        }
    }
    

    }
    @

    myChart is the QT C++ object used to update the serie an the color.

    Could someone help me to find a solution?

    Many thanks in advance for your support.

    Chobin

    1 Reply Last reply
    0
    • AndySA Offline
      AndySA Offline
      AndyS
      Moderators
      wrote on last edited by
      #2

      Hi @Chobin,

      I am not entirely sure what you mean here, what part of it are you trying to apply the gradient to exactly?

      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chobin
        wrote on last edited by Chobin
        #3

        Hi @AndyS

        Thanks for your reply. I'd like applying the gradient to the AreaSeries: name "Russian2.
        So I created a c++ class where I defined a property color, "fillColor", and at every sample I changed it. At every sample a signal is emitted and the new color is apply to the AreaSeries "Russian2". The problem is that the new color is not apply from the current sample, but from the first to latest sample.

        Is there a way to solve the problem?

        Many thanks.

        Best Regards,

        chobin

        1 Reply Last reply
        0
        • AndySA Offline
          AndySA Offline
          AndyS
          Moderators
          wrote on last edited by
          #4

          Hi @Chobin,

          Ah, I understand you now. This is not possible using AreaSeries unfortunately as it only takes a color, and you need to be able to pass a gradient here via a brush. So the only way to do that would be to modify Qt Charts. What I suggest you do is open a feature request for this via JIRA

          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          kshegunovK 1 Reply Last reply
          0
          • AndySA AndyS

            Hi @Chobin,

            Ah, I understand you now. This is not possible using AreaSeries unfortunately as it only takes a color, and you need to be able to pass a gradient here via a brush. So the only way to do that would be to modify Qt Charts. What I suggest you do is open a feature request for this via JIRA

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @AndyS said in ChartView & AreaSeries:

            So the only way to do that would be to modify Qt Charts.

            From my point of view, this is pretty much futile as it'd mean hacking at the Qt's sources. QtCharts does not provide for means to extend or modify the behavior, drawing or even adding chart types. Everything is buried in the private classes and the only thing one could override is a couple of setters.

            Read and abide by the Qt Code of Conduct

            AndySA 1 Reply Last reply
            0
            • kshegunovK kshegunov

              @AndyS said in ChartView & AreaSeries:

              So the only way to do that would be to modify Qt Charts.

              From my point of view, this is pretty much futile as it'd mean hacking at the Qt's sources. QtCharts does not provide for means to extend or modify the behavior, drawing or even adding chart types. Everything is buried in the private classes and the only thing one could override is a couple of setters.

              AndySA Offline
              AndySA Offline
              AndyS
              Moderators
              wrote on last edited by
              #6

              @kshegunov said in ChartView & AreaSeries:

              @AndyS said in ChartView & AreaSeries:

              So the only way to do that would be to modify Qt Charts.

              From my point of view, this is pretty much futile as it'd mean hacking at the Qt's sources. QtCharts does not provide for means to extend or modify the behavior, drawing or even adding chart types. Everything is buried in the private classes and the only thing one could override is a couple of setters.

              I meant that you would need to modify the sources directly, not by subclassing. I agree the only way is to override a couple of setters. Thinking about it, in theory, it might be possible to try and get access to the item used directly (since it likely a QGraphicsItem) so you might be able to call setBrush() on it directly. But I didn't mean that you can do this by subclassing at least, Qt Charts does not provide a means in that regard.

              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved