2018-11-25 21:53:26 +08:00
/*
2019-01-12 23:01:55 +08:00
Copyright ( c ) 2008 - 2019 Jan W . Krieger ( < jan @ jkrieger . de > )
2018-11-25 21:53:26 +08:00
This software is free software : you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License ( LGPL ) as published by
2019-02-08 00:24:46 +08:00
the Free Software Foundation , either version 2.1 of the License , or
2018-11-25 21:53:26 +08:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Lesser General Public License ( LGPL ) for more details .
You should have received a copy of the GNU Lesser General Public License ( LGPL )
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# include <QString>
# include <QPainter>
# include <QPair>
2018-11-26 03:25:44 +08:00
# include "jkqtplottertools/jkqtptools.h"
# include "jkqtplottertools/jkqtp_imexport.h"
2018-12-19 00:13:18 +08:00
# include "jkqtplottertools/jkqtpimagetools.h"
# include "jkqtplotter/jkqtpgraphsbase.h"
2018-11-25 21:53:26 +08:00
2018-12-19 00:13:18 +08:00
# ifndef jkqtpgraphsboxplot_H
# define jkqtpgraphsboxplot_H
2018-11-25 21:53:26 +08:00
/*! \brief This implements vertical <a href="http://en.wikipedia.org/wiki/Box_plot">boxplots</a>
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_statgraphs
2018-11-25 21:53:26 +08:00
2019-01-20 23:15:10 +08:00
The x position is given in posColumn . All other data are given in the medianColumn , minColumn , maxColumn ,
2018-11-25 21:53:26 +08:00
percentile25Column and percentile75Column .
\ image html plot_boxplotvertical . png
2019-01-20 23:15:10 +08:00
The different features of a boxplot are :
\ image html boxplots . png
\ note There are additional classes to draw a single boxplot element : JKQTPBoxplotHorizontalElement and JKQTPBoxplotVerticalElement .
In these you can set the data values , as they are NOT drawn from a data column . This can be useful , if you e . g . want to
draw the statistical properties of a distribution .
\ section BoxplotOutliers Outliers
If you also want to display outliers , as shown here with circles :
\ image html boxplot_outliers . png
You need to add them as ( x , y ) - pairs to the datastore and add a separate JKQTPXYLineGraph that shows these . See \ ref JKQTPlotterBoxplotsGraphs for details . Here is an example code - snippet :
\ code
// 4. create a graph of vertical boxplots:
JKQTPBoxplotVerticalGraph * graph = new JKQTPBoxplotVerticalGraph ( & plot ) ;
2019-01-26 20:00:40 +08:00
graph - > setPosColumn ( columnPOS ) ;
graph - > setMinColumn ( columnMIN ) ;
graph - > setPercentile25Column ( columnQ25 ) ;
graph - > setMedianColumn ( columnMEDIAN ) ;
graph - > setMeanColumn ( columnMEAN ) ;
graph - > setPercentile75Column ( columnQ75 ) ;
graph - > setMaxColumn ( columnMAX ) ;
graph - > setTitle ( " vertical Boxplots " ) ;
2019-01-20 23:15:10 +08:00
// 5. outliers need to be drawn separately
JKQTPXYLineGraph * graphOutliers = new JKQTPXYLineGraph ( & plot ) ;
2019-01-26 20:00:40 +08:00
graphOutliers - > setXColumn ( columnOUTLIERSX ) ;
graphOutliers - > setYColumn ( columnOUTLIERSY ) ;
graphOutliers - > setTitle ( " outliers " ) ;
2019-01-20 23:15:10 +08:00
// make the color a darker shade of the color of graph
2019-01-26 20:00:40 +08:00
graphOutliers - > setColor ( graph - > getColor ( ) . darker ( ) ) ;
graphOutliers - > setFillColor ( QColor ( " white " ) ) ;
2019-01-20 23:15:10 +08:00
// draw outliers as small circles, without lines
2019-04-22 19:27:50 +08:00
graphOutliers - > setSymbolType ( JKQTPCircle ) ;
2019-01-26 20:00:40 +08:00
graphOutliers - > setDrawLine ( false ) ;
graphOutliers - > setSymbolSize ( 7 ) ;
2019-01-20 23:15:10 +08:00
\ endcode
\ see \ ref JKQTPlotterBoxplotsGraphs
2018-11-25 21:53:26 +08:00
*/
2019-02-03 21:04:48 +08:00
class JKQTP_LIB_EXPORT JKQTPBoxplotVerticalGraph : public JKQTPGraph {
2018-11-25 21:53:26 +08:00
Q_OBJECT
public :
enum DataSortOrder {
Unsorted = 0 ,
Sorted = 1
} ;
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTPBoxplotVerticalGraph ( JKQTBasePlotter * parent = nullptr ) ;
2018-11-25 21:53:26 +08:00
/** \brief class constructor */
2019-01-20 23:15:10 +08:00
JKQTPBoxplotVerticalGraph ( JKQTPlotter * parent ) ;
2018-11-25 21:53:26 +08:00
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw ( JKQTPEnhancedPainter & painter ) ;
/** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) ;
/** \brief returns the color to be used for the key label */
2019-04-22 19:27:50 +08:00
virtual QColor getKeyLabelColor ( ) const override ;
2018-11-25 21:53:26 +08:00
/** \brief get the maximum and minimum x-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
2018-12-28 05:52:00 +08:00
virtual bool getXMinMax ( double & minx , double & maxx , double & smallestGreaterZero ) override ;
2018-11-25 21:53:26 +08:00
/** \brief get the maximum and minimum y-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
2018-12-28 05:52:00 +08:00
virtual bool getYMinMax ( double & miny , double & maxy , double & smallestGreaterZero ) override ;
2018-11-25 21:53:26 +08:00
2019-01-20 17:49:29 +08:00
/** \copydoc JKQTPGraph::usesColumn() */
2018-12-28 05:52:00 +08:00
virtual bool usesColumn ( int c ) const override ;
2018-11-25 21:53:26 +08:00
2019-02-08 00:24:46 +08:00
/*! \copydoc sortData
\ see see sortData for details */
2019-02-03 21:04:48 +08:00
inline virtual void setDataSortOrder ( const DataSortOrder & __value )
2019-01-10 04:23:24 +08:00
{
this - > sortData = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc sortData
\ see see sortData for details */
2019-02-03 21:04:48 +08:00
inline virtual DataSortOrder getDataSortOrder ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > sortData ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property sortData ( \copybrief sortData ) to the specified \a __value. \details Description of the parameter sortData is: <BLOCKQUOTE>\copydoc sortData </BLOCKQUOTE> \see sortData for more information */
2019-02-03 21:04:48 +08:00
void setDataSortOrder ( int __value ) ;
2019-02-08 00:24:46 +08:00
/*! \copydoc posColumn
\ see see posColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual void setPosColumn ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > posColumn = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc posColumn
\ see see posColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual int getPosColumn ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > posColumn ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property posColumn ( \copybrief posColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter posColumn is : < BLOCKQUOTE > \ copydoc posColumn < / BLOCKQUOTE >
2019-02-08 00:24:46 +08:00
\ see posColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setPosColumn ( size_t __value ) { this - > posColumn = static_cast < int > ( __value ) ; }
2019-02-08 00:24:46 +08:00
/*! \copydoc medianColumn
\ see see medianColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMedianColumn ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > medianColumn = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc medianColumn
\ see see medianColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual int getMedianColumn ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > medianColumn ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property medianColumn ( \copybrief medianColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter medianColumn is : < BLOCKQUOTE > \ copydoc medianColumn < / BLOCKQUOTE >
2019-02-08 00:24:46 +08:00
\ see medianColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setMedianColumn ( size_t __value ) { this - > medianColumn = static_cast < int > ( __value ) ; }
2019-02-08 00:24:46 +08:00
/*! \copydoc meanColumn
\ see see meanColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMeanColumn ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > meanColumn = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanColumn
\ see see meanColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual int getMeanColumn ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > meanColumn ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property meanColumn ( \copybrief meanColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter meanColumn is : < BLOCKQUOTE > \ copydoc meanColumn < / BLOCKQUOTE >
2019-02-08 00:24:46 +08:00
\ see meanColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setMeanColumn ( size_t __value ) { this - > meanColumn = static_cast < int > ( __value ) ; }
2019-02-08 00:24:46 +08:00
/*! \copydoc minColumn
\ see see minColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMinColumn ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > minColumn = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc minColumn
\ see see minColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual int getMinColumn ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > minColumn ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property minColumn ( \copybrief minColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter minColumn is : < BLOCKQUOTE > \ copydoc minColumn < / BLOCKQUOTE >
2019-02-08 00:24:46 +08:00
\ see minColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setMinColumn ( size_t __value ) { this - > minColumn = static_cast < int > ( __value ) ; }
2019-02-08 00:24:46 +08:00
/*! \copydoc maxColumn
\ see see maxColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMaxColumn ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > maxColumn = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc maxColumn
\ see see maxColumn for details */
2019-01-26 20:00:40 +08:00
inline virtual int getMaxColumn ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > maxColumn ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property maxColumn ( \copybrief maxColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter maxColumn is : < BLOCKQUOTE > \ copydoc maxColumn < / BLOCKQUOTE >
2019-02-08 00:24:46 +08:00
\ see maxColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setMaxColumn ( size_t __value ) { this - > maxColumn = static_cast < int > ( __value ) ; }
2019-02-08 00:24:46 +08:00
/*! \copydoc percentile25Column
\ see see percentile25Column for details */
2019-01-26 20:00:40 +08:00
inline virtual void setPercentile25Column ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > percentile25Column = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc percentile25Column
\ see see percentile25Column for details */
2019-01-26 20:00:40 +08:00
inline virtual int getPercentile25Column ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > percentile25Column ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property percentile25Column ( \copybrief percentile25Column ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter percentile25Column is : < BLOCKQUOTE > \ copydoc percentile25Column < / BLOCKQUOTE >
2019-02-08 00:24:46 +08:00
\ see percentile25Column for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setPercentile25Column ( size_t __value ) { this - > percentile25Column = static_cast < int > ( __value ) ; }
2019-02-08 00:24:46 +08:00
/*! \copydoc percentile75Column
\ see see percentile75Column for details */
2019-01-26 20:00:40 +08:00
inline virtual void setPercentile75Column ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > percentile75Column = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc percentile75Column
\ see see percentile75Column for details */
2019-01-26 20:00:40 +08:00
inline virtual int getPercentile75Column ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > percentile75Column ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property percentile75Column ( \copybrief percentile75Column ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter percentile75Column is : < BLOCKQUOTE > \ copydoc percentile75Column < / BLOCKQUOTE >
2019-02-08 00:24:46 +08:00
\ see percentile75Column for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setPercentile75Column ( size_t __value ) { this - > percentile75Column = static_cast < int > ( __value ) ; }
2019-02-08 00:24:46 +08:00
/*! \copydoc color
\ see see color for details */
2019-01-26 20:00:40 +08:00
inline virtual void setColor ( const QColor & __value )
2019-01-10 04:23:24 +08:00
{
this - > color = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc color
\ see see color for details */
2019-01-26 20:00:40 +08:00
inline virtual QColor getColor ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > color ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc fillColor
\ see see fillColor for details */
2019-01-26 20:00:40 +08:00
inline virtual void setFillColor ( const QColor & __value )
2019-01-10 04:23:24 +08:00
{
this - > fillColor = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc fillColor
\ see see fillColor for details */
2019-01-26 20:00:40 +08:00
inline virtual QColor getFillColor ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > fillColor ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc whiskerStyle
\ see see whiskerStyle for details */
2019-01-26 20:00:40 +08:00
inline virtual void setWhiskerStyle ( const Qt : : PenStyle & __value )
2019-01-10 04:23:24 +08:00
{
this - > whiskerStyle = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc whiskerStyle
\ see see whiskerStyle for details */
2019-01-26 20:00:40 +08:00
inline virtual Qt : : PenStyle getWhiskerStyle ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > whiskerStyle ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc fillStyle
\ see see fillStyle for details */
2019-01-26 20:00:40 +08:00
inline virtual void setFillStyle ( const Qt : : BrushStyle & __value )
2019-01-10 04:23:24 +08:00
{
this - > fillStyle = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc fillStyle
\ see see fillStyle for details */
2019-01-26 20:00:40 +08:00
inline virtual Qt : : BrushStyle getFillStyle ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > fillStyle ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc lineWidth
\ see see lineWidth for details */
2019-01-26 03:16:04 +08:00
inline virtual void setLineWidth ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > lineWidth = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc lineWidth
\ see see lineWidth for details */
2019-01-26 03:16:04 +08:00
inline virtual double getLineWidth ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > lineWidth ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc boxWidth
\ see see boxWidth for details */
2019-01-26 20:00:40 +08:00
inline virtual void setBoxWidth ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > boxWidth = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc boxWidth
\ see see boxWidth for details */
2019-01-26 20:00:40 +08:00
inline virtual double getBoxWidth ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > boxWidth ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbol
\ see see meanSymbol for details */
2019-04-22 19:27:50 +08:00
inline virtual void setMeanSymbol ( JKQTPGraphSymbols __value )
2019-01-10 04:23:24 +08:00
{
this - > meanSymbol = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbol
\ see see meanSymbol for details */
2019-01-26 20:00:40 +08:00
inline virtual JKQTPGraphSymbols getMeanSymbol ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > meanSymbol ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbolWidth
\ see see meanSymbolWidth for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMeanSymbolWidth ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > meanSymbolWidth = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbolWidth
\ see see meanSymbolWidth for details */
2019-01-26 20:00:40 +08:00
inline virtual double getMeanSymbolWidth ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > meanSymbolWidth ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbolSize
\ see see meanSymbolSize for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMeanSymbolSize ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > meanSymbolSize = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbolSize
\ see see meanSymbolSize for details */
2019-01-26 20:00:40 +08:00
inline virtual double getMeanSymbolSize ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > meanSymbolSize ;
}
2018-11-25 21:53:26 +08:00
protected :
2019-01-26 03:16:04 +08:00
/** \brief which plot style to use from the parent plotter (via JKQTBasePlotter::getPlotStyle() and JKQTBasePlotter::getNextStyle() ) */
2018-11-25 21:53:26 +08:00
int parentPlotStyle ;
/** \brief the column that contains the x-component of the datapoints */
int posColumn ;
/** \brief the column that contains the median-component of the datapoints */
int medianColumn ;
/** \brief the column that contains the median-component of the datapoints. \note This column is strictly optional. */
int meanColumn ;
/** \brief the column that contains the minimum-component of the datapoints */
int minColumn ;
/** \brief the column that contains the maximum-component of the datapoints */
int maxColumn ;
/** \brief the column that contains the 25% percentile-component of the datapoints */
int percentile25Column ;
/** \brief the column that contains the 75% percentile-component of the datapoints */
int percentile75Column ;
/** \brief color of the lines */
QColor color ;
/** \brief color of the box fill */
QColor fillColor ;
/** \brief fill style for the box */
Qt : : BrushStyle fillStyle ;
/** \brief linestyle of the whisker lines */
Qt : : PenStyle whiskerStyle ;
2019-01-20 23:15:10 +08:00
/** \brief width (pt) of the graph, given in pt */
2018-11-25 21:53:26 +08:00
double lineWidth ;
/** \brief width of box in percent of distance between the current two posColumn values
* if we only plot one box & whiskers then this is the width in plot coordinates */
double boxWidth ;
/** \brief which symbol to use for the mean */
2019-01-20 17:49:29 +08:00
JKQTPGraphSymbols meanSymbol ;
2019-01-20 23:15:10 +08:00
/** \brief size (diameter in pt) of the symbol for the mean */
2018-11-25 21:53:26 +08:00
double meanSymbolSize ;
2019-01-20 23:15:10 +08:00
/** \brief width (in pt) of the lines used to plot the symbol for the mean */
2018-11-25 21:53:26 +08:00
double meanSymbolWidth ;
QBrush getBrush ( JKQTPEnhancedPainter & painter ) const ;
QPen getLinePen ( JKQTPEnhancedPainter & painter ) const ;
/** \brief if \c !=Unsorted, the data is sorted before plotting */
DataSortOrder sortData ;
/** \brief this array contains the order of indices, in which to access the data in the data columns */
QVector < int > sortedIndices ;
2018-12-28 05:52:00 +08:00
virtual void intSortData ( ) ;
2018-11-25 21:53:26 +08:00
inline int getDataIndex ( int i ) {
if ( sortData = = Unsorted ) return i ;
return sortedIndices . value ( i , i ) ;
}
} ;
/*! \brief This implements horizontal <a href="http://en.wikipedia.org/wiki/Box_plot">boxplots</a>
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_statgraphs
2018-11-25 21:53:26 +08:00
the x position is given in posColumn . All other data are given in the medianColumn , minColumn , maxColumn ,
percentile25Column and percentile75Column .
2019-01-20 17:49:29 +08:00
\ image html plot_boxplothoricontal . png
2019-01-20 23:15:10 +08:00
\ note See the documentation of JKQTPBoxplotVerticalGraph for details on the properties of this class !
\ see JKQTPBoxplotVerticalGraph \ ref JKQTPlotterBoxplotsGraphs
2018-11-25 21:53:26 +08:00
*/
2019-02-03 21:04:48 +08:00
class JKQTP_LIB_EXPORT JKQTPBoxplotHorizontalGraph : public JKQTPBoxplotVerticalGraph {
2018-11-25 21:53:26 +08:00
Q_OBJECT
public :
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTPBoxplotHorizontalGraph ( JKQTBasePlotter * parent = nullptr ) ;
2019-01-20 23:15:10 +08:00
JKQTPBoxplotHorizontalGraph ( JKQTPlotter * parent ) ;
2018-11-25 21:53:26 +08:00
/** \brief plots the graph to the plotter object specified as parent */
2018-12-28 05:52:00 +08:00
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
2018-11-25 21:53:26 +08:00
/** \brief plots a key marker inside the specified rectangle \a rect */
2018-12-28 05:52:00 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
2018-11-25 21:53:26 +08:00
/** \brief get the maximum and minimum x-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
2018-12-28 05:52:00 +08:00
virtual bool getXMinMax ( double & minx , double & maxx , double & smallestGreaterZero ) override ;
2018-11-25 21:53:26 +08:00
/** \brief get the maximum and minimum y-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
2018-12-28 05:52:00 +08:00
virtual bool getYMinMax ( double & miny , double & maxy , double & smallestGreaterZero ) override ;
2018-11-25 21:53:26 +08:00
} ;
2019-01-20 23:15:10 +08:00
/*! \brief This implements a single vertical <a href="http://en.wikipedia.org/wiki/Box_plot">boxplot</a> as a "geometric element",
where the data is directly given to the object and not stored in a column , as in JKQTPBoxplotVerticalGraph
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_statgraphs
2019-01-20 17:49:29 +08:00
\ ingroup jkqtplotter_geoplots
2018-11-25 21:53:26 +08:00
2019-01-20 23:15:10 +08:00
\ image html plot_boxplotverticalelement . png
2018-11-25 21:53:26 +08:00
the x position is given in posColumn . All other data are given in the median , min , max ,
percentile25 and percentile75 .
2019-01-20 23:15:10 +08:00
The different features of a boxplot are :
\ image html boxplots . png
2018-11-25 21:53:26 +08:00
*/
2019-02-03 21:04:48 +08:00
class JKQTP_LIB_EXPORT JKQTPBoxplotVerticalElement : public JKQTPPlotObject {
2018-11-25 21:53:26 +08:00
Q_OBJECT
public :
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTPBoxplotVerticalElement ( JKQTBasePlotter * parent = nullptr ) ;
2018-11-25 21:53:26 +08:00
/** \brief class constructor */
2019-01-20 23:15:10 +08:00
JKQTPBoxplotVerticalElement ( JKQTPlotter * parent ) ;
2018-11-25 21:53:26 +08:00
/** \brief plots the graph to the plotter object specified as parent */
2018-12-28 05:52:00 +08:00
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
2018-11-25 21:53:26 +08:00
/** \brief plots a key marker inside the specified rectangle \a rect */
2018-12-28 05:52:00 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
2018-11-25 21:53:26 +08:00
/** \brief returns the color to be used for the key label */
2019-04-22 19:27:50 +08:00
virtual QColor getKeyLabelColor ( ) const override ;
2018-11-25 21:53:26 +08:00
/** \brief get the maximum and minimum x-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
2018-12-28 05:52:00 +08:00
virtual bool getXMinMax ( double & minx , double & maxx , double & smallestGreaterZero ) override ;
2018-11-25 21:53:26 +08:00
/** \brief get the maximum and minimum y-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
2018-12-28 05:52:00 +08:00
virtual bool getYMinMax ( double & miny , double & maxy , double & smallestGreaterZero ) override ;
2018-11-25 21:53:26 +08:00
2019-02-08 00:24:46 +08:00
/*! \copydoc pos
\ see see pos for details */
2019-01-26 20:00:40 +08:00
inline virtual void setPos ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > pos = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc pos
\ see see pos for details */
2019-01-26 20:00:40 +08:00
inline virtual double getPos ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > pos ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc median
\ see see median for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMedian ( double __value )
2019-01-10 04:23:24 +08:00
{
if ( this - > median ! = __value ) {
this - > median = __value ;
drawMedian = true ;
}
}
2019-02-08 00:24:46 +08:00
/*! \copydoc median
\ see see median for details */
2019-01-26 20:00:40 +08:00
inline virtual double getMedian ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > median ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc mean
\ see see mean for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMean ( double __value )
2019-01-10 04:23:24 +08:00
{
if ( this - > mean ! = __value ) {
this - > mean = __value ;
drawMean = true ;
}
}
2019-02-08 00:24:46 +08:00
/*! \copydoc mean
\ see see mean for details */
2019-01-26 20:00:40 +08:00
inline virtual double getMean ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > mean ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc min
\ see see min for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMin ( double __value )
2019-01-10 04:23:24 +08:00
{
if ( this - > min ! = __value ) {
this - > min = __value ;
drawMinMax = true ;
}
}
2019-02-08 00:24:46 +08:00
/*! \copydoc min
\ see see min for details */
2019-01-26 20:00:40 +08:00
inline virtual double getMin ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > min ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc max
\ see see max for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMax ( double __value )
2019-01-10 04:23:24 +08:00
{
if ( this - > max ! = __value ) {
this - > max = __value ;
drawMinMax = true ;
}
}
2019-02-08 00:24:46 +08:00
/*! \copydoc max
\ see see max for details */
2019-01-26 20:00:40 +08:00
inline virtual double getMax ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > max ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc percentile25
\ see see percentile25 for details */
2019-01-26 20:00:40 +08:00
inline virtual void setPercentile25 ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > percentile25 = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc percentile25
\ see see percentile25 for details */
2019-01-26 20:00:40 +08:00
inline virtual double getPercentile25 ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > percentile25 ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc percentile75
\ see see percentile75 for details */
2019-01-26 20:00:40 +08:00
inline virtual void setPercentile75 ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > percentile75 = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc percentile75
\ see see percentile75 for details */
2019-01-26 20:00:40 +08:00
inline virtual double getPercentile75 ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > percentile75 ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc color
\ see see color for details */
2019-01-26 20:00:40 +08:00
inline virtual void setColor ( const QColor & __value )
2019-01-10 04:23:24 +08:00
{
this - > color = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc color
\ see see color for details */
2019-01-26 20:00:40 +08:00
inline virtual QColor getColor ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > color ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc fillColor
\ see see fillColor for details */
2019-01-26 20:00:40 +08:00
inline virtual void setFillColor ( const QColor & __value )
2019-01-10 04:23:24 +08:00
{
this - > fillColor = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc fillColor
\ see see fillColor for details */
2019-01-26 20:00:40 +08:00
inline virtual QColor getFillColor ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > fillColor ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc whiskerStyle
\ see see whiskerStyle for details */
2019-01-26 20:00:40 +08:00
inline virtual void setWhiskerStyle ( const Qt : : PenStyle & __value )
2019-01-10 04:23:24 +08:00
{
this - > whiskerStyle = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc whiskerStyle
\ see see whiskerStyle for details */
2019-01-26 20:00:40 +08:00
inline virtual Qt : : PenStyle getWhiskerStyle ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > whiskerStyle ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc lineWidth
\ see see lineWidth for details */
2019-01-26 03:16:04 +08:00
inline virtual void setLineWidth ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > lineWidth = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc lineWidth
\ see see lineWidth for details */
2019-01-26 03:16:04 +08:00
inline virtual double getLineWidth ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > lineWidth ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc boxWidth
\ see see boxWidth for details */
2019-01-26 20:00:40 +08:00
inline virtual void setBoxWidth ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > boxWidth = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc boxWidth
\ see see boxWidth for details */
2019-01-26 20:00:40 +08:00
inline virtual double getBoxWidth ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > boxWidth ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbol
\ see see meanSymbol for details */
2019-04-22 19:27:50 +08:00
inline virtual void setMeanSymbol ( JKQTPGraphSymbols __value )
2019-01-10 04:23:24 +08:00
{
this - > meanSymbol = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbol
\ see see meanSymbol for details */
2019-01-26 20:00:40 +08:00
inline virtual JKQTPGraphSymbols getMeanSymbol ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > meanSymbol ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbolWidth
\ see see meanSymbolWidth for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMeanSymbolWidth ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > meanSymbolWidth = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbolWidth
\ see see meanSymbolWidth for details */
2019-01-26 20:00:40 +08:00
inline virtual double getMeanSymbolWidth ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > meanSymbolWidth ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbolSize
\ see see meanSymbolSize for details */
2019-01-26 20:00:40 +08:00
inline virtual void setMeanSymbolSize ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > meanSymbolSize = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc meanSymbolSize
\ see see meanSymbolSize for details */
2019-01-26 20:00:40 +08:00
inline virtual double getMeanSymbolSize ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > meanSymbolSize ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc drawMean
\ see see drawMean for details */
2019-01-26 20:00:40 +08:00
inline virtual void setDrawMean ( bool __value )
2019-01-10 04:23:24 +08:00
{
this - > drawMean = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc drawMean
\ see see drawMean for details */
2019-01-26 20:00:40 +08:00
inline virtual bool getDrawMean ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > drawMean ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc drawMedian
\ see see drawMedian for details */
2019-01-26 20:00:40 +08:00
inline virtual void setDrawMedian ( bool __value )
2019-01-10 04:23:24 +08:00
{
this - > drawMedian = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc drawMedian
\ see see drawMedian for details */
2019-01-26 20:00:40 +08:00
inline virtual bool getDrawMedian ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > drawMedian ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc drawMinMax
\ see see drawMinMax for details */
2019-01-26 20:00:40 +08:00
inline virtual void setDrawMinMax ( bool __value )
2019-01-10 04:23:24 +08:00
{
this - > drawMinMax = __value ;
}
2019-02-08 00:24:46 +08:00
/*! \copydoc drawMinMax
\ see see drawMinMax for details */
2019-01-26 20:00:40 +08:00
inline virtual bool getDrawMinMax ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > drawMinMax ;
}
2018-11-25 21:53:26 +08:00
protected :
2019-01-26 03:16:04 +08:00
/** \brief which plot style to use from the parent plotter (via JKQTBasePlotter::getPlotStyle() and JKQTBasePlotter::getNextStyle() ) */
2018-11-25 21:53:26 +08:00
int parentPlotStyle ;
/** \brief the column that contains the x-component of the datapoints */
double pos ;
/** \brief the column that contains the median-component of the datapoints */
double median ;
/** \brief the column that contains the median-component of the datapoints. \note This column is strictly optional. */
double mean ;
/** \brief indicates whether to draw the mean */
bool drawMean ;
/** \brief indicates whether to draw the median */
bool drawMedian ;
/** \brief indicates whether to draw the percentiles */
bool drawMinMax ;
/** \brief the column that contains the minimum-component of the datapoints */
double min ;
/** \brief the column that contains the maximum-component of the datapoints */
double max ;
/** \brief the column that contains the 25% percentile-component of the datapoints */
double percentile25 ;
/** \brief the column that contains the 75% percentile-component of the datapoints */
double percentile75 ;
/** \brief color of the lines */
QColor color ;
/** \brief color of the box fill */
QColor fillColor ;
/** \brief fill style for the box */
Qt : : BrushStyle fillStyle ;
/** \brief linestyle of the whisker lines */
Qt : : PenStyle whiskerStyle ;
/** \brief width (pixels) of the graph */
double lineWidth ;
2019-01-20 23:15:10 +08:00
/** \brief width of box, given in pt */
2018-11-25 21:53:26 +08:00
double boxWidth ;
/** \brief which symbol to use for the mean */
2019-01-20 17:49:29 +08:00
JKQTPGraphSymbols meanSymbol ;
2019-01-20 23:15:10 +08:00
/** \brief size (diameter in pt) of the symbol for the mean */
2018-11-25 21:53:26 +08:00
double meanSymbolSize ;
2019-01-20 23:15:10 +08:00
/** \brief width (in pt) of the lines used to plot the symbol for the mean */
2018-11-25 21:53:26 +08:00
double meanSymbolWidth ;
QBrush getBrush ( JKQTPEnhancedPainter & painter ) const ;
QPen getLinePen ( JKQTPEnhancedPainter & painter ) const ;
} ;
/*! \brief This implements a horizontal <a href="http://en.wikipedia.org/wiki/Box_plot">boxplot</a> where the data is directly given to the
2019-01-20 17:49:29 +08:00
object and not stored in a column , as in JKQTPBoxplotVerticalGraph
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_statgraphs
2019-01-20 17:49:29 +08:00
\ ingroup jkqtplotter_geoplots
2018-11-25 21:53:26 +08:00
the x position is given in pos . All other data are given in the median , min , max ,
percentile25 and percentile75 .
2019-01-20 17:49:29 +08:00
\ image html plot_boxplothorizontalelement . png
2019-01-20 23:15:10 +08:00
\ note See JKQTPBoxplotVerticalElement for a detailed documentation
\ see JKQTPBoxplotVerticalElement
2018-11-25 21:53:26 +08:00
*/
2019-02-03 21:04:48 +08:00
class JKQTP_LIB_EXPORT JKQTPBoxplotHorizontalElement : public JKQTPBoxplotVerticalElement {
2018-11-25 21:53:26 +08:00
Q_OBJECT
public :
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTPBoxplotHorizontalElement ( JKQTBasePlotter * parent = nullptr ) ;
2018-11-25 21:53:26 +08:00
/** \brief class constructor */
2019-01-20 23:15:10 +08:00
JKQTPBoxplotHorizontalElement ( JKQTPlotter * parent ) ;
2018-11-25 21:53:26 +08:00
/** \brief plots the graph to the plotter object specified as parent */
2018-12-28 05:52:00 +08:00
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
2018-11-25 21:53:26 +08:00
/** \brief plots a key marker inside the specified rectangle \a rect */
2018-12-28 05:52:00 +08:00
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
2018-11-25 21:53:26 +08:00
/** \brief get the maximum and minimum x-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
2018-12-28 05:52:00 +08:00
virtual bool getXMinMax ( double & minx , double & maxx , double & smallestGreaterZero ) override ;
2018-11-25 21:53:26 +08:00
/** \brief get the maximum and minimum y-value of the graph
*
* The result is given in the two parameters which are call - by - reference parameters !
*/
2018-12-28 05:52:00 +08:00
virtual bool getYMinMax ( double & miny , double & maxy , double & smallestGreaterZero ) override ;
2018-11-25 21:53:26 +08:00
} ;
2018-12-19 00:13:18 +08:00
# endif // jkqtpgraphsboxplot_H