Skip to content

Commit

Permalink
Fix bar width (#321)
Browse files Browse the repository at this point in the history
* set the initial value to Auto, clearValue to Auto and tooltip

* tweak the bar width value to pass to plotly

* add changelog info

* bump new release and minimum QGIS version

* no more 3.22 in docker
  • Loading branch information
ghtmtt committed May 12, 2023
1 parent 121f43d commit aa4bf76
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

strategy:
matrix:
docker_tags: [release-3_22, release-3_28, latest]
docker_tags: [release-3_28, latest]

steps:

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

## 4.0.1 2023-05-12

- tweak the bar width values, usefull with time series
- minimum QGIS version to 3.28 LTR

## 4.0.0 - 2023-04-17

- multiple plot docks thanks to @jdlom
Expand Down
11 changes: 10 additions & 1 deletion DataPlotly/core/plot_types/bar_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def create_trace(settings):
x = settings.x
y = settings.y

# tweak the width value
if settings.data_defined_marker_sizes:
width = settings.data_defined_marker_sizes
# set to None if 0.0 or Auto, useful especially for date/datetime data
elif settings.properties['marker_size'] == 0.0:
width = None
else:
width = settings.properties['marker_size']

return [graph_objs.Bar(
x=x,
y=y,
Expand All @@ -62,7 +71,7 @@ def create_trace(settings):
'color': settings.data_defined_stroke_colors if settings.data_defined_stroke_colors else settings.properties['out_color'],
'width': settings.data_defined_stroke_widths if settings.data_defined_stroke_widths else settings.properties['marker_width']}
},
width=settings.data_defined_marker_sizes if settings.data_defined_marker_sizes else settings.properties['marker_size'],
width=width,
opacity=settings.properties['opacity']
)]

Expand Down
4 changes: 3 additions & 1 deletion DataPlotly/gui/plot_settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,9 @@ def refreshWidgets(self): # pylint: disable=too-many-statements,too-many-branch
# change the label and the spin box value when the bar plot is chosen
if self.ptype == 'bar':
self.marker_size_lab.setText(self.tr('Bar width'))
self.marker_size.setValue(0.5)
self.marker_size.setValue(0.0)
self.marker_size.setClearValue(0.0, self.tr('Auto'))
self.marker_size.setToolTip(self.tr('Set to Auto to automatically resize the bar width'))

# change the label and the spin box value when the scatter plot is chosen
if self.ptype == 'scatter':
Expand Down
2 changes: 1 addition & 1 deletion DataPlotly/metadata.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[general]
name=Data Plotly
qgisMinimumVersion=3.4
qgisMinimumVersion=3.28
qgisMaximumVersion=3.98
description=D3 Plots for QGIS
author=Matteo Ghetta (Faunalia)
Expand Down

0 comments on commit aa4bf76

Please sign in to comment.