##// END OF EJS Templates
Fixed a compilation issue in axis example
Tero Ahola -
r501:6973892b62db
parent child
Show More
@@ -1,78 +1,78
1 1 #include <QApplication>
2 2 #include <QMainWindow>
3 3 #include <qchartview.h>
4 4 #include <qlineseries.h>
5 5 #include <qchart.h>
6 6 #include <qchartaxis.h>
7 7 #include <qchartaxiscategories.h>
8 8 #include <cmath>
9 9
10 10 QTCOMMERCIALCHART_USE_NAMESPACE
11 11
12 12 #define PI 3.14159265358979
13 13
14 14 int main(int argc, char *argv[])
15 15 {
16 16 QApplication a(argc, argv);
17 17
18 18 QMainWindow window;
19 19
20 20 QLineSeries* series0 = new QLineSeries();
21 21 QPen blue(Qt::blue);
22 22 blue.setWidth(3);
23 23 series0->setPen(blue);
24 24 QLineSeries* series1 = new QLineSeries();
25 25 QPen red(Qt::red);
26 26 red.setWidth(3);
27 27 series1->setPen(red);
28 28
29 29 int numPoints = 100;
30 30
31 31 for (int x = 0; x <= numPoints; ++x) {
32 32 series0->add(x, fabs(sin(PI/50*x)*100));
33 33 series1->add(x, fabs(cos(PI/50*x)*100));
34 34 }
35 35
36 36 QChartView* chartView = new QChartView(&window);
37 37
38 38 chartView->setRenderHint(QPainter::Antialiasing);
39 39 chartView->setChartTitle("This is custom axis chart example");
40 40 chartView->addSeries(series0);
41 41 chartView->addSeries(series1);
42 42
43 43 QLinearGradient backgroundGradient;
44 44 backgroundGradient.setColorAt(0.0, Qt::white);
45 45 backgroundGradient.setColorAt(1.0, QRgb(0xffff80));
46 46 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
47 47 chartView->setChartBackgroundBrush(backgroundGradient);
48 48
49 49 QChartAxis* axisX = chartView->axisX();
50 50 axisX->setLabelsAngle(45);
51 51 axisX->setGridPen(Qt::DashLine);
52 52
53 QChartAxisCategories& categoriesX = axisX->categories();
54 categoriesX.insert(0,"low");
55 categoriesX.insert(50,"medium");
56 categoriesX.insert(100,"High");
53 QChartAxisCategories *categoriesX = axisX->categories();
54 categoriesX->insert(0,"low");
55 categoriesX->insert(50,"medium");
56 categoriesX->insert(100,"High");
57 57
58 58 axisX->setMin(-10);
59 59 axisX->setMax(2200);
60 60
61 61 QChartAxis* axisY = chartView->axisY();
62 62 axisY->setLabelsAngle(45);
63 63 axisY->setShadesBrush(Qt::yellow);
64 64
65 QChartAxisCategories& categoriesY = axisY->categories();
66 categoriesY.insert(0,"low");
67 categoriesY.insert(50,"medium");
68 categoriesY.insert(100,"High");
65 QChartAxisCategories *categoriesY = axisY->categories();
66 categoriesY->insert(0,"low");
67 categoriesY->insert(50,"medium");
68 categoriesY->insert(100,"High");
69 69
70 70 axisY->setMin(-10);
71 71 axisY->setMax(200);
72 72
73 73 window.setCentralWidget(chartView);
74 74 window.resize(400, 300);
75 75 window.show();
76 76
77 77 return a.exec();
78 78 }
General Comments 0
You need to be logged in to leave comments. Login now