QWT 7.0.1
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtPlotBarChart Class Reference

QwtPlotBarChart displays a series of a values as bars. More...

#include <qwt_plot_barchart.h>

Inheritance diagram for QwtPlotBarChart:
QwtPlotAbstractBarChart QwtSeriesStore< QPointF > QwtPlotSeriesItem QwtAbstractSeriesStore QwtPlotItem QwtAbstractSeriesStore

Classes

class  PrivateData
 

Public Types

enum  LegendMode { LegendChartTitle , LegendBarTitles }
 Legend modes. More...
 
- Public Types inherited from QwtPlotAbstractBarChart
enum  LayoutPolicy { AutoAdjustSamples , ScaleSamplesToAxes , ScaleSampleToCanvas , FixedSampleSize }
 Mode how to calculate the bar width. More...
 
- Public Types inherited from QwtPlotItem
enum  RttiValues {
  Rtti_PlotItem = 0 , Rtti_PlotGrid , Rtti_PlotScale , Rtti_PlotLegend ,
  Rtti_PlotMarker , Rtti_PlotCurve , Rtti_PlotSpectroCurve , Rtti_PlotIntervalCurve ,
  Rtti_PlotHistogram , Rtti_PlotSpectrogram , Rtti_PlotGraphic , Rtti_PlotTradingCurve ,
  Rtti_PlotBarChart , Rtti_PlotMultiBarChart , Rtti_PlotShape , Rtti_PlotTextLabel ,
  Rtti_PlotZone , Rtti_PlotVectorField , Rtti_PlotUserItem = 1000
}
 Runtime type information. More...
 
enum  ItemAttribute { Legend = 0x01 , AutoScale = 0x02 , Margins = 0x04 }
 Plot Item Attributes. More...
 
enum  ItemInterest { ScaleInterest = 0x01 , LegendInterest = 0x02 }
 Plot Item Interests/绘图项关注的事件类型 More...
 
enum  RenderHint { RenderAntialiased = 0x1 }
 Render hints. More...
 

