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