// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \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
*/
