QGIS API Documentation  2.99.0-Master (23ddace)
Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsHistogramWidget Class Reference

Graphical histogram for displaying distributions of field values. More...

#include <qgshistogramwidget.h>

Inheritance diagram for QgsHistogramWidget:
Inheritance graph
[legend]

Public Slots

void refresh ()
 Redraws the histogram. More...
 
void refreshValues ()
 Refreshes the values for the histogram by fetching them from the layer. More...
 
void setLayer (QgsVectorLayer *layer)
 Sets the vector layer associated with the histogram. More...
 
void setSourceFieldExp (const QString &fieldOrExp)
 Sets the source field or expression to use for values in the histogram. More...
 

Public Member Functions

 QgsHistogramWidget (QWidget *parent=0, QgsVectorLayer *layer=nullptr, const QString &fieldOrExp=QString())
 QgsHistogramWidget constructor. More...
 
 ~QgsHistogramWidget ()
 
QBrush brush () const
 Returns the brush used when drawing histogram bars. More...
 
QgsRangeList graduatedRanges () const
 Returns the graduated ranges associated with the histogram. More...
 
QgsVectorLayerlayer ()
 Returns the layer currently associated with the widget. More...
 
QPen pen () const
 Returns the pen used when drawing histogram bars. More...
 
void setBrush (const QBrush &brush)
 Sets the brush used for drawing histogram bars. More...
 
void setGraduatedRanges (const QgsRangeList &ranges)
 Sets the graduated ranges associated with the histogram. More...
 
void setPen (const QPen &pen)
 Sets the pen to use when drawing histogram bars. More...
 
void setXAxisTitle (const QString &title)
 Sets the title for the histogram's x-axis. More...
 
void setYAxisTitle (const QString &title)
 Sets the title for the histogram's y-axis. More...
 
QString sourceFieldExp () const
 Returns the source field name or expression used to calculate values displayed in the histogram. More...
 
QString xAxisTitle () const
 Returns the title for the histogram's x-axis. More...
 
QString yAxisTitle () const
 Returns the title for the histogram's y-axis. More...
 

Protected Member Functions

virtual void drawHistogram ()
 Updates and redraws the histogram. More...
 

Protected Attributes

QwtPlot * mPlot = nullptr
 
QList< QwtPlotMarker *> mRangeMarkers
 
QgsRangeList mRanges
 

Detailed Description

Graphical histogram for displaying distributions of field values.

Since
QGIS 2.9

Definition at line 48 of file qgshistogramwidget.h.

Constructor & Destructor Documentation

◆ QgsHistogramWidget()

QgsHistogramWidget::QgsHistogramWidget ( QWidget *  parent = 0,
QgsVectorLayer layer = nullptr,
const QString &  fieldOrExp = QString() 
)

QgsHistogramWidget constructor.

If layer and fieldOrExp are specified then the histogram will be initially populated with the corresponding values.

Parameters
parentparent widget
layersource vector layer
fieldOrExpfield name or expression string

Definition at line 41 of file qgshistogramwidget.cpp.

◆ ~QgsHistogramWidget()

QgsHistogramWidget::~QgsHistogramWidget ( )

Definition at line 78 of file qgshistogramwidget.cpp.

Member Function Documentation

◆ brush()

QBrush QgsHistogramWidget::brush ( ) const
inline

Returns the brush used when drawing histogram bars.

See also
setBrush
pen

Definition at line 104 of file qgshistogramwidget.h.

◆ drawHistogram()

void QgsHistogramWidget::drawHistogram ( )
protectedvirtual

Updates and redraws the histogram.

Reimplemented in QgsGraduatedHistogramWidget.

Definition at line 170 of file qgshistogramwidget.cpp.

◆ graduatedRanges()

QgsRangeList QgsHistogramWidget::graduatedRanges ( ) const
inline

Returns the graduated ranges associated with the histogram.

If set, the ranges will be used to color the histogram bars and for showing vertical dividers at the histogram breaks.

Returns
graduated range list
See also
setGraduatedRanges

Definition at line 118 of file qgshistogramwidget.h.

◆ layer()

QgsVectorLayer* QgsHistogramWidget::layer ( )
inline

Returns the layer currently associated with the widget.

See also
setLayer
sourceFieldExp

Definition at line 68 of file qgshistogramwidget.h.

