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

QtCharts bar: histogram with sorted value (and animation)



  • Hello,

    I am tryng to implement a histogram with sorted values (higher values first), these data are dynamics and change over times.
    Consequently, a bar (with its label) can change of position over time.

    I have seen "oscilloscope " and "temperature records" examples, which are very helpful but I have not seen any way to move bars easily.

    Below is a very basic mockup with what I am tryng to implement:
    chart_mockup.png

    • Is it possible to move a bar with its label easily by manipulating chart object?
    • Is it possible to move bars (laterally) with animations? it would be great!
    • What is the best way to implement this data viewer easily (knowing that data are updated just one time per second and they are less than 100 bars, so it is not a very CPU sensitive task)

    Any help would be greatly appreciated!

    Thank you in advance.



  • @malaga said in QtCharts bar: histogram with sorted value (and animation):

    Is it possible to move a bar with its label easily by manipulating chart object?
    Is it possible to move bars (laterally) with animations? it would be great!

    Move where?
    What kind of animations?

    What is the best way to implement this data viewer easily (knowing that data are updated just one time per second and they are less than 100 bars, so it is not a very CPU sensitive task)

    Just repaint / create your bars once per second and make sure that your QBarSeries data has the correct order (append decreasing values, so your highest bar is on the left).



  • @Pl45m4

    Move where?
    What kind of animations?

    Sorry if this point was not explicit.
    Each bar is linked to an object name which is indicated with labels on the X axis. Since data are updated and change over time, and that bars are sorted (higher values first), a bar can move at right if its values decrease or move to the left if its value increase.
    For now, I achieve that by directly updating labels by using bar chart "categories" and by updating bar values, but I've not managed to have animations representing the evolution of the bar. I would like my bars to move laterally to the left and the right with animation, without directly "jumping" to their new positions (that is to say with linear interpolated positions between two data update)



  • @malaga said in QtCharts bar: histogram with sorted value (and animation):

    I would like my bars to move laterally to the left and the right with animation

    What if you slowly in-/decrease the X-value of your bars?! I guess, for "real animations" you have to create your own QChartView subclass or even a custom widget.


Log in to reply