@@ -1,45 +1,45 | |||
|
1 | 1 | #include <QApplication> |
|
2 | 2 | #include <QMainWindow> |
|
3 | 3 | #include <qchartview.h> |
|
4 | 4 | #include <qxychartseries.h> |
|
5 | 5 | #include <qchart.h> |
|
6 | 6 | #include <cmath> |
|
7 | 7 | |
|
8 | 8 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
9 | 9 | |
|
10 | 10 | #define PI 3.14159265358979 |
|
11 | 11 | |
|
12 | 12 | int main(int argc, char *argv[]) |
|
13 | 13 | { |
|
14 | 14 | QApplication a(argc, argv); |
|
15 | 15 | |
|
16 | 16 | QMainWindow window; |
|
17 | 17 | |
|
18 | 18 | QXYChartSeries* series0 = QXYChartSeries::create(); |
|
19 | 19 | QPen blue(Qt::blue); |
|
20 | 20 | blue.setWidth(3); |
|
21 | 21 | series0->setPen(blue); |
|
22 | 22 | QXYChartSeries* series1 = QXYChartSeries::create(); |
|
23 | 23 | QPen red(Qt::red); |
|
24 | 24 | red.setWidth(3); |
|
25 | 25 | series1->setPen(red); |
|
26 | 26 | |
|
27 | 27 | int numPoints = 100; |
|
28 | 28 | |
|
29 | 29 | for (int x = 0; x <= numPoints; ++x) { |
|
30 | 30 | series0->add(x, abs(sin(PI/50*x)*100)); |
|
31 | 31 | series1->add(x, abs(cos(PI/50*x)*100)); |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | 34 | QChartView* chartView = new QChartView(&window); |
|
35 | 35 | chartView->setRenderHint(QPainter::Antialiasing); |
|
36 |
chartView->setTitle(" |
|
|
36 | chartView->setTitle("Basic line chart example"); | |
|
37 | 37 | chartView->addSeries(series0); |
|
38 | 38 | chartView->addSeries(series1); |
|
39 | 39 | |
|
40 | 40 | window.setCentralWidget(chartView); |
|
41 | 41 | window.resize(400, 300); |
|
42 | 42 | window.show(); |
|
43 | 43 | |
|
44 | 44 | return a.exec(); |
|
45 | 45 | } |
General Comments 0
You need to be logged in to leave comments.
Login now