Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. import QtCharts 2.1
  2. import QtQuick.Controls 1.4
  3. import QtQuick.Layouts 1.3
  4.  
  5.  
  6. ApplicationWindow {
  7. id: root
  8. visible: true
  9. width: 700
  10. height: 700
  11.  
  12. property var chartX: ["2013-01-27","2013-02-03","2013-02-10","2013-02-17","2013-02-24","2013-03-03","2013-03-10","2013-03-17","2013-03-24","2013-03-31","2013-04-07","2013-04-14","2013-04-21","2013-04-28","2013-05-05","2013-05-12","2013-05-19","2013-05-26","2013-06-02","2013-06-09","2013-06-16","2013-06-23","2013-06-30","2013-07-07","2013-07-14","2013-07-21","2013-07-28","2013-08-04","2013-08-11","2013-08-18","2013-08-25","2013-09-01","2013-09-08","2013-09-15","2013-09-22","2013-09-29","2013-10-06","2013-10-13","2013-10-20","2013-10-27","2013-11-03","2013-11-10","2013-11-17","2013-11-24","2013-12-01","2013-12-08","2013-12-15","2013-12-22","2013-12-29","2014-01-05","2014-01-12","2014-01-19","2014-01-26","2014-02-02","2014-02-09","2014-02-16","2014-02-23","2014-03-02","2014-03-09","2014-03-16","2014-03-23","2014-03-30","2014-04-06","2014-04-13","2014-04-20","2014-04-27","2014-05-04","2014-05-11","2014-05-18","2014-05-25","2014-06-01","2014-06-08","2014-06-15","2014-06-22","2014-06-29","2014-07-06","2014-07-13","2014-07-20","2014-07-27","2014-08-03","2014-08-10","2014-08-17","2014-08-24","2014-08-31","2014-09-07","2014-09-14","2014-09-21","2014-09-28","2014-10-05","2014-10-12","2014-10-19","2014-10-26","2014-11-02","2014-11-09","2014-11-16","2014-11-23","2014-11-30","2014-12-07","2014-12-14","2014-12-21","2014-12-28","2015-01-04"]
  13. property var chartData1: [2,1,0,1,2,3,2,3,3,8,7,5,7,10,3,8,21,15,12,9,9,22,9,12,11,8,13,14,17,21,14,9,14,13,19,21,24,21,23,19,20,23,19,18,28,19,21,21,23,26,21,21,27,33,21,30,26,23,28,24,26,31,39,35,37,35,28,33,44,37,34,34,37,37,33,40,32,40,46,43,39,29,39,46,56,37,50,52,49,48,46,53,28,36,50,54,51,48,60,35,53,22]
  14. property var chartData2: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,1,2,0,0,0,0,0,0,0,0,0,0,1,3,5,7,5,4,4,6,6,12,6,8,7,0,0,2,0,0,0,2,0,2,0,1,2,2,1,0,0,1,1,2,0,1,1,1,1,0,1,1,0,0,0,0,0,0,2,0]
  15. property bool toggle: true
  16.  
  17. ColumnLayout {
  18. anchors.fill: parent
  19. RowLayout{
  20. GroupBox {
  21. title: "Query results"
  22. anchors.fill: parent
  23. Button {
  24. text: "Toggle Data"
  25. onClicked: {
  26. if (root.toggle){
  27. root.chartData2 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,2,0,0,0,0,3,3,5,4,5,4,4,6,8,5,7,5,4,2,3,3,0,1,0,1,0,2,0,1,0,1,3,2,1,1,1,1,1,2,1,0,0,0,0,1,3];
  28. root.toggle = !root.toggle;
  29. }
  30. else{
  31. root.chartData2 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,1,2,0,0,0,0,0,0,0,0,0,0,1,3,5,7,5,4,4,6,6,12,6,8,7,0,0,2,0,0,0,2,0,2,0,1,2,2,1,0,0,1,1,2,0,1,1,1,1,0,1,1,0,0,0,0,0,0,2,0];
  32. }
  33. }
  34. }
  35. }
  36. }
  37. RowLayout{
  38. Layout.fillWidth: true
  39. Layout.fillHeight: true
  40. ChartView {
  41. title: "Bar series"
  42. anchors.fill: parent
  43. legend.alignment: Qt.AlignBottom
  44. antialiasing: true
  45.  
  46. BarSeries {
  47. id: mySeries
  48. axisX: BarCategoryAxis {
  49. id: xAxis
  50. categories: root.chartX
  51. }
  52.  
  53. axisY: ValueAxis {
  54. id: yAxis
  55. max: 80
  56. }
  57. BarSet {
  58. id: chartData1
  59. label: "Returned"
  60. values: root.chartData1
  61. }
  62. BarSet {
  63. id: chartData2
  64. label: "Created";
  65. values: root.chartData2
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement