Results 1 to 4 of 4

Thread: How to zoom charts using fingers?

  1. #1
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Question How to zoom charts using fingers?

    Hi!
    I using Qt 5.4.1 Enterprise and used Qt Charts 2.0 module
    I create Line Chart Example and build it to android device
    My code:
    Qt Code:
    1. import QtQuick 2.4
    2. import QtQuick.Controls 1.3
    3. import QtQuick.Window 2.2
    4. import QtQuick.Dialogs 1.2
    5. import QtCharts 2.0
    6.  
    7. ApplicationWindow {
    8. width: 640
    9. height: 480
    10. visible: true
    11. property int currentIndex: -1
    12. property int index_X: -1
    13. property int index_Y: 50
    14. property string driver: "Test"
    15.  
    16. ChartView {
    17. id: chartView
    18. title: "TEST CHARTS"
    19. anchors.fill: parent
    20. legend.alignment: Qt.AlignTop
    21. animationOptions: ChartView.SeriesAnimations
    22. antialiasing: true
    23. theme: ChartView.ChartThemeDark
    24. }
    25.  
    26. Timer {
    27. id: timer
    28. interval: 700
    29. repeat: true
    30. triggeredOnStart: true
    31. running: true
    32. onTriggered: {
    33. currentIndex++;
    34. index_Y = Math.random()*250
    35. index_X ++;
    36. if (currentIndex <= 20) {
    37. // Check if there is a series for the data already (we are using driver name to identify series)
    38. var lineSeries = chartView.series(driver);
    39. if (!lineSeries) {
    40. lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, driver);
    41. chartView.axisY().min = 0;
    42. chartView.axisY().max = 250;
    43. chartView.axisY().tickCount = 6;
    44. chartView.axisX().titleText = "Time line";
    45. chartView.axisX().labelFormat = "%.0f";
    46. }
    47. lineSeries.append(index_X, index_Y);
    48.  
    49. if (index_X > 3) {
    50. chartView.axisX().max = index_X + 1;
    51. chartView.axisX().min = chartView.axisX().max - 5;
    52. } else {
    53. chartView.axisX().max = 5;
    54. chartView.axisX().min = 0;
    55. }
    56. chartView.axisX().tickCount = chartView.axisX().max - chartView.axisX().min + 1;
    57. } else {
    58. // No more data, change x-axis range to show all the data
    59. timer.stop();
    60. chartView.animationOptions = ChartView.AllAnimations;
    61. chartView.axisX().min = 0;
    62. chartView.axisX().max = index_X;
    63. }
    64. }
    65. }
    66.  
    67. }
    To copy to clipboard, switch view to plain text mode 
    And now, I want to zoom charts using two finger as video below (from 1.59 - 2.02)

    Please help me any idea. Thanks so much!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to zoom charts using fingers?

    You could try a PinchArea on top of the chart view and calling the chart view's zoom function appropriately from the pinch area's signal handlers.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    tanthinh1510 (6th May 2015)

  4. #3
    Join Date
    Oct 2013
    Location
    VietNam
    Posts
    41
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: How to zoom charts using fingers?

    Quote Originally Posted by anda_skoa View Post
    You could try a PinchArea on top of the chart view and calling the chart view's zoom function appropriately from the pinch area's signal handlers.

    Cheers,
    _
    Thanks anda_skoa! I used PinchArea and it zoom ok.
    And I want to move charts using one finger touch screen and drag as video below (from 2.01 - 2.03)



    Have signal to work it?

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to zoom charts using fingers?

    Have a look at the documentation, some of the examples and maybe a couple of tutorials.

    The Flickable type might be a good start.

    Cheers,
    _

Similar Threads

  1. Replies: 21
    Last Post: 8th December 2011, 02:18
  2. how to zoom in zoom out tableview in QT programming?
    By nageshvk in forum Qt Programming
    Replies: 0
    Last Post: 27th October 2010, 05:05
  3. QWTPlot Zoom: cannot zoom negative value
    By jwieland in forum Qwt
    Replies: 0
    Last Post: 8th January 2010, 16:16
  4. Replies: 1
    Last Post: 16th November 2009, 05:25
  5. QGLWidget with text - zoom in / zoom out
    By h123 in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2008, 09:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.