##// END OF EJS Templates
Updated customchart example. Now it uses QIntervalsAxis
Marek Rosa -
r1702:f2951e50a7b8
parent child
Show More
@@ -22,8 +22,7
22 22 #include <QMainWindow>
23 23 #include <QChartView>
24 24 #include <QLineSeries>
25 #include <QValuesAxis>
26 #include <QBarCategoriesAxis>
25 #include <QIntervalsAxis>
27 26
28 27 QTCOMMERCIALCHART_USE_NAMESPACE
29 28
@@ -33,7 +32,7 int main(int argc, char *argv[])
33 32
34 33 //![1]
35 34 QLineSeries* series = new QLineSeries();
36 *series << QPointF(0, 0.6) << QPointF(0.5, 0.4) << QPointF(1, 2) << QPointF(1.5, 1.2) << QPointF(2, 1.0);
35 *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26);
37 36 QChart* chart = new QChart();
38 37 chart->legend()->hide();
39 38 chart->addSeries(series);
@@ -63,8 +62,8 int main(int argc, char *argv[])
63 62 //![2]
64 63
65 64 //![3]
66 QBarCategoriesAxis* axisX = new QBarCategoriesAxis();
67 QBarCategoriesAxis* axisY = new QBarCategoriesAxis();
65 QIntervalsAxis* axisX = new QIntervalsAxis();
66 QIntervalsAxis* axisY = new QIntervalsAxis();
68 67
69 68 // Customize axis label font
70 69 QFont labelsFont;
@@ -92,18 +91,22 int main(int argc, char *argv[])
92 91 //![3]
93 92
94 93 //![4]
95 axisX->append("low");
96 axisX->append("optimal");
97 axisX->append("high");
98 axisX->setRange("low","high");
99
100 axisY->append("slow");
101 axisY->append("med");
102 axisY->append("fast");
103 axisY->setRange("slow","fast");
94 axisX->append("low", 10);
95 axisX->append("optimal", 20);
96 axisX->append("high", 30);
97 axisX->setRange(0, 30);
98 // axisX->setRange("low","high");
99
100 axisY->append("slow", 10);
101 axisY->append("med", 20);
102 axisY->append("fast", 30);
103 axisY->setRange(0, 30);
104 // axisY->setRange("slow","fast");
104 105
105 106 chart->setAxisX(axisX, series);
106 107 chart->setAxisY(axisY, series);
108 axisX->setRange(0, 30);
109 axisY->setRange(0, 30);
107 110 //![4]
108 111
109 112 //![5]
@@ -100,12 +100,9 void ChartIntervalAxisY::updateGeometry()
100 100
101 101 if (i < ticksList.count())
102 102 labelItem->setPos(m_rect.left() - rect.width() - label_padding , layout[i] + (layout[i + 1] - layout[i]) / 2 - center.y());
103 // labelItem->setPos(layout[i] + (layout[i + 1] - layout[i]) / 2 - center.x(), m_rect.bottom() + label_padding);
104 103 else
105 104 labelItem->setPos(m_rect.left() - rect.width() - label_padding , layout[i]-center.y());
106 105
107 // labelItem->setPos(m_rect.left() - rect.width() - label_padding , layout[i]-center.y());
108
109 106 if(labelItem->pos().y()+rect.height()>height) {
110 107 labelItem->setVisible(false);
111 108 lineItem->setVisible(false);
General Comments 0
You need to be logged in to leave comments. Login now