QGIS API Documentation 3.99.0-Master (c22de0620c0)
Loading...
Searching...
No Matches
qgslayoutchartwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutchartwidget.cpp
3 --------------------------
4 begin : August 2025
5 copyright : (C) 2025 by Mathieu
6 email : mathieu at opengis dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include "qgsapplication.h"
21#include "qgsgui.h"
22#include "qgslayout.h"
24#include "qgslayoutitemchart.h"
25#include "qgsplotregistry.h"
26#include "qgsplotwidget.h"
27
28#include "moc_qgslayoutchartwidget.cpp"
29
31 : QgsLayoutItemBaseWidget( nullptr, chartItem )
32 , mChartItem( chartItem )
33{
34 setupUi( this );
35
36 //add widget for general composer item properties
37 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, chartItem );
38 mainLayout->addWidget( mItemPropertiesWidget );
39
40 QMap<QString, QString> plotTypes = QgsApplication::instance()->plotRegistry()->plotTypes();
41 for ( auto plotTypesIterator = plotTypes.keyValueBegin(); plotTypesIterator != plotTypes.keyValueEnd(); ++plotTypesIterator )
42 {
43 mChartTypeComboBox->addItem( plotTypesIterator->second, plotTypesIterator->first );
44 }
45
46 mLayerComboBox->setFilters( Qgis::LayerFilter::VectorLayer );
47
48 connect( mChartTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutChartWidget::mChartTypeComboBox_currentIndexChanged );
49 connect( mChartPropertiesButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mChartPropertiesButton_clicked );
50 connect( mFlipAxesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mFlipAxesCheckBox_stateChanged );
51
52 connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsLayoutChartWidget::changeLayer );
53 connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, mSortExpressionWidget, &QgsFieldExpressionWidget::setLayer );
54 connect( mSortCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mSortCheckBox_stateChanged );
55 connect( mSortExpressionWidget, static_cast<void ( QgsFieldExpressionWidget::* )( const QString &, bool )>( &QgsFieldExpressionWidget::fieldChanged ), this, &QgsLayoutChartWidget::changeSortExpression );
56 connect( mSortDirectionButton, &QToolButton::clicked, this, &QgsLayoutChartWidget::mSortDirectionButton_clicked );
57
58 connect( mSeriesListWidget, &QListWidget::currentItemChanged, this, &QgsLayoutChartWidget::mSeriesListWidget_currentItemChanged );
59 connect( mSeriesListWidget, &QListWidget::itemChanged, this, &QgsLayoutChartWidget::mSeriesListWidget_itemChanged );
60 connect( mAddSeriesPushButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mAddSeriesPushButton_clicked );
61 connect( mRemoveSeriesPushButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mRemoveSeriesPushButton_clicked );
62 connect( mSeriesPropertiesButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mSeriesPropertiesButton_clicked );
63
64 mLinkedMapComboBox->setCurrentLayout( mChartItem->layout() );
65 mLinkedMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
66 connect( mLinkedMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutChartWidget::mLinkedMapComboBox_itemChanged );
67
68 connect( mFilterOnlyVisibleFeaturesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mFilterOnlyVisibleFeaturesCheckBox_stateChanged );
69 connect( mIntersectAtlasCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mIntersectAtlasCheckBox_stateChanged );
70
71 setGuiElementValues();
72 updateButtonsState();
73
74 connect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
75}
76
78{
79 if ( mItemPropertiesWidget )
80 mItemPropertiesWidget->setMasterLayout( masterLayout );
81}
82
84{
86 return false;
87
88 if ( mChartItem )
89 {
90 disconnect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
91 }
92
93 mChartItem = qobject_cast<QgsLayoutItemChart *>( item );
94 mItemPropertiesWidget->setItem( mChartItem );
95
96 if ( mChartItem )
97 {
98 connect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
99 }
100
101 setGuiElementValues();
102
103 return true;
104}
105
106void QgsLayoutChartWidget::setGuiElementValues()
107{
108 if ( mChartItem )
109 {
110 whileBlocking( mChartTypeComboBox )->setCurrentIndex( mChartTypeComboBox->findData( mChartItem->plot()->type() ) );
111 whileBlocking( mLayerComboBox )->setLayer( mChartItem->sourceLayer() );
112
113 Qgs2DXyPlot *plot2DXy = dynamic_cast<Qgs2DXyPlot *>( mChartItem->plot() );
114 if ( plot2DXy )
115 {
116 mFlipAxesCheckBox->setEnabled( true );
117 whileBlocking( mFlipAxesCheckBox )->setChecked( plot2DXy->flipAxes() );
118 }
119 else
120 {
121 mFlipAxesCheckBox->setEnabled( false );
122 whileBlocking( mFlipAxesCheckBox )->setChecked( false );
123 }
124
125 whileBlocking( mSortCheckBox )->setCheckState( mChartItem->sortFeatures() ? Qt::Checked : Qt::Unchecked );
126
127 whileBlocking( mSortDirectionButton )->setEnabled( mChartItem->sortFeatures() );
128 whileBlocking( mSortDirectionButton )->setArrowType( mChartItem->sortAscending() ? Qt::UpArrow : Qt::DownArrow );
129
130 whileBlocking( mSortExpressionWidget )->setEnabled( mChartItem->sortFeatures() );
131 whileBlocking( mSortExpressionWidget )->setLayer( mChartItem->sourceLayer() );
132 whileBlocking( mSortExpressionWidget )->setField( mChartItem->sortExpression() );
133
134 mSeriesListWidget->clear();
135 const QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
136 for ( const QgsLayoutItemChart::SeriesDetails &series : seriesList )
137 {
138 addSeriesListItem( series.name() );
139 }
140
141 if ( !seriesList.isEmpty() )
142 {
143 mSeriesListWidget->setCurrentRow( 0 );
144 }
145 else
146 {
147 mSeriesPropertiesButton->setEnabled( false );
148 }
149
150 whileBlocking( mFilterOnlyVisibleFeaturesCheckBox )->setChecked( mChartItem->filterOnlyVisibleFeatures() );
151 mLinkedMapLabel->setEnabled( mFilterOnlyVisibleFeaturesCheckBox->isChecked() );
152 mLinkedMapComboBox->setEnabled( mFilterOnlyVisibleFeaturesCheckBox->isChecked() );
153 whileBlocking( mLinkedMapComboBox )->setItem( mChartItem->map() );
154
155 whileBlocking( mIntersectAtlasCheckBox )->setChecked( mChartItem->filterToAtlasFeature() );
156 }
157 else
158 {
159 mSeriesListWidget->clear();
160 }
161}
162
163void QgsLayoutChartWidget::mChartTypeComboBox_currentIndexChanged( int )
164{
165 if ( !mChartItem )
166 {
167 return;
168 }
169
170 const QString plotType = mChartTypeComboBox->currentData().toString();
171 if ( mChartItem->plot()->type() == plotType )
172 {
173 return;
174 }
175
176 QgsPlot *newPlot = QgsApplication::instance()->plotRegistry()->createPlot( plotType );
177 Qgs2DXyPlot *newPlot2DXy = dynamic_cast<Qgs2DXyPlot *>( newPlot );
178 if ( newPlot2DXy )
179 {
180 Qgs2DXyPlot *oldPlot2DXy = dynamic_cast<Qgs2DXyPlot *>( mChartItem->plot() );
181 if ( oldPlot2DXy )
182 {
183 // Transfer a few basic details for a nicer UX
184 newPlot2DXy->setXMinimum( oldPlot2DXy->xMinimum() );
185 newPlot2DXy->setXMaximum( oldPlot2DXy->xMaximum() );
186 newPlot2DXy->setYMinimum( oldPlot2DXy->yMinimum() );
187 newPlot2DXy->setYMaximum( oldPlot2DXy->yMaximum() );
188
189 newPlot2DXy->xAxis().setType( oldPlot2DXy->xAxis().type() );
190 newPlot2DXy->xAxis().setGridIntervalMajor( oldPlot2DXy->xAxis().gridIntervalMajor() );
191 newPlot2DXy->xAxis().setGridIntervalMinor( oldPlot2DXy->xAxis().gridIntervalMinor() );
192 newPlot2DXy->xAxis().setLabelInterval( oldPlot2DXy->xAxis().labelInterval() );
193
194 newPlot2DXy->yAxis().setGridIntervalMajor( oldPlot2DXy->yAxis().gridIntervalMajor() );
195 newPlot2DXy->yAxis().setGridIntervalMinor( oldPlot2DXy->yAxis().gridIntervalMinor() );
196 newPlot2DXy->yAxis().setLabelInterval( oldPlot2DXy->yAxis().labelInterval() );
197 }
198 mFlipAxesCheckBox->setEnabled( true );
199 mFlipAxesCheckBox->setChecked( newPlot2DXy->flipAxes() );
200 }
201 else
202 {
203 mFlipAxesCheckBox->setEnabled( false );
204 mFlipAxesCheckBox->setChecked( false );
205 }
206
207 mChartItem->beginCommand( tr( "Change Chart Type" ) );
208 mChartItem->setPlot( newPlot );
209 mChartItem->update();
210 mChartItem->endCommand();
211}
212
213void QgsLayoutChartWidget::mChartPropertiesButton_clicked()
214{
215 if ( !mChartItem )
216 {
217 return;
218 }
219
221
222 const QString plotType = mChartTypeComboBox->currentData().toString();
223 QgsPlotAbstractMetadata *abstractMetadata = QgsApplication::instance()->plotRegistry()->plotMetadata( plotType );
224 if ( !abstractMetadata )
225 {
226 return;
227 }
228
229 QgsPlotWidget *widget = abstractMetadata->createPlotWidget( this );
230 if ( !widget )
231 {
232 return;
233 }
234
235 widget->registerExpressionContextGenerator( mChartItem );
236 widget->setPlot( mChartItem->plot() );
237
238 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
239 if ( !mChartItem )
240 {
241 return;
242 }
243
244 mChartItem->beginCommand( tr( "Modify Chart" ) );
245 mChartItem->setPlot( widget->createPlot() );
246 mChartItem->endCommand();
247 mChartItem->update();
248 } );
249
250 openPanel( widget );
251}
252
253void QgsLayoutChartWidget::mFlipAxesCheckBox_stateChanged( int state )
254{
255 if ( !mChartItem )
256 {
257 return;
258 }
259
260 Qgs2DXyPlot *plot2DXy = dynamic_cast<Qgs2DXyPlot *>( mChartItem->plot() );
261 if ( !plot2DXy )
262 {
263 return;
264 }
265
266 mChartItem->beginCommand( tr( "Modify Chart" ) );
267 plot2DXy->setFlipAxes( state == Qt::Checked );
268 mChartItem->endCommand();
269 mChartItem->update();
270}
271
272void QgsLayoutChartWidget::changeLayer( QgsMapLayer *layer )
273{
274 if ( !mChartItem )
275 {
276 return;
277 }
278
279 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
280 if ( !vl )
281 {
282 return;
283 }
284
285 mChartItem->beginCommand( tr( "Change Chart Source Layer" ) );
286 mChartItem->setSourceLayer( vl );
287 mChartItem->update();
288 mChartItem->endCommand();
289 updateButtonsState();
290}
291
292void QgsLayoutChartWidget::changeSortExpression( const QString &expression, bool )
293{
294 if ( !mChartItem )
295 {
296 return;
297 }
298
299 mChartItem->beginCommand( tr( "Change Chart Source Sort Expression" ) );
300 mChartItem->setSortExpression( expression );
301 mChartItem->update();
302 mChartItem->endCommand();
303}
304
305void QgsLayoutChartWidget::mSortCheckBox_stateChanged( int state )
306{
307 if ( !mChartItem )
308 return;
309
310 if ( state == Qt::Checked )
311 {
312 mSortDirectionButton->setEnabled( true );
313 mSortExpressionWidget->setEnabled( true );
314 }
315 else
316 {
317 mSortDirectionButton->setEnabled( false );
318 mSortExpressionWidget->setEnabled( false );
319 }
320
321 mChartItem->beginCommand( tr( "Toggle Atlas Sorting" ) );
322 mChartItem->setSortFeatures( state == Qt::Checked );
323 mChartItem->update();
324 mChartItem->endCommand();
325}
326
327void QgsLayoutChartWidget::mSortDirectionButton_clicked()
328{
329 if ( !mChartItem )
330 {
331 return;
332 }
333
334 Qt::ArrowType at = mSortDirectionButton->arrowType();
335 at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
336 mSortDirectionButton->setArrowType( at );
337
338 mChartItem->beginCommand( tr( "Change Chart Source Sort Direction" ) );
339 mChartItem->setSortAscending( at == Qt::UpArrow );
340 mChartItem->update();
341 mChartItem->endCommand();
342}
343
344QListWidgetItem *QgsLayoutChartWidget::addSeriesListItem( const QString &name )
345{
346 QListWidgetItem *item = new QListWidgetItem( name, nullptr );
347 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
348 mSeriesListWidget->addItem( item );
349 return item;
350}
351
352void QgsLayoutChartWidget::mSeriesListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
353{
354 mSeriesPropertiesButton->setEnabled( static_cast<bool>( current ) );
355}
356
357void QgsLayoutChartWidget::mSeriesListWidget_itemChanged( QListWidgetItem *item )
358{
359 if ( !mChartItem )
360 {
361 return;
362 }
363
364 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
365 const int idx = mSeriesListWidget->row( item );
366 if ( idx >= seriesList.size() )
367 {
368 return;
369 }
370
371 mChartItem->beginCommand( tr( "Rename Chart Series" ) );
372 seriesList[idx].setName( item->text() );
373 mChartItem->setSeriesList( seriesList );
374 mChartItem->endCommand();
375}
376
377void QgsLayoutChartWidget::mAddSeriesPushButton_clicked()
378{
379 if ( !mChartItem )
380 {
381 return;
382 }
383
384 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
385 const QString itemName = tr( "Series %1" ).arg( seriesList.size() + 1 );
386 addSeriesListItem( itemName );
387
388 mChartItem->beginCommand( tr( "Add Chart Series" ) );
389 seriesList << QgsLayoutItemChart::SeriesDetails( itemName );
390 mChartItem->setSeriesList( seriesList );
391 mChartItem->endCommand();
392 mChartItem->update();
393
394 mSeriesListWidget->setCurrentRow( mSeriesListWidget->count() - 1 );
395 mSeriesListWidget_currentItemChanged( mSeriesListWidget->currentItem(), nullptr );
396 updateButtonsState();
397}
398
399void QgsLayoutChartWidget::mRemoveSeriesPushButton_clicked()
400{
401 QListWidgetItem *item = mSeriesListWidget->currentItem();
402 if ( !item || !mChartItem )
403 {
404 return;
405 }
406
407 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
408 const int idx = mSeriesListWidget->row( item );
409 if ( idx >= seriesList.size() )
410 {
411 return;
412 }
413
414 QListWidgetItem *deletedItem = mSeriesListWidget->takeItem( mSeriesListWidget->row( item ) );
415 delete deletedItem;
416
417 mChartItem->beginCommand( tr( "Remove Chart Series" ) );
418 seriesList.removeAt( idx );
419 mChartItem->setSeriesList( seriesList );
420 mChartItem->endCommand();
421 mChartItem->update();
422 updateButtonsState();
423}
424
425void QgsLayoutChartWidget::mSeriesPropertiesButton_clicked()
426{
427 QListWidgetItem *item = mSeriesListWidget->currentItem();
428 if ( !item || !mChartItem )
429 {
430 return;
431 }
432
433 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
434 const int idx = mSeriesListWidget->row( item );
435 if ( idx >= seriesList.size() )
436 {
437 return;
438 }
439
440 QgsLayoutChartSeriesDetailsWidget *widget = new QgsLayoutChartSeriesDetailsWidget( mChartItem->sourceLayer(), idx, seriesList[idx], this );
441 widget->registerExpressionContextGenerator( mChartItem );
442 widget->setPanelTitle( tr( "Series Details" ) );
443 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
444 if ( !mChartItem )
445 {
446 return;
447 }
448
449 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
450 const int idx = widget->index();
451 if ( idx >= seriesList.size() )
452 {
453 return;
454 }
455
456 mChartItem->beginCommand( tr( "Modify Chart Series" ) );
457 seriesList[idx].setXExpression( widget->xExpression() );
458 seriesList[idx].setYExpression( widget->yExpression() );
459 seriesList[idx].setFilterExpression( widget->filterExpression() );
460 mChartItem->setSeriesList( seriesList );
461 mChartItem->endCommand();
462 mChartItem->update();
463 } );
464
465 openPanel( widget );
466}
467
468void QgsLayoutChartWidget::mLinkedMapComboBox_itemChanged( QgsLayoutItem *item )
469{
470 if ( !mChartItem )
471 {
472 return;
473 }
474
475 mChartItem->beginCommand( tr( "Change Chart Map Item" ) );
476 mChartItem->setMap( qobject_cast<QgsLayoutItemMap *>( item ) );
477 mChartItem->endCommand();
478 mChartItem->update();
479}
480
481void QgsLayoutChartWidget::mFilterOnlyVisibleFeaturesCheckBox_stateChanged( int state )
482{
483 if ( !mChartItem )
484 {
485 return;
486 }
487
488 mChartItem->beginCommand( tr( "Toggle Visible Features Only Filter" ) );
489 const bool useOnlyVisibleFeatures = ( state == Qt::Checked );
490 mChartItem->setFilterOnlyVisibleFeatures( useOnlyVisibleFeatures );
491 mChartItem->endCommand();
492 mChartItem->update();
493
494 //enable/disable map combobox based on state of checkbox
495 mLinkedMapComboBox->setEnabled( state == Qt::Checked );
496 mLinkedMapLabel->setEnabled( state == Qt::Checked );
497}
498
499void QgsLayoutChartWidget::mIntersectAtlasCheckBox_stateChanged( int state )
500{
501 if ( !mChartItem )
502 {
503 return;
504 }
505
506 mChartItem->beginCommand( tr( "Toggle Chart Atlas Filter" ) );
507 const bool filterToAtlas = ( state == Qt::Checked );
508 mChartItem->setFilterToAtlasFeature( filterToAtlas );
509 mChartItem->endCommand();
510 mChartItem->update();
511}
512
513void QgsLayoutChartWidget::updateButtonsState()
514{
515 if ( !mChartItem )
516 {
517 return;
518 }
519
520 const bool enable = qobject_cast<QgsVectorLayer *>( mLayerComboBox->currentLayer() ) != nullptr;
521 mSortCheckBox->setEnabled( enable );
522 mAddSeriesPushButton->setEnabled( enable );
523 mRemoveSeriesPushButton->setEnabled( mSeriesListWidget->count() > 0 );
524}
Base class for 2-dimensional plot/chart/graphs with an X and Y axes.
Definition qgsplot.h:661
void setXMaximum(double maximum)
Sets the maximum value of the x axis.
Definition qgsplot.h:737
double yMaximum() const
Returns the maximum value of the y axis.
Definition qgsplot.h:744
void setYMinimum(double minimum)
Sets the minimum value of the y axis.
Definition qgsplot.h:723
double xMinimum() const
Returns the minimum value of the x axis.
Definition qgsplot.h:702
void setFlipAxes(bool flipAxes)
Sets whether the X and Y axes are flipped.
Definition qgsplot.cpp:1128
QgsPlotAxis & yAxis()
Returns a reference to the plot's y axis.
Definition qgsplot.h:772
bool flipAxes() const
Returns whether the X and Y axes are flipped.
Definition qgsplot.h:816
void setXMinimum(double minimum)
Sets the minimum value of the x axis.
Definition qgsplot.h:709
QgsPlotAxis & xAxis()
Returns a reference to the plot's x axis.
Definition qgsplot.h:758
double yMinimum() const
Returns the minimum value of the y axis.
Definition qgsplot.h:716
void setYMaximum(double maximum)
Sets the maximum value of the y axis.
Definition qgsplot.h:751
double xMaximum() const
Returns the maximum value of the x axis.
Definition qgsplot.h:730
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
static QgsPlotRegistry * plotRegistry()
Returns the application's plot registry, used for plot types.
A widget for selection of layer fields or expression creation.
void setLayer(QgsMapLayer *layer)
Sets the layer used to display the fields and expression.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
static void initPlotWidgets()
Initializes plot widgets.
Definition qgsgui.cpp:461
QString yExpression() const
Returns the Y-axis expression.
QString filterExpression() const
Returns the filter expression.
QString xExpression() const
Returns the X-axis expression.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
void setMasterLayout(QgsMasterLayoutInterface *masterLayout) override
Sets the master layout associated with the item.
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
QgsLayoutChartWidget(QgsLayoutItemChart *chartItem)
constructor
QgsLayoutItemBaseWidget(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutItemBaseWidget, linked with the specified layoutObject.
A layout item subclass that renders chart plots.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
A widget for controlling the common properties of layout items (e.g.
Base class for graphical items within a QgsLayout.
int type() const override
Returns a unique graphics item type identifier.
void changed()
Emitted when the object's properties change.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Interface for master layout type objects, such as print layouts and reports.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
void widgetChanged()
Emitted when the widget state changes.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
virtual QgsPlotWidget * createPlotWidget(QWidget *parent=nullptr)=0
Creates a widget for configuring plot of this type.
double gridIntervalMinor() const
Returns the interval of minor grid lines for the axis.
Definition qgsplot.h:389
double gridIntervalMajor() const
Returns the interval of major grid lines for the axis.
Definition qgsplot.h:403
void setType(Qgis::PlotAxisType type)
Sets the axis type.
Definition qgsplot.cpp:112
void setGridIntervalMajor(double interval)
Sets the interval of major grid lines for the axis.
Definition qgsplot.h:410
void setGridIntervalMinor(double interval)
Sets the interval of minor grid lines for the axis.
Definition qgsplot.h:396
void setLabelInterval(double interval)
Sets the interval of labels for the axis.
Definition qgsplot.h:424
Qgis::PlotAxisType type() const
Returns the axis type.
Definition qgsplot.cpp:107
double labelInterval() const
Returns the interval of labels for the axis.
Definition qgsplot.h:417
QgsPlot * createPlot(const QString &type) const
Creates a new instance of a plot given the type.
QMap< QString, QString > plotTypes() const
Returns a map of available plot types to translated name.
QgsPlotAbstractMetadata * plotMetadata(const QString &type) const
Returns the metadata for the specified plot type.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
virtual QgsPlot * createPlot()=0
Creates a plot defined by the current settings in the widget.
virtual void setPlot(QgsPlot *plot)=0
Sets the widget to match the settings of the plot.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:6854