1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,121 +1,131 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QLineSeries> |
|
24 | #include <QLineSeries> | |
25 | #include <QCategoryAxis> |
|
25 | #include <QCategoryAxis> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | int main(int argc, char *argv[]) |
|
29 | int main(int argc, char *argv[]) | |
30 | { |
|
30 | { | |
31 | QApplication a(argc, argv); |
|
31 | QApplication a(argc, argv); | |
32 |
|
32 | |||
33 | //![1] |
|
33 | //![1] | |
34 | QLineSeries *series = new QLineSeries(); |
|
34 | QLineSeries *series = new QLineSeries(); | |
35 | *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26); |
|
35 | *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26); | |
36 | QChart *chart = new QChart(); |
|
36 | QChart *chart = new QChart(); | |
37 | chart->legend()->hide(); |
|
37 | chart->legend()->hide(); | |
38 | chart->addSeries(series); |
|
38 | chart->addSeries(series); | |
39 | //![1] |
|
39 | //![1] | |
40 |
|
40 | |||
41 | //![2] |
|
41 | //![2] | |
42 | // Customize series |
|
42 | // Customize series | |
43 | QPen pen(QRgb(0xfdb157)); |
|
43 | QPen pen(QRgb(0xfdb157)); | |
44 | pen.setWidth(5); |
|
44 | pen.setWidth(5); | |
45 | series->setPen(pen); |
|
45 | series->setPen(pen); | |
46 |
|
46 | |||
47 | // Customize chart title |
|
47 | // Customize chart title | |
48 | QFont font; |
|
48 | QFont font; | |
49 | font.setPixelSize(18); |
|
49 | font.setPixelSize(18); | |
50 | chart->setTitleFont(font); |
|
50 | chart->setTitleFont(font); | |
51 | chart->setTitleBrush(QBrush(Qt::white)); |
|
51 | chart->setTitleBrush(QBrush(Qt::white)); | |
52 | chart->setTitle("Customchart example"); |
|
52 | chart->setTitle("Customchart example"); | |
53 |
|
53 | |||
54 | // Customize chart background |
|
54 | // Customize chart background | |
55 | QLinearGradient backgroundGradient; |
|
55 | QLinearGradient backgroundGradient; | |
56 | backgroundGradient.setStart(QPointF(0, 0)); |
|
56 | backgroundGradient.setStart(QPointF(0, 0)); | |
57 | backgroundGradient.setFinalStop(QPointF(0, 1)); |
|
57 | backgroundGradient.setFinalStop(QPointF(0, 1)); | |
58 | backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1)); |
|
58 | backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1)); | |
59 | backgroundGradient.setColorAt(1.0, QRgb(0x4c4547)); |
|
59 | backgroundGradient.setColorAt(1.0, QRgb(0x4c4547)); | |
60 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
60 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
61 | chart->setBackgroundBrush(backgroundGradient); |
|
61 | chart->setBackgroundBrush(backgroundGradient); | |
|
62 | ||||
|
63 | // Customize plot area background | |||
|
64 | QLinearGradient plotAreaGradient; | |||
|
65 | plotAreaGradient.setStart(QPointF(0, 1)); | |||
|
66 | plotAreaGradient.setFinalStop(QPointF(1, 0)); | |||
|
67 | plotAreaGradient.setColorAt(0.0, QRgb(0x555555)); | |||
|
68 | plotAreaGradient.setColorAt(1.0, QRgb(0x55aa55)); | |||
|
69 | plotAreaGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |||
|
70 | chart->setPlotAreaBackgroundBrush(plotAreaGradient); | |||
|
71 | chart->setPlotAreaBackgroundVisible(true); | |||
62 | //![2] |
|
72 | //![2] | |
63 |
|
73 | |||
64 | //![3] |
|
74 | //![3] | |
65 | QCategoryAxis *axisX = new QCategoryAxis(); |
|
75 | QCategoryAxis *axisX = new QCategoryAxis(); | |
66 | QCategoryAxis *axisY = new QCategoryAxis(); |
|
76 | QCategoryAxis *axisY = new QCategoryAxis(); | |
67 |
|
77 | |||
68 | // Customize axis label font |
|
78 | // Customize axis label font | |
69 | QFont labelsFont; |
|
79 | QFont labelsFont; | |
70 | labelsFont.setPixelSize(12); |
|
80 | labelsFont.setPixelSize(12); | |
71 | axisX->setLabelsFont(labelsFont); |
|
81 | axisX->setLabelsFont(labelsFont); | |
72 | axisY->setLabelsFont(labelsFont); |
|
82 | axisY->setLabelsFont(labelsFont); | |
73 |
|
83 | |||
74 | // Customize axis colors |
|
84 | // Customize axis colors | |
75 | QPen axisPen(QRgb(0xd18952)); |
|
85 | QPen axisPen(QRgb(0xd18952)); | |
76 | axisPen.setWidth(2); |
|
86 | axisPen.setWidth(2); | |
77 | axisX->setLinePen(axisPen); |
|
87 | axisX->setLinePen(axisPen); | |
78 | axisY->setLinePen(axisPen); |
|
88 | axisY->setLinePen(axisPen); | |
79 |
|
89 | |||
80 | // Customize axis label colors |
|
90 | // Customize axis label colors | |
81 | QBrush axisBrush(Qt::white); |
|
91 | QBrush axisBrush(Qt::white); | |
82 | axisX->setLabelsBrush(axisBrush); |
|
92 | axisX->setLabelsBrush(axisBrush); | |
83 | axisY->setLabelsBrush(axisBrush); |
|
93 | axisY->setLabelsBrush(axisBrush); | |
84 |
|
94 | |||
85 | // Customize grid lines and shades |
|
95 | // Customize grid lines and shades | |
86 | axisX->setGridLineVisible(false); |
|
96 | axisX->setGridLineVisible(false); | |
87 | axisY->setGridLineVisible(false); |
|
97 | axisY->setGridLineVisible(false); | |
88 | axisY->setShadesPen(Qt::NoPen); |
|
98 | axisY->setShadesPen(Qt::NoPen); | |
89 |
axisY->setShadesBrush(QBrush(Q |
|
99 | axisY->setShadesBrush(QBrush(QColor(0x99, 0xcc, 0xcc, 0x55))); | |
90 | axisY->setShadesVisible(true); |
|
100 | axisY->setShadesVisible(true); | |
91 | //![3] |
|
101 | //![3] | |
92 |
|
102 | |||
93 | //![4] |
|
103 | //![4] | |
94 | axisX->append("low", 10); |
|
104 | axisX->append("low", 10); | |
95 | axisX->append("optimal", 20); |
|
105 | axisX->append("optimal", 20); | |
96 | axisX->append("high", 30); |
|
106 | axisX->append("high", 30); | |
97 | axisX->setRange(0, 30); |
|
107 | axisX->setRange(0, 30); | |
98 |
|
108 | |||
99 | axisY->append("slow", 10); |
|
109 | axisY->append("slow", 10); | |
100 | axisY->append("med", 20); |
|
110 | axisY->append("med", 20); | |
101 | axisY->append("fast", 30); |
|
111 | axisY->append("fast", 30); | |
102 | axisY->setRange(0, 30); |
|
112 | axisY->setRange(0, 30); | |
103 |
|
113 | |||
104 | chart->setAxisX(axisX, series); |
|
114 | chart->setAxisX(axisX, series); | |
105 | chart->setAxisY(axisY, series); |
|
115 | chart->setAxisY(axisY, series); | |
106 | //![4] |
|
116 | //![4] | |
107 |
|
117 | |||
108 | //![5] |
|
118 | //![5] | |
109 | QChartView *chartView = new QChartView(chart); |
|
119 | QChartView *chartView = new QChartView(chart); | |
110 | chartView->setRenderHint(QPainter::Antialiasing); |
|
120 | chartView->setRenderHint(QPainter::Antialiasing); | |
111 | //![5] |
|
121 | //![5] | |
112 |
|
122 | |||
113 | //![6] |
|
123 | //![6] | |
114 | QMainWindow window; |
|
124 | QMainWindow window; | |
115 | window.setCentralWidget(chartView); |
|
125 | window.setCentralWidget(chartView); | |
116 | window.resize(400, 300); |
|
126 | window.resize(400, 300); | |
117 | window.show(); |
|
127 | window.show(); | |
118 | //![6] |
|
128 | //![6] | |
119 |
|
129 | |||
120 | return a.exec(); |
|
130 | return a.exec(); | |
121 | } |
|
131 | } |
General Comments 0
You need to be logged in to leave comments.
Login now