Skip to content
Open
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

## 4.3.1 - 2025-07-08

- Fix regression when loading projects

## 4.3.0 - 2025-07-07

- New radar plot type thanks to @soaubier Oslandia
- Fix error with title thanks to @florianneukirchen
- Add help link to help menu and metadata thanks to @Gustry

## 4.2.0 - 2024-10-24

- Fix loading of the plugin when used with `qgis_process`, contribution from @Gustry
Expand Down
36 changes: 34 additions & 2 deletions DataPlotly/core/plot_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ def add_source_field_or_expression(field_or_expression):
z_expression, z_needs_geom, z_attrs = add_source_field_or_expression(self.settings.properties['z_name']) if \
self.settings.properties[
'z_name'] else (None, False, set())
y_label_expression, _, y_label_attrs = add_source_field_or_expression(self.settings.properties['y_combo_radar_label']) if \
self.settings.properties.get(
'y_combo_radar_label') else (None, False, set())
y_fields_expression = QgsExpression("array(" + ", ".join([f'"{field_name}"'
for field_name in self.settings.properties['y_fields_combo'].split(", ")
]) + ")") if \
self.settings.properties.get(
'y_fields_combo') else None
additional_info_expression, additional_needs_geom, additional_attrs = add_source_field_or_expression(
self.settings.layout['additional_info_expression']) if self.settings.layout[
'additional_info_expression'] else (None, False, set())
Expand All @@ -171,6 +179,7 @@ def add_source_field_or_expression(field_or_expression):
x_attrs,
y_attrs,
z_attrs,
y_label_attrs,
additional_attrs)

request = QgsFeatureRequest()
Expand Down Expand Up @@ -230,6 +239,9 @@ def add_source_field_or_expression(field_or_expression):
colors = []
stroke_colors = []
stroke_widths = []
y_radar_labels = []
y_radar_values = []

for f in it:
if visible_geom_engine and not visible_geom_engine.intersects(f.geometry().constGet()):
continue
Expand Down Expand Up @@ -267,6 +279,22 @@ def add_source_field_or_expression(field_or_expression):
if z == NULL or z is None:
continue

y_radar_label = None
if y_label_expression:
y_radar_label = y_label_expression.evaluate(context)
if y_radar_label == NULL or y_radar_label is None:
continue
elif self.settings.properties.get('y_combo_radar_label'):
y_radar_label = f[self.settings.properties['y_combo_radar_label']]
if y_radar_label == NULL or y_radar_label is None:
continue

y_radar_value = None
if y_fields_expression:
y_radar_value = y_fields_expression.evaluate(context)
if y_radar_value == NULL or y_radar_value is None:
continue

if additional_info_expression:
additional_hover_text.append(
additional_info_expression.evaluate(context))
Expand All @@ -280,6 +308,10 @@ def add_source_field_or_expression(field_or_expression):
yy.append(y)
if z is not None:
zz.append(z)
if y_radar_label is not None:
y_radar_labels.append(y_radar_label)
if y_radar_value is not None:
y_radar_values.append(y_radar_value)

if self.settings.data_defined_properties.isActive(PlotSettings.PROPERTY_MARKER_SIZE):
default_value = self.settings.properties['marker_size']
Expand Down Expand Up @@ -338,6 +370,8 @@ def add_source_field_or_expression(field_or_expression):
self.settings.x = xx
self.settings.y = yy
self.settings.z = zz
self.settings.y_radar_labels = y_radar_labels
self.settings.y_radar_values = y_radar_values
if marker_sizes:
self.settings.data_defined_marker_sizes = marker_sizes
if colors:
Expand Down Expand Up @@ -699,7 +733,6 @@ def build_figure(self) -> str:

with open(self.plot_path, "w", encoding="utf8") as f:
f.write(self.build_html(config))

return self.plot_path

def build_figures(self, plot_type, ptrace, config=None) -> str:
Expand Down Expand Up @@ -740,7 +773,6 @@ def build_figures(self, plot_type, ptrace, config=None) -> str:
self.layout = PlotFactory.PLOT_TYPES[plot_type].create_layout(
self.settings)
figures = go.Figure(data=ptrace, layout=self.layout)

else:
figures = go.Figure(data=ptrace, layout=self.layout)