Public Member Functions

 QwtPlotBarChart (const QString &title=QString())
 Constructor.
 
 QwtPlotBarChart (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotBarChart ()
 Destructor.
 
virtual int rtti () const QWT_OVERRIDE
 
void setSamples (const QVector< QPointF > &)
 Initialize data with an array of points.
 
void setSamples (const QVector< double > &)
 Initialize data with an array of doubles.
 
void setSamples (QwtSeriesData< QPointF > *)
 Assign a series of samples.
 
void setSymbol (QwtColumnSymbol *)
 Assign a symbol.
 
const QwtColumnSymbolsymbol () const
 
void setPen (const QPen &p)
 set bar symbol pen
 
QPen pen () const
 bar symbol pen
 
void setBrush (const QBrush &b)
 set bar symbol brush
 
QBrush brush () const
 bar symbol brush
 
void setFrameStyle (QwtColumnSymbol::FrameStyle f)
 set bar symbol frame style
 
QwtColumnSymbol::FrameStyle frameStyle () const
 bar symbol frame style
 
void setLegendMode (LegendMode)
 Set the mode that decides what to display on the legend.
 
LegendMode legendMode () const
 
virtual void drawSeries (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const QWT_OVERRIDE
 Draw an interval of the bar chart.
 
virtual QRectF boundingRect () const QWT_OVERRIDE
 
virtual QwtColumnSymbolspecialSymbol (int sampleIndex, const QPointF &) const
 Needs to be overloaded to return a non default symbol for a specific sample.
 
virtual QwtText barTitle (int sampleIndex) const
 Return the title of a bar.
 
- Public Member Functions inherited from QwtPlotAbstractBarChart
 QwtPlotAbstractBarChart (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotAbstractBarChart ()
 Destructor.
 
void setLayoutPolicy (LayoutPolicy)
 The combination of layoutPolicy() and layoutHint() define how the width of the bars is calculated.
 
LayoutPolicy layoutPolicy () const
 The combination of layoutPolicy() and layoutHint() define how the width of the bars is calculated.
 
void setLayoutHint (double)
 The combination of layoutPolicy() and layoutHint() define how the width of the bars is calculated.
 
double layoutHint () const
 The combination of layoutPolicy() and layoutHint() define how the width of the bars is calculated.
 
void setSpacing (int)
 Set the spacing.
 
int spacing () const
 
void setMargin (int)
 Set the margin.
 
int margin () const
 
void setBaseline (double)
 Set the baseline.
 
double baseline () const
 
virtual void getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const QWT_OVERRIDE
 Calculate a hint for the canvas margin.
 
- Public Member Functions inherited from QwtPlotSeriesItem
 QwtPlotSeriesItem (const QString &title=QString())
 Constructor.
 
 QwtPlotSeriesItem (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotSeriesItem ()
 Destructor.
 
void setOrientation (Qt::Orientation)
 Set the orientation of the item.
 
Qt::Orientation orientation () const
 
virtual void draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
 Draw the complete series.
 
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &) QWT_OVERRIDE
 Update the item to changes of the axes scale division.
 
- Public Member Functions inherited from QwtPlotItem
 QwtPlotItem ()
 Constructor.
 
 QwtPlotItem (const QString &title)
 Constructor.
 
 QwtPlotItem (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotItem ()
 Destroy the QwtPlotItem.
 
void attach (QwtPlot *plot)
 Attach the item to a plot.
 
void detach ()
 This method detaches a QwtPlotItem from any QwtPlot it has been associated with.
 
QwtPlotplot () const
 Return attached plot.
 
void setTitle (const QString &title)
 Set a new title.
 
void setTitle (const QwtText &title)
 Set a new title.
 
const QwtTexttitle () const
 
void setItemAttribute (ItemAttribute, bool on=true)
 Toggle an item attribute.
 
bool testItemAttribute (ItemAttribute) const
 Test an item attribute.
 
void setItemInterest (ItemInterest, bool on=true)
 Toggle an item interest.
 
bool testItemInterest (ItemInterest) const
 Test an item interest.
 
void setRenderHint (RenderHint, bool on=true)
 Toggle an render hint.
 
bool testRenderHint (RenderHint) const
 Test a render hint.
 
void setRenderThreadCount (uint numThreads)
 On multi core systems rendering of certain plot item ( f.e QwtPlotRasterItem ) can be done in parallel in several threads.
 
uint renderThreadCount () const
 
void setLegendIconSize (const QSize &)
 Set the size of the legend icon.
 
QSize legendIconSize () const
 
double z () const
 Plot items are painted in increasing z-order.
 
void setZ (double z)
 Set the z value.
 
void show ()
 Show the item.
 
void hide ()
 Hide the item.
 
virtual void setVisible (bool)
 Show/Hide the item.
 
bool isVisible () const
 
void setAxes (QwtAxisId xAxis, QwtAxisId yAxis)
 Set X and Y axis.
 
void setXAxis (QwtAxisId)
 Set the X axis.
 
QwtAxisId xAxis () const
 Return xAxis.
 
void setYAxis (QwtAxisId)
 Set the Y axis.
 
QwtAxisId yAxis () const
 Return yAxis.
 
virtual void itemChanged ()
 Update the legend and call QwtPlot::autoRefresh() for the parent plot.
 
virtual void legendChanged ()
 Update the legend of the parent plot.
 
virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &)
 Update the item to changes of the legend info.
 
QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the bounding scale rectangle of 2 maps.
 
QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the bounding paint rectangle of 2 maps.
 
- Public Member Functions inherited from QwtAbstractSeriesStore
virtual ~QwtAbstractSeriesStore ()
 Destructor.
 
- Public Member Functions inherited from QwtSeriesStore< QPointF >
 QwtSeriesStore ()
 Constructor The store contains no series.
 
 ~QwtSeriesStore ()
 Destructor.
 
void setData (QwtSeriesData< QPointF > *series)
 Assign a series of samples.
 
QwtSeriesData< QPointF > * data ()
 
const QwtSeriesData< QPointF > * data () const
 
QPointF sample (size_t index) const
 
virtual size_t dataSize () const QWT_OVERRIDE
 
virtual QRectF dataRect () const QWT_OVERRIDE
 
virtual void setRectOfInterest (const QRectF &rect) QWT_OVERRIDE
 Set a the "rect of interest" for the series.
 
QwtSeriesData< QPointF > * swapData (QwtSeriesData< QPointF > *series)
 Replace a series without deleting the previous one.
 

Protected Member Functions

virtual void drawSample (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, const QwtInterval &boundingInterval, int index, const QPointF &sample) const
 Draw a sample.
 
virtual void drawBar (QPainter *, int sampleIndex, const QPointF &sample, const QwtColumnRect &) const
 Draw a bar.
 
QwtColumnRect columnRect (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, const QwtInterval &boundingInterval, const QPointF &sample) const
 Calculate the geometry of a bar in widget coordinates.
 
QList< QwtLegendDatalegendData () const QWT_OVERRIDE
 Return all information, that is needed to represent the item on the legend.
 
QwtGraphic legendIcon (int index, const QSizeF &) const QWT_OVERRIDE
 
- Protected Member Functions inherited from QwtPlotAbstractBarChart
double sampleWidth (const QwtScaleMap &map, double canvasSize, double boundingSize, double value) const
 Calculate the width for a sample in paint device coordinates.
 
- Protected Member Functions inherited from QwtPlotSeriesItem
virtual void dataChanged () QWT_OVERRIDE
 dataChanged() indicates, that the series has been changed.
 
- Protected Member Functions inherited from QwtPlotItem
QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const
 Return a default icon from a brush.
 

Detailed Description

QwtPlotBarChart displays a series of a values as bars.

Each bar might be customized individually by implementing a specialSymbol(). Otherwise it is rendered using a default symbol.

Depending on its orientation() the bars are displayed horizontally or vertically. The bars cover the interval between the baseline() and the value.

By activating the LegendBarTitles mode each sample will have its own entry on the legend.

The most common use case of a bar chart is to display a list of y coordinates, where the x coordinate is simply the index in the list. But for other situations ( f.e. when values are related to dates ) it is also possible to set x coordinates explicitly.

See also
QwtPlotMultiBarChart, QwtPlotHistogram, QwtPlotCurve::Sticks, QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()

Member Enumeration Documentation

◆ LegendMode

Legend modes.

The default setting is QwtPlotBarChart::LegendChartTitle.

See also
setLegendMode(), legendMode()
Enumerator
LegendChartTitle 

One entry on the legend showing the default symbol and the title() of the chart.

See also
QwtPlotItem::title()
LegendBarTitles 

One entry for each value showing the individual symbol of the corresponding bar and the bar title.

See also
specialSymbol(), barTitle()

Constructor & Destructor Documentation

◆ QwtPlotBarChart() [1/2]

QwtPlotBarChart::QwtPlotBarChart ( const QString &  title = QString())
explicit

Constructor.

Parameters
titleTitle of the curve

◆ QwtPlotBarChart() [2/2]

QwtPlotBarChart::QwtPlotBarChart ( const QwtText title)
explicit

Constructor.

Parameters
titleTitle of the curve

Member Function Documentation

◆ barTitle()

QwtText QwtPlotBarChart::barTitle ( int  sampleIndex) const
virtual

Return the title of a bar.

In LegendBarTitles mode the title is displayed on the legend entry corresponding to a bar.

The default implementation is a dummy, that is intended to be overloaded.

Parameters
sampleIndexIndex of the bar
Returns
An empty text
See also
LegendBarTitles

◆ boundingRect()

QRectF QwtPlotBarChart::boundingRect ( ) const
virtual
Returns
Bounding rectangle of all samples. For an empty series the rectangle is invalid.

Reimplemented from QwtPlotSeriesItem.

◆ brush()

QBrush QwtPlotBarChart::brush ( ) const

bar symbol brush

Returns

◆ columnRect()

QwtColumnRect QwtPlotBarChart::columnRect ( const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect,
const QwtInterval boundingInterval,
const QPointF &  sample 
) const
protected

Calculate the geometry of a bar in widget coordinates.

Parameters
xMapx map
yMapy map
canvasRectContents rect of the canvas
boundingIntervalBounding interval of sample values
sampleValue of the sample
Returns
Geometry of the column

◆ drawBar()

void QwtPlotBarChart::drawBar ( QPainter *  painter,
int  sampleIndex,
const QPointF &  sample,
const QwtColumnRect rect 
) const
protectedvirtual

Draw a bar.

Parameters
painterPainter
sampleIndexIndex of the sample represented by the bar
sampleValue of the sample
rectBounding rectangle of the bar

◆ drawSample()

void QwtPlotBarChart::drawSample ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect,
const QwtInterval boundingInterval,
int  index,
const QPointF &  sample 
) const
protectedvirtual

Draw a sample.

Parameters
painterPainter
xMapx map
yMapy map
canvasRectContents rect of the canvas
boundingIntervalBounding interval of sample values
indexIndex of the sample
sampleValue of the sample
See also
drawSeries()

◆ drawSeries()

void QwtPlotBarChart::drawSeries ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
virtual

Draw an interval of the bar chart.

Parameters
painterPainter
xMapMaps x-values into pixel coordinates.
yMapMaps y-values into pixel coordinates.
canvasRectContents rect of the canvas
fromIndex of the first point to be painted
toIndex of the last point to be painted. If to < 0 the curve will be painted to its last point.
See also
drawSymbols()

Implements QwtPlotSeriesItem.

◆ frameStyle()

QwtColumnSymbol::FrameStyle QwtPlotBarChart::frameStyle ( ) const

bar symbol frame style

Returns

◆ legendData()

QList< QwtLegendData > QwtPlotBarChart::legendData ( ) const
protectedvirtual

Return all information, that is needed to represent the item on the legend.

In case of LegendBarTitles an entry for each bar is returned, otherwise the chart is represented like any other plot item from its title() and the legendIcon().

Returns
Information, that is needed to represent the item on the legend
See also
title(), setLegendMode(), barTitle(), QwtLegend, QwtPlotLegendItem

Reimplemented from QwtPlotItem.

◆ legendIcon()

QwtGraphic QwtPlotBarChart::legendIcon ( int  index,
const QSizeF &  size 
) const
protectedvirtual
Returns
Icon representing a bar or the chart on the legend

When the legendMode() is LegendBarTitles the icon shows the bar corresponding to index - otherwise the bar displays the default symbol.

Parameters
indexIndex of the legend entry
sizeIcon size
See also
setLegendMode(), drawBar(), QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()

Reimplemented from QwtPlotItem.

◆ legendMode()

QwtPlotBarChart::LegendMode QwtPlotBarChart::legendMode ( ) const
Returns
Legend mode
See also
setLegendMode()

◆ pen()

QPen QwtPlotBarChart::pen ( ) const

bar symbol pen

Returns

◆ rtti()

int QwtPlotBarChart::rtti ( ) const
virtual
Returns
QwtPlotItem::Rtti_PlotBarChart

Reimplemented from QwtPlotItem.

◆ setBrush()

void QwtPlotBarChart::setBrush ( const QBrush &  b)

set bar symbol brush

Parameters
b

◆ setFrameStyle()

void QwtPlotBarChart::setFrameStyle ( QwtColumnSymbol::FrameStyle  f)

set bar symbol frame style

Parameters
f

◆ setLegendMode()

void QwtPlotBarChart::setLegendMode ( LegendMode  mode)

Set the mode that decides what to display on the legend.

In case of LegendBarTitles barTitle() needs to be overloaded to return individual titles for each bar.

Parameters
modeNew mode
See also
legendMode(), legendData(), barTitle(), QwtPlotItem::ItemAttribute

◆ setPen()

void QwtPlotBarChart::setPen ( const QPen &  p)

set bar symbol pen

Parameters
pen

◆ setSamples() [1/3]

void QwtPlotBarChart::setSamples ( const QVector< double > &  samples)

Initialize data with an array of doubles.

The indices in the array are taken as x coordinate, while the doubles are interpreted as y values.

Parameters
samplesVector of y coordinates
Note
QVector is implicitly shared

◆ setSamples() [2/3]

void QwtPlotBarChart::setSamples ( const QVector< QPointF > &  samples)

Initialize data with an array of points.

Parameters
samplesVector of points
Note
QVector is implicitly shared
QPolygonF is derived from QVector<QPointF>

◆ setSamples() [3/3]

void QwtPlotBarChart::setSamples ( QwtSeriesData< QPointF > *  data)

Assign a series of samples.

setSamples() is just a wrapper for setData() without any additional value - beside that it is easier to find for the developer.

Parameters
dataData
Warning
The item takes ownership of the data object, deleting it when its not used anymore.

◆ setSymbol()

void QwtPlotBarChart::setSymbol ( QwtColumnSymbol symbol)

Assign a symbol.

The bar chart will take the ownership of the symbol, hence the previously set symbol will be delete by setting a new one. If symbol is NULL no symbol will be drawn.

Parameters
symbolSymbol
See also
symbol()

◆ specialSymbol()

QwtColumnSymbol * QwtPlotBarChart::specialSymbol ( int  sampleIndex,
const QPointF &  sample 
) const
virtual

Needs to be overloaded to return a non default symbol for a specific sample.

Parameters
sampleIndexIndex of the sample represented by the bar
sampleValue of the sample
Returns
NULL, indicating to use the default symbol

◆ symbol()

const QwtColumnSymbol * QwtPlotBarChart::symbol ( ) const
Returns
Current symbol or NULL, when no symbol has been assigned
See also
setSymbol()

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