Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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[
'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[
'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['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
11 changes: 10 additions & 1 deletion DataPlotly/core/plot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,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 +137,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 Down Expand Up @@ -205,6 +212,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