Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,14 @@ Thumbs.db

# Test
*.qgs~

# QtCreator
*.creator
*.creator.user
*.files
*.cflags
*.config
*.cxxflags
*.includes
.qtc_clangd/

1 change: 0 additions & 1 deletion DataPlotly/core/plot_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def add_source_field_or_expression(field_or_expression):
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())

attrs = set().union(self.settings.data_defined_properties.referencedFields(),
x_attrs,
y_attrs,
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 @@ -18,3 +18,4 @@
from .scatter import ScatterPlotFactory
from .ternary import TernaryFactory
from .violin import ViolinFactory
from .filledline import FilledLineFactory
59 changes: 59 additions & 0 deletions DataPlotly/core/plot_types/filledline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
Base class for trace factories

.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""

import os
from plotly import graph_objs
from qgis.PyQt.QtGui import QIcon
from DataPlotly.core.plot_types.plot_type import PlotType


class FilledLineFactory(PlotType):
"""
Factory for filled line scatter plots
"""

@staticmethod
def type_name():
return 'filledline'

@staticmethod
def name():
return PlotType.tr('Filled Line Plot')

@staticmethod
def icon():
return QIcon(os.path.join(os.path.dirname(__file__), 'icons/filledline.svg'))

@staticmethod
def create_trace(settings):
# Only add filled band if both arrays present and lengths match the x axis
if settings.y and settings.z and isinstance(settings.y, (list, tuple)) and isinstance(settings.z, (list, tuple)):
if len(settings.x) == len(settings.y) == len(settings.z):
return [graph_objs.Scatter(
x=settings.x+settings.x[::-1], #forward and backward in reverse
y=settings.y+settings.z[::-1], #upper line + lower line in reverse order
mode='none', # no lines
fill='toself',
fillcolor=settings.data_defined_colors if settings.data_defined_colors else settings.properties.get('fill_color'),
showlegend=True,
hoverinfo='skip',
ids=settings.feature_ids,
name=settings.data_defined_legend_title if settings.data_defined_legend_title != '' else settings.properties['name']
)]
else:
# lengths mismatch -> skip fill to avoid runtime errors (you may want to log/warn)
pass

@staticmethod
def create_layout(settings):
layout = super(FilledLineFactory, FilledLineFactory).create_layout(settings)

layout['xaxis'].update(rangeslider=settings.layout['range_slider'])

return layout
99 changes: 99 additions & 0 deletions DataPlotly/core/plot_types/icons/filledline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions DataPlotly/core/plot_types/plot_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def create_layout(settings):
"color": settings.layout.get('font_xticks_color', "#000"),
"family": settings.layout.get('font_xticks_family', "Arial"),
},
'gridcolor': settings.layout.get('gridcolor', '#bdbfc0')
'gridcolor': settings.layout.get('gridcolor', '#bdbfc0'),
'zerolinecolor': settings.layout.get('gridcolor', '#bdbfc0')
},
yaxis={
'title': {
Expand All @@ -149,7 +150,8 @@ def create_layout(settings):
"color": settings.layout.get('font_yticks_color', "#000"),
"family": settings.layout.get('font_yticks_family', "Arial"),
},
'gridcolor': settings.layout.get('gridcolor', '#bdbfc0')
'gridcolor': settings.layout.get('gridcolor', '#bdbfc0'),
'zerolinecolor': settings.layout.get('gridcolor', '#bdbfc0')
},
paper_bgcolor=bg_color,
plot_bgcolor=bg_color
Expand Down
Loading