◆ pen()

QPen QgsHistogramWidget::pen ( ) const
inline

Returns the pen used when drawing histogram bars.

See also
setPen
brush

Definition at line 90 of file qgshistogramwidget.h.

◆ refresh

void QgsHistogramWidget::refresh ( )
slot

Redraws the histogram.

Calling this slot does not update the values for the histogram, use refreshValues() to do this.

Definition at line 135 of file qgshistogramwidget.cpp.

◆ refreshValues

void QgsHistogramWidget::refreshValues ( )
slot

Refreshes the values for the histogram by fetching them from the layer.

Definition at line 96 of file qgshistogramwidget.cpp.

◆ setBrush()

void QgsHistogramWidget::setBrush ( const QBrush &  brush)
inline

Sets the brush used for drawing histogram bars.

If ranges have been set using setGraduatedRanges() then the pen and brush will have no effect.

Parameters
brushhistogram brush
See also
brush
setPen

Definition at line 98 of file qgshistogramwidget.h.

◆ setGraduatedRanges()

void QgsHistogramWidget::setGraduatedRanges ( const QgsRangeList ranges)

Sets the graduated ranges associated with the histogram.

If set, the ranges will be used to color the histogram bars and for showing vertical dividers at the histogram breaks.

Parameters
rangesgraduated range list
See also
graduatedRanges

Definition at line 90 of file qgshistogramwidget.cpp.

◆ setLayer

void QgsHistogramWidget::setLayer ( QgsVectorLayer layer)
slot

Sets the vector layer associated with the histogram.

Parameters
layersource vector layer
See also
setSourceFieldExp

Definition at line 140 of file qgshistogramwidget.cpp.

◆ setPen()

void QgsHistogramWidget::setPen ( const QPen &  pen)
inline

Sets the pen to use when drawing histogram bars.

If set to Qt::NoPen then the pen will be automatically calculated. If ranges have been set using setGraduatedRanges() then the pen and brush will have no effect.

Parameters
penhistogram pen
See also
pen
setBrush

Definition at line 84 of file qgshistogramwidget.h.

◆ setSourceFieldExp

void QgsHistogramWidget::setSourceFieldExp ( const QString &  fieldOrExp)
slot

Sets the source field or expression to use for values in the histogram.

Parameters
fieldOrExpfield name or expression string
See also
setLayer

Definition at line 161 of file qgshistogramwidget.cpp.

◆ setXAxisTitle()

void QgsHistogramWidget::setXAxisTitle ( const QString &  title)
inline

Sets the title for the histogram's x-axis.

Parameters
titlex-axis title, or empty string to remove title
See also
xAxisTitle
setYAxisTitle

Definition at line 131 of file qgshistogramwidget.h.

◆ setYAxisTitle()

void QgsHistogramWidget::setYAxisTitle ( const QString &  title)
inline

Sets the title for the histogram's y-axis.

Parameters
titley-axis title, or empty string to remove title
See also
yAxisTitle
setXAxisTitle

Definition at line 144 of file qgshistogramwidget.h.

◆ sourceFieldExp()

QString QgsHistogramWidget::sourceFieldExp ( ) const
inline

Returns the source field name or expression used to calculate values displayed in the histogram.

See also
setSourceFieldExp
layer

Definition at line 75 of file qgshistogramwidget.h.

◆ xAxisTitle()

QString QgsHistogramWidget::xAxisTitle ( ) const
inline

Returns the title for the histogram's x-axis.

See also
setXAxisTitle
yAxisTitle

Definition at line 124 of file qgshistogramwidget.h.

◆ yAxisTitle()

QString QgsHistogramWidget::yAxisTitle ( ) const
inline

Returns the title for the histogram's y-axis.

See also
setYAxisTitle
xAxisTitle

Definition at line 137 of file qgshistogramwidget.h.

Member Data Documentation

◆ mPlot

QwtPlot* QgsHistogramWidget::mPlot = nullptr
protected

Definition at line 175 of file qgshistogramwidget.h.

◆ mRangeMarkers

QList< QwtPlotMarker * > QgsHistogramWidget::mRangeMarkers
protected

Definition at line 177 of file qgshistogramwidget.h.

◆ mRanges

QgsRangeList QgsHistogramWidget::mRanges
protected

Definition at line 176 of file qgshistogramwidget.h.


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