@@ -1,73 +1,74 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QApplication> |
|
22 | 22 | #include <QMainWindow> |
|
23 | 23 | #include <QChartView> |
|
24 | 24 | #include <QLineSeries> |
|
25 | 25 | #include <QValueAxis> |
|
26 | 26 | #include <QLogValueAxis> |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | int main(int argc, char *argv[]) |
|
31 | 31 | { |
|
32 | 32 | QApplication a(argc, argv); |
|
33 | 33 | |
|
34 | 34 | //![1] |
|
35 | 35 | QLineSeries *series = new QLineSeries(); |
|
36 |
*series << QPointF(1, |
|
|
36 | *series << QPointF(1, 1) << QPointF(2, 73) << QPointF(3, 268) << QPointF(4, 17) << QPointF(5, 4325) << QPointF(6, 723); | |
|
37 | 37 | //![1] |
|
38 | 38 | |
|
39 | 39 | //![3] |
|
40 | 40 | QChart *chart = new QChart(); |
|
41 | 41 | chart->addSeries(series); |
|
42 | 42 | chart->legend()->hide(); |
|
43 | chart->setTitle("QLogValueAxis chart example"); | |
|
43 | 44 | //![3] |
|
44 | 45 | |
|
45 | 46 | //![4] |
|
46 | 47 | QValueAxis *axisX = new QValueAxis; |
|
47 | 48 | axisX->setTitleText("Data point"); |
|
48 | 49 | axisX->setTickCount(6); |
|
49 | 50 | axisX->setLabelFormat("%i"); |
|
50 | 51 | chart->addAxis(axisX, Qt::AlignBottom); |
|
51 | 52 | series->attachAxis(axisX); |
|
52 | 53 | |
|
53 | 54 | QLogValueAxis *axisY = new QLogValueAxis; |
|
54 |
axisY->set |
|
|
55 | axisY->setLabelFormat("%g"); | |
|
55 | 56 | axisY->setTitleText("Values"); |
|
56 | 57 | chart->addAxis(axisY, Qt::AlignLeft); |
|
57 | 58 | series->attachAxis(axisY); |
|
58 | 59 | //![4] |
|
59 | 60 | |
|
60 | 61 | //![5] |
|
61 | 62 | QChartView *chartView = new QChartView(chart); |
|
62 | 63 | chartView->setRenderHint(QPainter::Antialiasing); |
|
63 | 64 | //![5] |
|
64 | 65 | |
|
65 | 66 | //![6] |
|
66 | 67 | QMainWindow window; |
|
67 | 68 | window.setCentralWidget(chartView); |
|
68 |
window.resize( |
|
|
69 | window.resize(400, 300); | |
|
69 | 70 | window.show(); |
|
70 | 71 | //![6] |
|
71 | 72 | |
|
72 | 73 | return a.exec(); |
|
73 | 74 | } |
@@ -1,83 +1,90 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QApplication> |
|
22 | 22 | #include <QMainWindow> |
|
23 | 23 | #include <QChartView> |
|
24 | 24 | #include <QLineSeries> |
|
25 | #include <QSplineSeries> | |
|
25 | 26 | #include <QValueAxis> |
|
26 |
#include <Q |
|
|
27 | #include <QValueAxis> | |
|
27 | #include <QCategoryAxis> | |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | int main(int argc, char *argv[]) |
|
32 | 32 | { |
|
33 | 33 | QApplication a(argc, argv); |
|
34 | 34 | |
|
35 | qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); | |
|
36 | ||
|
37 | 35 | //![1] |
|
38 | QLineSeries *series; | |
|
39 | QValueAxis *axisX; | |
|
40 | QValueAxis *axisY; | |
|
41 | 36 | QChart *chart = new QChart(); |
|
42 | for (int i = 0; i < 5; i++) { | |
|
43 | series = new QLineSeries; | |
|
44 | for (int k(0); k < 8; k++) | |
|
45 | series->append(i + k, qrand() % 20); | |
|
46 | chart->addSeries(series); | |
|
47 | ||
|
48 | axisX = new QValueAxis; | |
|
49 | axisX->setTickCount(7 + i); | |
|
50 |
|
|
|
51 | ||
|
52 | axisY = new QValueAxis; | |
|
53 | axisY->setTickCount(7 + i); | |
|
54 | axisY->setLinePenColor(series->pen().color()); | |
|
55 | ||
|
56 | chart->addAxis(axisX,i % 2?Qt::AlignTop:Qt::AlignBottom); | |
|
57 | chart->addAxis(axisY,i % 2?Qt::AlignRight:Qt::AlignLeft); | |
|
58 | series->attachAxis(axisX); | |
|
59 | series->attachAxis(axisY); | |
|
60 | } | |
|
37 | QValueAxis *axisX = new QValueAxis; | |
|
38 | axisX->setTickCount(10); | |
|
39 | ||
|
40 | QSplineSeries *series = new QSplineSeries; | |
|
41 | *series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5); | |
|
42 | chart->addSeries(series); | |
|
43 | ||
|
44 | QValueAxis *axisY = new QValueAxis; | |
|
45 | axisY->setLinePenColor(series->pen().color()); | |
|
46 | ||
|
47 | chart->addAxis(axisX, Qt::AlignBottom); | |
|
48 | chart->addAxis(axisY, Qt::AlignLeft); | |
|
49 | series->attachAxis(axisX); | |
|
50 | series->attachAxis(axisY); | |
|
51 | ||
|
52 | series = new QSplineSeries; | |
|
53 | *series << QPointF(1, 0.5) << QPointF(1.5, 4.5) << QPointF(2.4, 2.5) << QPointF(4.3, 12.5) | |
|
54 | << QPointF(5.2, 3.5) << QPointF(7.4, 16.5) << QPointF(8.3, 7.5) << QPointF(10, 17); | |
|
55 | chart->addSeries(series); | |
|
56 | ||
|
57 | QCategoryAxis *axisY3 = new QCategoryAxis; | |
|
58 | axisY3->append("Low", 5); | |
|
59 | axisY3->append("Medium", 12); | |
|
60 | axisY3->append("High", 17); | |
|
61 | axisY3->setLinePenColor(series->pen().color()); | |
|
62 | axisY3->setGridLinePen((series->pen())); | |
|
63 | ||
|
64 | chart->addAxis(axisY3, Qt::AlignRight); | |
|
65 | series->attachAxis(axisX); | |
|
66 | series->attachAxis(axisY3); | |
|
67 | ||
|
61 | 68 | //![2] |
|
62 | 69 | |
|
63 | 70 | //![3] |
|
64 | 71 | chart->legend()->hide(); |
|
65 | ||
|
66 | chart->setTitle("Simple line chart example"); | |
|
72 | chart->setTitle("Multiaxis chart example"); | |
|
67 | 73 | //![3] |
|
68 | 74 | |
|
69 | 75 | //![4] |
|
70 | 76 | QChartView *chartView = new QChartView(chart); |
|
71 | 77 | chartView->setRenderHint(QPainter::Antialiasing); |
|
72 | 78 | //![4] |
|
73 | 79 | |
|
74 | 80 | |
|
75 | 81 | //![5] |
|
76 | 82 | QMainWindow window; |
|
77 | 83 | window.setCentralWidget(chartView); |
|
78 | 84 | window.resize(800, 600); |
|
79 | 85 | window.show(); |
|
80 | 86 | //![5] |
|
81 | 87 | |
|
82 | 88 | return a.exec(); |
|
83 | 89 | } |
|
90 |
General Comments 0
You need to be logged in to leave comments.
Login now