1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Charts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#include <QtCharts/QChartView>
31#include <QtCharts/QLineSeries>
32#include <QtCharts/QLogValueAxis>
33#include <QtCharts/QValueAxis>
34#include <QtWidgets/QApplication>
35#include <QtWidgets/QMainWindow>
36
37QT_CHARTS_USE_NAMESPACE
38
39int main(int argc, char *argv[])
40{
41 QApplication app(argc, argv);
42
43 //![1]
44 QLineSeries *series = new QLineSeries();
45 *series << QPointF(1.0, 1.0) << QPointF(2.0, 73.0) << QPointF(3.0, 268.0) << QPointF(4.0, 17.0)
46 << QPointF(5.0, 4325.0) << QPointF(6.0, 723.0);
47 //![1]
48
49 //![2]
50 QChart *chart = new QChart();
51 chart->addSeries(series);
52 chart->legend()->hide();
53 chart->setTitle("Logarithmic axis example");
54 //![2]
55
56 //![3]
57 QValueAxis *axisX = new QValueAxis();
58 axisX->setTitleText("Data point");
59 axisX->setLabelFormat("%i");
60 axisX->setTickCount(series->count());
61 chart->addAxis(axis: axisX, alignment: Qt::AlignBottom);
62 series->attachAxis(axis: axisX);
63
64 QLogValueAxis *axisY = new QLogValueAxis();
65 axisY->setTitleText("Values");
66 axisY->setLabelFormat("%g");
67 axisY->setBase(8.0);
68 axisY->setMinorTickCount(-1);
69 chart->addAxis(axis: axisY, alignment: Qt::AlignLeft);
70 series->attachAxis(axis: axisY);
71 //![3]
72
73 //![4]
74 QChartView *chartView = new QChartView(chart);
75 chartView->setRenderHint(hint: QPainter::Antialiasing);
76 //![4]
77
78 //![5]
79 QMainWindow window;
80 window.setCentralWidget(chartView);
81 window.resize(w: 800, h: 600);
82 window.show();
83 //![5]
84
85 return app.exec();
86}
87

source code of qtcharts/examples/charts/logvalueaxis/main.cpp