mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Tweak appearance of histogram titles and hide value title to make
more space for plot itself.
This commit is contained in:
parent
bcab4aeb14
commit
86a45d406b
@ -79,6 +79,32 @@ class QgsHistogramWidget : QWidget
|
|||||||
*/
|
*/
|
||||||
QgsRangeList graduatedRanges() const;
|
QgsRangeList graduatedRanges() const;
|
||||||
|
|
||||||
|
/** Returns the title for the histogram's x-axis.
|
||||||
|
* @see setXAxisTitle
|
||||||
|
* @see yAxisTitle
|
||||||
|
*/
|
||||||
|
QString xAxisTitle() const;
|
||||||
|
|
||||||
|
/** Sets the title for the histogram's x-axis.
|
||||||
|
* @param title x-axis title, or empty string to remove title
|
||||||
|
* @see xAxisTitle
|
||||||
|
* @see setYAxisTitle
|
||||||
|
*/
|
||||||
|
void setXAxisTitle( const QString& title );
|
||||||
|
|
||||||
|
/** Returns the title for the histogram's y-axis.
|
||||||
|
* @see setYAxisTitle
|
||||||
|
* @see xAxisTitle
|
||||||
|
*/
|
||||||
|
QString yAxisTitle() const;
|
||||||
|
|
||||||
|
/** Sets the title for the histogram's y-axis.
|
||||||
|
* @param title y-axis title, or empty string to remove title
|
||||||
|
* @see yAxisTitle
|
||||||
|
* @see setXAxisTitle
|
||||||
|
*/
|
||||||
|
void setYAxisTitle( const QString& title );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/** Triggers a refresh of the histogram when the widget is next repainted.
|
/** Triggers a refresh of the histogram when the widget is next repainted.
|
||||||
|
@ -47,6 +47,8 @@ QgsHistogramWidget::QgsHistogramWidget( QWidget *parent, QgsVectorLayer* layer,
|
|||||||
, mRedrawRequired( true )
|
, mRedrawRequired( true )
|
||||||
, mVectorLayer( layer )
|
, mVectorLayer( layer )
|
||||||
, mSourceFieldExp( fieldOrExp )
|
, mSourceFieldExp( fieldOrExp )
|
||||||
|
, mXAxisTitle( QObject::tr("Value"))
|
||||||
|
, mYAxisTitle( QObject::tr("Count"))
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
@ -163,8 +165,20 @@ void QgsHistogramWidget::drawHistogram()
|
|||||||
//ensure all children get removed
|
//ensure all children get removed
|
||||||
mpPlot->setAutoDelete( true );
|
mpPlot->setAutoDelete( true );
|
||||||
// Set axis titles
|
// Set axis titles
|
||||||
mpPlot->setAxisTitle( QwtPlot::xBottom, QObject::tr( "Value" ) );
|
if ( !mXAxisTitle.isEmpty() )
|
||||||
mpPlot->setAxisTitle( QwtPlot::yLeft, QObject::tr( "Count" ) );
|
mpPlot->setAxisTitle( QwtPlot::xBottom, mXAxisTitle );
|
||||||
|
if ( !mYAxisTitle.isEmpty() )
|
||||||
|
mpPlot->setAxisTitle( QwtPlot::yLeft, mYAxisTitle );
|
||||||
|
mpPlot->setAxisFont( QwtPlot::xBottom, this->font() );
|
||||||
|
mpPlot->setAxisFont( QwtPlot::yLeft, this->font() );
|
||||||
|
QFont titleFont = this->font();
|
||||||
|
titleFont.setBold( true );
|
||||||
|
QwtText xAxisText = mpPlot->axisTitle( QwtPlot::xBottom );
|
||||||
|
xAxisText.setFont( titleFont );
|
||||||
|
mpPlot->setAxisTitle( QwtPlot::xBottom, xAxisText );
|
||||||
|
QwtText yAxisText = mpPlot->axisTitle( QwtPlot::yLeft );
|
||||||
|
yAxisText.setFont( titleFont );
|
||||||
|
mpPlot->setAxisTitle( QwtPlot::yLeft, yAxisText );
|
||||||
mpPlot->setAxisAutoScale( QwtPlot::yLeft );
|
mpPlot->setAxisAutoScale( QwtPlot::yLeft );
|
||||||
mpPlot->setAxisAutoScale( QwtPlot::xBottom );
|
mpPlot->setAxisAutoScale( QwtPlot::xBottom );
|
||||||
|
|
||||||
|
@ -118,6 +118,32 @@ class GUI_EXPORT QgsHistogramWidget : public QWidget, private Ui::QgsHistogramWi
|
|||||||
*/
|
*/
|
||||||
QgsRangeList graduatedRanges() const { return mRanges; }
|
QgsRangeList graduatedRanges() const { return mRanges; }
|
||||||
|
|
||||||
|
/** Returns the title for the histogram's x-axis.
|
||||||
|
* @see setXAxisTitle
|
||||||
|
* @see yAxisTitle
|
||||||
|
*/
|
||||||
|
QString xAxisTitle() const { return mXAxisTitle; }
|
||||||
|
|
||||||
|
/** Sets the title for the histogram's x-axis.
|
||||||
|
* @param title x-axis title, or empty string to remove title
|
||||||
|
* @see xAxisTitle
|
||||||
|
* @see setYAxisTitle
|
||||||
|
*/
|
||||||
|
void setXAxisTitle( const QString& title ) { mXAxisTitle = title; }
|
||||||
|
|
||||||
|
/** Returns the title for the histogram's y-axis.
|
||||||
|
* @see setYAxisTitle
|
||||||
|
* @see xAxisTitle
|
||||||
|
*/
|
||||||
|
QString yAxisTitle() const { return mYAxisTitle; }
|
||||||
|
|
||||||
|
/** Sets the title for the histogram's y-axis.
|
||||||
|
* @param title y-axis title, or empty string to remove title
|
||||||
|
* @see yAxisTitle
|
||||||
|
* @see setXAxisTitle
|
||||||
|
*/
|
||||||
|
void setYAxisTitle( const QString& title ) { mYAxisTitle = title; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/** Triggers a refresh of the histogram when the widget is next repainted.
|
/** Triggers a refresh of the histogram when the widget is next repainted.
|
||||||
@ -166,6 +192,8 @@ class GUI_EXPORT QgsHistogramWidget : public QWidget, private Ui::QgsHistogramWi
|
|||||||
QPen mMeanPen;
|
QPen mMeanPen;
|
||||||
QPen mStdevPen;
|
QPen mStdevPen;
|
||||||
QPen mGridPen;
|
QPen mGridPen;
|
||||||
|
QString mXAxisTitle;
|
||||||
|
QString mYAxisTitle;
|
||||||
|
|
||||||
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
|
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
|
||||||
QwtPlotHistogram* createPlotHistogram( const QString& title, const QBrush &brush, const QPen &pen = Qt::NoPen ) const;
|
QwtPlotHistogram* createPlotHistogram( const QString& title, const QBrush &brush, const QPen &pen = Qt::NoPen ) const;
|
||||||
|
@ -50,6 +50,8 @@ QgsGraduatedHistogramWidget::QgsGraduatedHistogramWidget( QWidget *parent )
|
|||||||
, mHistoPicker( 0 )
|
, mHistoPicker( 0 )
|
||||||
, mPressedValue( 0 )
|
, mPressedValue( 0 )
|
||||||
{
|
{
|
||||||
|
//clear x axis title to make more room for graph
|
||||||
|
setXAxisTitle( QString() );
|
||||||
|
|
||||||
mFilter = new QgsGraduatedHistogramEventFilter( mPlot );
|
mFilter = new QgsGraduatedHistogramEventFilter( mPlot );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user