@@ -33,13 +33,14 int main(int argc, char *argv[]) | |||||
33 |
|
33 | |||
34 | //![1] |
|
34 | //![1] | |
35 | QLineSeries *series = new QLineSeries(); |
|
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 | //![1] |
|
37 | //![1] | |
38 |
|
38 | |||
39 | //![3] |
|
39 | //![3] | |
40 | QChart *chart = new QChart(); |
|
40 | QChart *chart = new QChart(); | |
41 | chart->addSeries(series); |
|
41 | chart->addSeries(series); | |
42 | chart->legend()->hide(); |
|
42 | chart->legend()->hide(); | |
|
43 | chart->setTitle("QLogValueAxis chart example"); | |||
43 | //![3] |
|
44 | //![3] | |
44 |
|
45 | |||
45 | //![4] |
|
46 | //![4] | |
@@ -51,7 +52,7 int main(int argc, char *argv[]) | |||||
51 | series->attachAxis(axisX); |
|
52 | series->attachAxis(axisX); | |
52 |
|
53 | |||
53 | QLogValueAxis *axisY = new QLogValueAxis; |
|
54 | QLogValueAxis *axisY = new QLogValueAxis; | |
54 |
axisY->set |
|
55 | axisY->setLabelFormat("%g"); | |
55 | axisY->setTitleText("Values"); |
|
56 | axisY->setTitleText("Values"); | |
56 | chart->addAxis(axisY, Qt::AlignLeft); |
|
57 | chart->addAxis(axisY, Qt::AlignLeft); | |
57 | series->attachAxis(axisY); |
|
58 | series->attachAxis(axisY); | |
@@ -65,7 +66,7 int main(int argc, char *argv[]) | |||||
65 | //![6] |
|
66 | //![6] | |
66 | QMainWindow window; |
|
67 | QMainWindow window; | |
67 | window.setCentralWidget(chartView); |
|
68 | window.setCentralWidget(chartView); | |
68 |
window.resize( |
|
69 | window.resize(400, 300); | |
69 | window.show(); |
|
70 | window.show(); | |
70 | //![6] |
|
71 | //![6] | |
71 |
|
72 |
@@ -22,9 +22,9 | |||||
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QLineSeries> |
|
24 | #include <QLineSeries> | |
|
25 | #include <QSplineSeries> | |||
25 | #include <QValueAxis> |
|
26 | #include <QValueAxis> | |
26 |
#include <Q |
|
27 | #include <QCategoryAxis> | |
27 | #include <QValueAxis> |
|
|||
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 | |||
@@ -32,38 +32,44 int main(int argc, char *argv[]) | |||||
32 | { |
|
32 | { | |
33 | QApplication a(argc, argv); |
|
33 | QApplication a(argc, argv); | |
34 |
|
34 | |||
35 | qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); |
|
|||
36 |
|
||||
37 | //![1] |
|
35 | //![1] | |
38 | QLineSeries *series; |
|
|||
39 | QValueAxis *axisX; |
|
|||
40 | QValueAxis *axisY; |
|
|||
41 | QChart *chart = new QChart(); |
|
36 | QChart *chart = new QChart(); | |
42 | for (int i = 0; i < 5; i++) { |
|
37 | QValueAxis *axisX = new QValueAxis; | |
43 | series = new QLineSeries; |
|
38 | axisX->setTickCount(10); | |
44 | for (int k(0); k < 8; k++) |
|
|||
45 | series->append(i + k, qrand() % 20); |
|
|||
46 | chart->addSeries(series); |
|
|||
47 |
|
39 | |||
48 | axisX = new QValueAxis; |
|
40 | QSplineSeries *series = new QSplineSeries; | |
49 | axisX->setTickCount(7 + i); |
|
41 | *series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5); | |
50 | axisX->setLinePenColor(series->pen().color()); |
|
42 | chart->addSeries(series); | |
51 |
|
43 | |||
52 |
|
|
44 | QValueAxis *axisY = new QValueAxis; | |
53 | axisY->setTickCount(7 + i); |
|
|||
54 |
|
|
45 | axisY->setLinePenColor(series->pen().color()); | |
55 |
|
46 | |||
56 |
|
|
47 | chart->addAxis(axisX, Qt::AlignBottom); | |
57 |
|
|
48 | chart->addAxis(axisY, Qt::AlignLeft); | |
58 |
|
|
49 | series->attachAxis(axisX); | |
59 |
|
|
50 | series->attachAxis(axisY); | |
60 | } |
|
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 | //![2] |
|
68 | //![2] | |
62 |
|
69 | |||
63 | //![3] |
|
70 | //![3] | |
64 | chart->legend()->hide(); |
|
71 | chart->legend()->hide(); | |
65 |
|
72 | chart->setTitle("Multiaxis chart example"); | ||
66 | chart->setTitle("Simple line chart example"); |
|
|||
67 | //![3] |
|
73 | //![3] | |
68 |
|
74 | |||
69 | //![4] |
|
75 | //![4] | |
@@ -81,3 +87,4 int main(int argc, char *argv[]) | |||||
81 |
|
87 | |||
82 | return a.exec(); |
|
88 | return a.exec(); | |
83 | } |
|
89 | } | |
|
90 |
General Comments 0
You need to be logged in to leave comments.
Login now