Expand Down
20 changes: 19 additions & 1 deletion DataPlotly/core/plot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class PlotSettings: # pylint: disable=too-many-instance-attributes
PROPERTY_FONT_YTICKS_SIZE = 27
PROPERTY_FONT_YTICKS_FAMILY = 28
PROPERTY_FONT_YTICKS_COLOR = 29
PROPERTY_FONT_LEGEND_SIZE = 30
PROPERTY_FONT_LEGEND_FAMILY = 31
PROPERTY_FONT_LEGEND_COLOR = 32

DYNAMIC_PROPERTIES = {
PROPERTY_FILTER: QgsPropertyDefinition('filter', 'Feature filter', QgsPropertyDefinition.Boolean),
Expand All @@ -77,6 +80,9 @@ class PlotSettings: # pylint: disable=too-many-instance-attributes
PROPERTY_FONT_YTICKS_SIZE: QgsPropertyDefinition('font_yticks_size', 'Font yticks size', QgsPropertyDefinition.String),
PROPERTY_FONT_YTICKS_FAMILY: QgsPropertyDefinition('font_yticks_family', 'Font yticks family', QgsPropertyDefinition.String),
PROPERTY_FONT_YTICKS_COLOR: QgsPropertyDefinition('font_yticks_color', 'Font yticks color', QgsPropertyDefinition.ColorWithAlpha),
PROPERTY_FONT_LEGEND_SIZE: QgsPropertyDefinition('font_legend_size', 'Font yticks size', QgsPropertyDefinition.String),
PROPERTY_FONT_LEGEND_FAMILY: QgsPropertyDefinition('font_legend_family', 'Font yticks family', QgsPropertyDefinition.String),
PROPERTY_FONT_LEGEND_COLOR: QgsPropertyDefinition('font_legend_color', 'Font yticks color', QgsPropertyDefinition.ColorWithAlpha),
PROPERTY_X_TITLE: QgsPropertyDefinition('x_title', 'X title', QgsPropertyDefinition.String),
PROPERTY_Y_TITLE: QgsPropertyDefinition('y_title', 'Y title', QgsPropertyDefinition.String),
PROPERTY_Z_TITLE: QgsPropertyDefinition('z_title', 'Z title', QgsPropertyDefinition.String),
Expand All @@ -101,6 +107,8 @@ def __init__(self, plot_type: str = 'scatter', properties: dict = None, layout:
'x_name': '',
'y_name': '',
'z_name': '',
'y_combo_radar_label': '',
'y_fields_combo': '',
'in_color': '#8ebad9',
'out_color': '#1f77b4',
'marker_width': 1,
Expand Down Expand Up @@ -135,7 +143,12 @@ def __init__(self, plot_type: str = 'scatter', properties: dict = None, layout:
'show_mean_line': False,
'layout_filter_by_map': False,
'layout_filter_by_atlas': False,
'pie_hole': 0
'pie_hole': 0,
'fill': False,
'line_combo_threshold': 'Dot Line',
'line_dash_threshold': 'dash',
'threshold_value': 1,
'threshold': False
}

# layout nested dictionary
Expand All @@ -162,6 +175,9 @@ def __init__(self, plot_type: str = 'scatter', properties: dict = None, layout:
'font_yticks_size': 10,
'font_yticks_family': "Arial",
'font_yticks_color': "#000000",
'font_legend_size': 10,
'font_legend_family': "Arial",
'font_legend_color': "#000000",
'xaxis': None,
'bar_mode': None,
'x_type': None,
Expand Down Expand Up @@ -205,6 +221,8 @@ def __init__(self, plot_type: str = 'scatter', properties: dict = None, layout:
self.x = []
self.y = []
self.z = []
self.y_radar_labels = []
self.y_radar_values = []
self.feature_ids = []
self.additional_hover_text = []
self.data_defined_marker_sizes = []
Expand Down
1 change: 1 addition & 0 deletions DataPlotly/core/plot_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .histogram import HistogramFactory
from .pie import PieChartFactory
from .polar import PolarChartFactory
from .radar import RadarChartFactory
from .scatter import ScatterPlotFactory
from .ternary import TernaryFactory
from .violin import ViolinFactory
Loading