QGIS API Documentation  3.24.2-Tisler (13c1a02865)
Public Member Functions | List of all members
QgsHistogram Class Reference

Calculator for a numeric histogram from a list of values. More...

#include <qgshistogram.h>

Public Member Functions

 QgsHistogram ()=default
 Constructor for QgsHistogram. More...
 
virtual ~QgsHistogram ()=default
 
QList< double > binEdges (int bins) const
 Returns a list of edges for the histogram for a specified number of bins. More...
 
QList< int > counts (int bins) const
 Returns the calculated list of the counts for the histogram bins. More...
 
double optimalBinWidth () const
 Calculates the optimal bin width using the Freedman-Diaconis rule. More...
 
int optimalNumberBins () const
 Returns the optimal number of bins for the source values, calculated using the Freedman-Diaconis rule. More...
 
bool setValues (const QgsVectorLayer *layer, const QString &fieldOrExpression, QgsFeedback *feedback=nullptr)
 Assigns numeric source values for the histogram from a vector layer's field or as the result of an expression. More...
 
void setValues (const QList< double > &values)
 Assigns numeric source values for the histogram. More...
 

Detailed Description

Calculator for a numeric histogram from a list of values.

Since
QGIS 2.9

Definition at line 37 of file qgshistogram.h.

Constructor & Destructor Documentation

◆ QgsHistogram()

QgsHistogram::QgsHistogram ( )
default

Constructor for QgsHistogram.

◆ ~QgsHistogram()

virtual QgsHistogram::~QgsHistogram ( )
virtualdefault

Member Function Documentation

◆ binEdges()

QList< double > QgsHistogram::binEdges ( int  bins) const

Returns a list of edges for the histogram for a specified number of bins.

This list will be length bins + 1, as both the first and last value are also included.

Parameters
binsnumber of bins
Returns
list of bin edges
Note
values must first be specified using setValues()

Definition at line 68 of file qgshistogram.cpp.

◆ counts()

QList< int > QgsHistogram::counts ( int  bins) const

Returns the calculated list of the counts for the histogram bins.

Parameters
binsnumber of histogram bins
Returns
list of histogram counts
Note
values must first be specified using setValues()

Definition at line 84 of file qgshistogram.cpp.

◆ optimalBinWidth()

double QgsHistogram::optimalBinWidth ( ) const

Calculates the optimal bin width using the Freedman-Diaconis rule.

Bins widths are determined by the inter-quartile range of values and the number of values.

Returns
optimal width for bins
See also
optimalNumberBins
Note
values must first be specified using setValues()

Definition at line 57 of file qgshistogram.cpp.

◆ optimalNumberBins()

int QgsHistogram::optimalNumberBins ( ) const

Returns the optimal number of bins for the source values, calculated using the Freedman-Diaconis rule.

The number of bins are determined by the inter-quartile range of values and the number of values.

Returns
optimal number of bins
See also
optimalBinWidth
Note
values must first be specified using setValues()

Definition at line 63 of file qgshistogram.cpp.

◆ setValues() [1/2]

bool QgsHistogram::setValues ( const QgsVectorLayer layer,
const QString &  fieldOrExpression,
QgsFeedback feedback = nullptr 
)

Assigns numeric source values for the histogram from a vector layer's field or as the result of an expression.

Parameters
layervector layer
fieldOrExpressionfield name or expression to be evaluated
feedbackoptional feedback object to allow cancellation of calculation
Returns
true if values were successfully set

Definition at line 42 of file qgshistogram.cpp.

◆ setValues() [2/2]

void QgsHistogram::setValues ( const QList< double > &  values)

Assigns numeric source values for the histogram.

Parameters
valueslist of doubles

Definition at line 36 of file qgshistogram.cpp.


The documentation for this class was generated from the following files: