@@ -33,13 +33,14 int main(int argc, char *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] |
@@ -51,7 +52,7 int main(int argc, char *argv[]) | |||
|
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); |
@@ -65,7 +66,7 int main(int argc, char *argv[]) | |||
|
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 |
@@ -22,9 +22,9 | |||
|
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 | |
@@ -32,38 +32,44 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); | |
|
37 | QValueAxis *axisX = new QValueAxis; | |
|
38 | axisX->setTickCount(10); | |
|
47 | 39 | |
|
48 | axisX = new QValueAxis; | |
|
49 | axisX->setTickCount(7 + i); | |
|
50 | axisX->setLinePenColor(series->pen().color()); | |
|
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); | |
|
51 | 43 | |
|
52 |
|
|
|
53 | axisY->setTickCount(7 + i); | |
|
44 | QValueAxis *axisY = new QValueAxis; | |
|
54 | 45 |
|
|
55 | 46 | |
|
56 |
|
|
|
57 |
|
|
|
47 | chart->addAxis(axisX, Qt::AlignBottom); | |
|
48 | chart->addAxis(axisY, Qt::AlignLeft); | |
|
58 | 49 |
|
|
59 | 50 |
|
|
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 | 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] |
@@ -81,3 +87,4 int main(int argc, char *argv[]) | |||
|
81 | 87 | |
|
82 | 88 | return a.exec(); |
|
83 | 89 | } |
|
90 |
General Comments 0
You need to be logged in to leave comments.
Login now