Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtCharts 2.1
- import QtQuick.Controls 1.4
- import QtQuick.Layouts 1.3
- ApplicationWindow {
- id: root
- visible: true
- width: 700
- height: 700
- 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"]
- 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]
- 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]
- property bool toggle: true
- ColumnLayout {
- anchors.fill: parent
- RowLayout{
- GroupBox {
- title: "Query results"
- anchors.fill: parent
- Button {
- text: "Toggle Data"
- onClicked: {
- if (root.toggle){
- 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];
- root.toggle = !root.toggle;
- }
- else{
- 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];
- }
- }
- }
- }
- }
- RowLayout{
- Layout.fillWidth: true
- Layout.fillHeight: true
- ChartView {
- title: "Bar series"
- anchors.fill: parent
- legend.alignment: Qt.AlignBottom
- antialiasing: true
- BarSeries {
- id: mySeries
- axisX: BarCategoryAxis {
- id: xAxis
- categories: root.chartX
- }
- axisY: ValueAxis {
- id: yAxis
- max: 80
- }
- BarSet {
- id: chartData1
- label: "Returned"
- values: root.chartData1
- }
- BarSet {
- id: chartData2
- label: "Created";
- values: root.chartData2
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement