@@ -15,7 +15,7 | |||
|
15 | 15 | Then we customize the axes. |
|
16 | 16 | \snippet ../examples/customchart/main.cpp 3 |
|
17 | 17 | |
|
18 | And the axis label values and ranges. | |
|
18 | And the axis label values and ranges. Once the axes are ready we set them to be used by the chart. | |
|
19 | 19 | \snippet ../examples/customchart/main.cpp 4 |
|
20 | 20 | |
|
21 | 21 | Finally we create a view containing the chart. |
@@ -23,6 +23,7 | |||
|
23 | 23 | #include <QChartView> |
|
24 | 24 | #include <QLineSeries> |
|
25 | 25 | #include <QValuesAxis> |
|
26 | #include <QBarCategoriesAxis> | |
|
26 | 27 | |
|
27 | 28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | 29 | |
@@ -32,11 +33,10 int main(int argc, char *argv[]) | |||
|
32 | 33 | |
|
33 | 34 | //![1] |
|
34 | 35 | QLineSeries* series = new QLineSeries(); |
|
35 |
*series << QPointF(0, 6) << QPointF( |
|
|
36 | *series << QPointF(0, 6) << QPointF(0.5, 4) << QPointF(1, 8) << QPointF(1.5, 4) << QPointF(2, 3); | |
|
36 | 37 | QChart* chart = new QChart(); |
|
37 | 38 | chart->legend()->hide(); |
|
38 | 39 | chart->addSeries(series); |
|
39 | chart->createDefaultAxes(); | |
|
40 | 40 | //![1] |
|
41 | 41 | |
|
42 | 42 | //![2] |
@@ -63,8 +63,8 int main(int argc, char *argv[]) | |||
|
63 | 63 | //![2] |
|
64 | 64 | |
|
65 | 65 | //![3] |
|
66 | QValuesAxis* axisX = qobject_cast<QValuesAxis *>(chart->axisX()); | |
|
67 |
QValuesAxis* axisY = |
|
|
66 | QBarCategoriesAxis* axisX = new QBarCategoriesAxis; | |
|
67 | QValuesAxis* axisY = new QValuesAxis; | |
|
68 | 68 | |
|
69 | 69 | // Customize axis label font |
|
70 | 70 | QFont labelsFont; |
@@ -92,20 +92,15 int main(int argc, char *argv[]) | |||
|
92 | 92 | //![3] |
|
93 | 93 | |
|
94 | 94 | //![4] |
|
95 | // QAxisCategories* categoriesX = chart->axisX()->categories(); | |
|
96 | // categoriesX->insert(1,"low"); | |
|
97 | // categoriesX->insert(5,"optimal"); | |
|
98 | // categoriesX->insert(10,"high"); | |
|
99 | ||
|
100 | // QAxisCategories* categoriesY = chart->axisY()->categories(); | |
|
101 | // categoriesY->insert(1,"slow"); | |
|
102 | // categoriesY->insert(5,"med"); | |
|
103 | // categoriesY->insert(10,"fast"); | |
|
104 | ||
|
105 | axisX->setRange(0,10); | |
|
106 | axisX->setTicksCount(4); | |
|
95 | axisX->append("low"); | |
|
96 | axisX->append("optimal"); | |
|
97 | axisX->append("high"); | |
|
98 | ||
|
99 | axisX->setRange("low","high"); | |
|
107 | 100 | axisY->setRange(0,10); |
|
108 | 101 | axisY->setTicksCount(4); |
|
102 | chart->setAxisX(axisX, series); | |
|
103 | chart->setAxisY(axisY, series); | |
|
109 | 104 | //![4] |
|
110 | 105 | |
|
111 | 106 | //![5] |
General Comments 0
You need to be logged in to leave comments.
Login now