Class: QgsHistogramWidget

class qgis.gui.QgsHistogramWidget

Bases: PyQt5.QtWidgets.QWidget

Graphical histogram for displaying distributions of field values.

New in version 2.9.

QgsHistogramWidget(parent: QWidget = None, layer: QgsVectorLayer = None, fieldOrExp: str = ‘’) QgsHistogramWidget constructor. If layer and fieldOrExp are specified then the histogram will be initially populated with the corresponding values.

Parameters
actionEvent(self, QActionEvent)
brush(self) QBrush

Returns the brush used when drawing histogram bars.

See also

setBrush()

See also

pen()

Return type

QBrush

changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEvent(self, QCloseEvent)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
drawHistogram(self)

Updates and redraws the histogram.

dropEvent(self, QDropEvent)
enterEvent(self, QEvent)
event(self, QEvent) bool
focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
graduatedRanges(self) List[QgsRendererRange]

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.

Return type

List[QgsRendererRange]

Returns

graduated range list

hideEvent(self, QHideEvent)
initPainter(self, QPainter)
inputMethodEvent(self, QInputMethodEvent)
isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
layer(self) QgsVectorLayer

Returns the layer currently associated with the widget.

See also

setLayer()

See also

sourceFieldExp()

Return type

QgsVectorLayer

leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, QMouseEvent)
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr) Tuple[bool, int]
paintEvent(self, QPaintEvent)
pen(self) QPen

Returns the pen used when drawing histogram bars.

See also

setPen()

See also

brush()

Return type

QPen

receivers(self, PYQT_SIGNAL) int
refresh(self)

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

refreshValues(self)

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

resizeEvent(self, QResizeEvent)
sender(self) QObject
senderSignalIndex(self) int
setBrush(self, brush: Union[QBrush, QColor, Qt.GlobalColor, QGradient])

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

brush (Union[QBrush) – histogram brush

See also

brush()

See also

setPen()

setGraduatedRanges(self, ranges: Iterable[QgsRendererRange])

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

ranges (Iterable[QgsRendererRange]) – graduated range list

setLayer(self, layer: QgsVectorLayer)

Sets the vector layer associated with the histogram.

Parameters

layer (QgsVectorLayer) – source vector layer

setPen(self, pen: Union[QPen, QColor, Qt.GlobalColor, QGradient])

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

pen (Union[QPen) – histogram pen

See also

pen()

See also

setBrush()

setSourceFieldExp(self, fieldOrExp: str)

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

Parameters

fieldOrExp (str) – field name or expression string

See also

setLayer()

setXAxisTitle(self, title: str)

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

Parameters

title (str) – x-axis title, or empty string to remove title

See also

xAxisTitle()

See also

setYAxisTitle()

setYAxisTitle(self, title: str)

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

Parameters

title (str) – y-axis title, or empty string to remove title

See also

yAxisTitle()

See also

setXAxisTitle()

sharedPainter(self) QPainter
showEvent(self, QShowEvent)
sourceFieldExp(self) str

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

See also

layer()

Return type

str

tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
updateMicroFocus(self)
wheelEvent(self, QWheelEvent)
xAxisTitle(self) str

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

See also

setXAxisTitle()

See also

yAxisTitle()

Return type

str

yAxisTitle(self) str

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

See also

setYAxisTitle()

See also

xAxisTitle()

Return type

str