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