/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Charts module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \example candlestickchart
    \title Candlestick Chart Example
    \ingroup qtcharts_examples

    \brief Shows how to create a candlestick chart.

    \image examples_candlestickchart.png

    \include examples-run.qdocinc

    \section1 Creating Candlestick Charts

    To display a candlestick chart, we start by creating QCandlestickSeries to handle daily data. We
    are also specifying custom increasing and decreasing body colors.

    \snippet candlestickchart/main.cpp 1

    QFile is used for accessing a text file where the non-continuous data is kept. The
    \c CandlestickDataReader is an auxiliary class for reading the text file and finding the open,
    high, low, close, and timestamp values from the data. The \c CandlestickDataReader is explained
    in more detail later. The method \c readCandlestickSet() reads the values and sets them to the
    QCandlestickSet item which the method returns for the caller. The returned QCandlestickSet item
    is added to the series. We are also saving custom categories list for later use.

    \snippet candlestickchart/main.cpp 2

    Below, a new QChart instance is created and the previously created series object is added to it.
    We also define a title, and set an animation as
    \l {QChart::AnimationOption} {QChart::SeriesAnimation}.

    \snippet candlestickchart/main.cpp 3

    Here, we ask the chart to create default axes for our presentation. Then, we set custom
    categories for the horizontal axis by querying the pointer for the axis from the chart, and then
    setting the categories from previously saved custom categories list. We also set the range for
    the vertical axis by querying the pointer for the axis from the chart, and then setting the min
    and max values for that axis.

    \snippet candlestickchart/main.cpp 4

    Below, we set the legend to be visible and place it at the bottom of the chart.

    \snippet candlestickchart/main.cpp 5

    Finally, we add the chart onto a view. We also turn on the antialiasing for the chartView.

    \snippet candlestickchart/main.cpp 6

    The chart is ready to be shown. We set the chart to be the central widget of the window. We also
    set the size for the chart window and show it.

    \snippet candlestickchart/main.cpp 7

    Here, the method \c readCandlestickSet() is explained in detail. First, a line is read from
    the file, rejecting any lines starting with # as they are considered comment lines.

    \snippet candlestickchart/candlestickdatareader.cpp 1

    In the file, the data is arranged as a space-delimited sequence of numbers. On this snippet the
    line is split into single number strings which are stored in a QStringList.

    \snippet candlestickchart/candlestickdatareader.cpp 2

    To select values from the continuous data, following code is used. The values in a \c strList
    are stored in the following order: timestamp, open, high, low, close.

    \snippet candlestickchart/candlestickdatareader.cpp 3

    Finally, the following snippet shows how to create a new QCandlestickSet and provide it with all
    the necessary values.

    \snippet candlestickchart/candlestickdatareader.cpp 4
*/
