g3w-admin-qplotly 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. g3w_admin_qplotly-0.0.1.dist-info/METADATA +52 -0
  2. g3w_admin_qplotly-0.0.1.dist-info/RECORD +139 -0
  3. g3w_admin_qplotly-0.0.1.dist-info/WHEEL +5 -0
  4. g3w_admin_qplotly-0.0.1.dist-info/licenses/LICENSE +373 -0
  5. g3w_admin_qplotly-0.0.1.dist-info/top_level.txt +1 -0
  6. qplotly/__init__.py +1 -0
  7. qplotly/admin.py +34 -0
  8. qplotly/api/__init__.py +0 -0
  9. qplotly/api/plots/__init__.py +0 -0
  10. qplotly/api/plots/views.py +211 -0
  11. qplotly/api/widgets/__init__.py +0 -0
  12. qplotly/api/widgets/permissions.py +79 -0
  13. qplotly/api/widgets/serializers.py +109 -0
  14. qplotly/api/widgets/views.py +287 -0
  15. qplotly/apiurls.py +132 -0
  16. qplotly/apps.py +11 -0
  17. qplotly/locale/bg/LC_MESSAGES/django.mo +0 -0
  18. qplotly/locale/bg/LC_MESSAGES/django.po +162 -0
  19. qplotly/locale/de/LC_MESSAGES/django.mo +0 -0
  20. qplotly/locale/de/LC_MESSAGES/django.po +126 -0
  21. qplotly/locale/de/LC_MESSAGES/djangojs.mo +0 -0
  22. qplotly/locale/de/LC_MESSAGES/djangojs.po +221 -0
  23. qplotly/locale/es/LC_MESSAGES/django.mo +0 -0
  24. qplotly/locale/es/LC_MESSAGES/django.po +151 -0
  25. qplotly/locale/es/LC_MESSAGES/djangojs.mo +0 -0
  26. qplotly/locale/es/LC_MESSAGES/djangojs.po +232 -0
  27. qplotly/locale/fi/LC_MESSAGES/django.mo +0 -0
  28. qplotly/locale/fi/LC_MESSAGES/django.po +126 -0
  29. qplotly/locale/fi/LC_MESSAGES/djangojs.mo +0 -0
  30. qplotly/locale/fi/LC_MESSAGES/djangojs.po +222 -0
  31. qplotly/locale/fr/LC_MESSAGES/django.mo +0 -0
  32. qplotly/locale/fr/LC_MESSAGES/django.po +160 -0
  33. qplotly/locale/fr/LC_MESSAGES/djangojs.mo +0 -0
  34. qplotly/locale/fr/LC_MESSAGES/djangojs.po +222 -0
  35. qplotly/locale/it/LC_MESSAGES/django.mo +0 -0
  36. qplotly/locale/it/LC_MESSAGES/django.po +163 -0
  37. qplotly/locale/it/LC_MESSAGES/djangojs.mo +0 -0
  38. qplotly/locale/it/LC_MESSAGES/djangojs.po +220 -0
  39. qplotly/locale/pl/LC_MESSAGES/django.mo +0 -0
  40. qplotly/locale/pl/LC_MESSAGES/django.po +129 -0
  41. qplotly/locale/pl/LC_MESSAGES/djangojs.mo +0 -0
  42. qplotly/locale/pl/LC_MESSAGES/djangojs.po +217 -0
  43. qplotly/locale/pt/LC_MESSAGES/django.mo +0 -0
  44. qplotly/locale/pt/LC_MESSAGES/django.po +160 -0
  45. qplotly/locale/ro/LC_MESSAGES/django.mo +0 -0
  46. qplotly/locale/ro/LC_MESSAGES/django.po +128 -0
  47. qplotly/locale/ro/LC_MESSAGES/djangojs.mo +0 -0
  48. qplotly/locale/ro/LC_MESSAGES/djangojs.po +222 -0
  49. qplotly/locale/se/LC_MESSAGES/django.mo +0 -0
  50. qplotly/locale/se/LC_MESSAGES/django.po +126 -0
  51. qplotly/locale/se/LC_MESSAGES/djangojs.mo +0 -0
  52. qplotly/locale/se/LC_MESSAGES/djangojs.po +222 -0
  53. qplotly/migrations/0001_initial.py +26 -0
  54. qplotly/migrations/0002_qplotlywidget_type.py +18 -0
  55. qplotly/migrations/0003_auto_20200925_0838.py +18 -0
  56. qplotly/migrations/0004_auto_20200925_1535.py +25 -0
  57. qplotly/migrations/0005_qplotlywidget_show_on_start_client.py +18 -0
  58. qplotly/migrations/0006_alter_qplotlywidget_options_qplotlywidget_order.py +23 -0
  59. qplotly/migrations/0007_alter_qplotlywidget_options_and_more.py +22 -0
  60. qplotly/migrations/0008_alter_qplotlywidget_order.py +18 -0
  61. qplotly/migrations/0009_qplotlywidget_show_in_sidebar.py +18 -0
  62. qplotly/migrations/0010_remove_qplotlywidget_show_in_sidebar_and_more.py +22 -0
  63. qplotly/migrations/0011_rename_show_poistion_qplotlywidget_show_position.py +18 -0
  64. qplotly/migrations/0012_qplotlywidgetrelation_qplotlywidget_related_widgets.py +34 -0
  65. qplotly/migrations/0013_alter_qplotlywidgetrelation_source_and_more.py +24 -0
  66. qplotly/migrations/0014_alter_qplotlywidgetrelation_source_and_more.py +24 -0
  67. qplotly/migrations/0015_qplotlywidgetrelation_project.py +34 -0
  68. qplotly/migrations/0016_remove_qplotlywidget_project.py +17 -0
  69. qplotly/migrations/__init__.py +0 -0
  70. qplotly/models.py +142 -0
  71. qplotly/receivers.py +356 -0
  72. qplotly/requirements.txt +1 -0
  73. qplotly/server_filters/__init__.py +1 -0
  74. qplotly/server_filters/relations.py +32 -0
  75. qplotly/static/qplotly/icons/2dhistogram.svg +2048 -0
  76. qplotly/static/qplotly/icons/barplot.svg +2048 -0
  77. qplotly/static/qplotly/icons/boxplot.svg +2048 -0
  78. qplotly/static/qplotly/icons/contour.svg +2056 -0
  79. qplotly/static/qplotly/icons/histogram.svg +2048 -0
  80. qplotly/static/qplotly/icons/pie.svg +2048 -0
  81. qplotly/static/qplotly/icons/polar.svg +2055 -0
  82. qplotly/static/qplotly/icons/scatterplot.svg +2048 -0
  83. qplotly/static/qplotly/icons/scatterternary.svg +2055 -0
  84. qplotly/static/qplotly/icons/violin.svg +2878 -0
  85. qplotly/static/qplotly/js/data-widget-qplotlyWidgetList.js +373 -0
  86. qplotly/static/qplotly/js/i18n/bg.js +19 -0
  87. qplotly/static/qplotly/js/i18n/de.js +19 -0
  88. qplotly/static/qplotly/js/i18n/en.js +19 -0
  89. qplotly/static/qplotly/js/i18n/fi.js +19 -0
  90. qplotly/static/qplotly/js/i18n/fr.js +19 -0
  91. qplotly/static/qplotly/js/i18n/index.js +19 -0
  92. qplotly/static/qplotly/js/i18n/it.js +19 -0
  93. qplotly/static/qplotly/js/i18n/ro.js +19 -0
  94. qplotly/static/qplotly/js/i18n/se.js +19 -0
  95. qplotly/static/qplotly/js/i18n/uk.js +19 -0
  96. qplotly/static/qplotly/js/plugin.js +927 -0
  97. qplotly/static/qplotly/js/sidebar.js +373 -0
  98. qplotly/static/qplotly/js/widget.js +9 -0
  99. qplotly/static/qplotly/plotly-1.52.2.min.js +7 -0
  100. qplotly/static/qplotly/polyfill.min.js +3 -0
  101. qplotly/templates/qplotly/include/plot_type_icon.html +52 -0
  102. qplotly/templates/qplotly/layer_action.html +13 -0
  103. qplotly/templates/qplotly/plots_list_order.html +68 -0
  104. qplotly/templates/qplotly/plots_list_order_action.html +14 -0
  105. qplotly/templatetags/__init__.py +0 -0
  106. qplotly/templatetags/qplotly_tags.py +28 -0
  107. qplotly/urls.py +52 -0
  108. qplotly/utils/__init__.py +13 -0
  109. qplotly/utils/models.py +86 -0
  110. qplotly/utils/qplotly_factory.py +699 -0
  111. qplotly/utils/qplotly_settings.py +37 -0
  112. qplotly/vendor/DataPlotly/__init__.py +0 -0
  113. qplotly/vendor/DataPlotly/core/__init__.py +0 -0
  114. qplotly/vendor/DataPlotly/core/plot_factory.py +843 -0
  115. qplotly/vendor/DataPlotly/core/plot_settings.py +322 -0
  116. qplotly/vendor/DataPlotly/core/plot_types/__init__.py +20 -0
  117. qplotly/vendor/DataPlotly/core/plot_types/bar_plot.py +83 -0
  118. qplotly/vendor/DataPlotly/core/plot_types/box.py +56 -0
  119. qplotly/vendor/DataPlotly/core/plot_types/contour.py +43 -0
  120. qplotly/vendor/DataPlotly/core/plot_types/histogram.py +66 -0
  121. qplotly/vendor/DataPlotly/core/plot_types/histogram2d.py +39 -0
  122. qplotly/vendor/DataPlotly/core/plot_types/icons/2dhistogram.svg +2048 -0
  123. qplotly/vendor/DataPlotly/core/plot_types/icons/barplot.svg +2048 -0
  124. qplotly/vendor/DataPlotly/core/plot_types/icons/boxplot.svg +2048 -0
  125. qplotly/vendor/DataPlotly/core/plot_types/icons/contour.svg +2056 -0
  126. qplotly/vendor/DataPlotly/core/plot_types/icons/histogram.svg +2048 -0
  127. qplotly/vendor/DataPlotly/core/plot_types/icons/pie.svg +2048 -0
  128. qplotly/vendor/DataPlotly/core/plot_types/icons/polar.svg +2055 -0
  129. qplotly/vendor/DataPlotly/core/plot_types/icons/scatterplot.svg +2048 -0
  130. qplotly/vendor/DataPlotly/core/plot_types/icons/scatterternary.svg +2055 -0
  131. qplotly/vendor/DataPlotly/core/plot_types/icons/violin.svg +2878 -0
  132. qplotly/vendor/DataPlotly/core/plot_types/pie.py +60 -0
  133. qplotly/vendor/DataPlotly/core/plot_types/plot_type.py +170 -0
  134. qplotly/vendor/DataPlotly/core/plot_types/polar.py +63 -0
  135. qplotly/vendor/DataPlotly/core/plot_types/scatter.py +74 -0
  136. qplotly/vendor/DataPlotly/core/plot_types/ternary.py +129 -0
  137. qplotly/vendor/DataPlotly/core/plot_types/violin.py +62 -0
  138. qplotly/vendor/__init__.py +0 -0
  139. qplotly/views.py +148 -0
@@ -0,0 +1,60 @@
1
+ """
2
+ Pie chart factory
3
+
4
+ .. note:: This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+ """
9
+
10
+ import os
11
+ from plotly import graph_objs
12
+ from qgis.PyQt.QtGui import QIcon
13
+ from qplotly.vendor.DataPlotly.core.plot_types.plot_type import PlotType
14
+
15
+
16
+ class PieChartFactory(PlotType):
17
+ """
18
+ Factory for pie charts
19
+ """
20
+
21
+ @staticmethod
22
+ def type_name():
23
+ return 'pie'
24
+
25
+ @staticmethod
26
+ def name():
27
+ return PlotType.tr('Pie Chart')
28
+
29
+ @staticmethod
30
+ def icon():
31
+ return QIcon(os.path.join(os.path.dirname(__file__), 'icons/pie.svg'))
32
+
33
+ @staticmethod
34
+ def create_trace(settings):
35
+ return [graph_objs.Pie(
36
+ labels=settings.x,
37
+ values=settings.y,
38
+ marker={
39
+ 'colors': settings.data_defined_colors if settings.data_defined_colors else [settings.properties['in_color']]
40
+ },
41
+ name=settings.properties['custom'][0],
42
+ hole=settings.properties.get('pie_hole', 0)
43
+ )]
44
+
45
+ @staticmethod
46
+ def create_layout(settings):
47
+ layout = super(PieChartFactory, PieChartFactory).create_layout(settings)
48
+
49
+ layout['xaxis'].update(title='')
50
+ layout['xaxis'].update(showgrid=False)
51
+ layout['xaxis'].update(zeroline=False)
52
+ layout['xaxis'].update(showline=False)
53
+ layout['xaxis'].update(showticklabels=False)
54
+ layout['yaxis'].update(title='')
55
+ layout['yaxis'].update(showgrid=False)
56
+ layout['yaxis'].update(zeroline=False)
57
+ layout['yaxis'].update(showline=False)
58
+ layout['yaxis'].update(showticklabels=False)
59
+
60
+ return layout
@@ -0,0 +1,170 @@
1
+ """
2
+ Base class for plot type subclasses
3
+
4
+ .. note:: This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+ """
9
+
10
+ from plotly import graph_objs
11
+ from qgis.PyQt.QtCore import QCoreApplication
12
+
13
+
14
+ def from_qfont_to_plotly(style, color):
15
+ """
16
+ Converts a QFont to a Plotly basic font settings dictionary
17
+ """
18
+ if style is not None and color is not None:
19
+ return {
20
+ "size": style.pointSize() or 10,
21
+ "color": color.name() or "black",
22
+ "family": style.family() or "Arial",
23
+ }
24
+ return {
25
+ "size": 10,
26
+ "color": "black",
27
+ "family": "Arial",
28
+ }
29
+
30
+
31
+ class PlotType:
32
+ """
33
+ Base class for plot subclasses
34
+ """
35
+
36
+ @staticmethod
37
+ def type_name():
38
+ """
39
+ Returns the unique type name for this plot type
40
+ """
41
+ return ''
42
+
43
+ @staticmethod
44
+ def name():
45
+ """
46
+ Returns the friendly translated name for the plot type
47
+ """
48
+ return ''
49
+
50
+ @staticmethod
51
+ def icon():
52
+ """
53
+ Returns a path to an icon for this chart type
54
+ """
55
+ return ''
56
+
57
+ @staticmethod
58
+ def create_trace(settings): # pylint: disable=W0613
59
+ """
60
+ Returns a new trace using the specified plot settings
61
+ """
62
+ return None
63
+
64
+ @staticmethod
65
+ def create_layout(settings):
66
+ """
67
+ Returns a new layout using the specified plot settings
68
+ """
69
+
70
+ # flip the variables according to the box orientation
71
+ if settings.properties['box_orientation'] == 'h':
72
+ y_title = settings.data_defined_y_title if settings.data_defined_y_title != ''\
73
+ else settings.layout['y_title']
74
+ x_title = settings.data_defined_x_title if settings.data_defined_x_title != ''\
75
+ else settings.layout['x_title']
76
+ else:
77
+ x_title = settings.data_defined_x_title if settings.data_defined_x_title != ''\
78
+ else settings.layout['x_title']
79
+ y_title = settings.data_defined_y_title if settings.data_defined_y_title != ''\
80
+ else settings.layout['y_title']
81
+
82
+ range_x = None
83
+ if settings.layout.get('x_min', None) is not None and settings.layout.get('x_max', None) is not None:
84
+ range_x = [
85
+ settings.data_defined_x_min if settings.data_defined_x_min else settings.layout['x_min'],
86
+ settings.data_defined_x_max if settings.data_defined_x_max else settings.layout['x_max']
87
+ ]
88
+ range_y = None
89
+ if settings.layout.get('y_min', None) is not None and settings.layout.get('y_max', None) is not None:
90
+ range_y = [
91
+ settings.data_defined_y_min if settings.data_defined_y_min else settings.layout['y_min'],
92
+ settings.data_defined_y_max if settings.data_defined_y_max else settings.layout['y_max']
93
+ ]
94
+
95
+ bg_color = settings.layout.get('bg_color', 'rgb(255,255,255)')
96
+
97
+ # add font size parameter from the title setting
98
+ title = settings.data_defined_title if settings.data_defined_title else settings.layout['title']
99
+ if isinstance(title, str) or title is None:
100
+ title = {"text": title}
101
+
102
+ title["font"] = {
103
+ "size": settings.layout.get('font_title_size', 10),
104
+ "color": settings.layout.get('font_title_color', "#000"),
105
+ "family": settings.layout.get('font_title_family', "Arial"),
106
+ }
107
+
108
+ layout = graph_objs.Layout(
109
+ showlegend=settings.layout['legend'],
110
+ legend={'orientation': settings.layout['legend_orientation']},
111
+ title=title,
112
+ xaxis={
113
+ 'title': x_title,
114
+ 'titlefont': {
115
+ "size": settings.layout.get('font_xlabel_size', 10),
116
+ "color": settings.layout.get('font_xlabel_color', "#000"),
117
+ "family": settings.layout.get('font_xlabel_family', "Arial"),
118
+ },
119
+ 'autorange': settings.layout['x_inv'],
120
+ 'range': range_x,
121
+ 'tickfont': {
122
+ "size": settings.layout.get('font_xticks_size', 10),
123
+ "color": settings.layout.get('font_xticks_color', "#000"),
124
+ "family": settings.layout.get('font_xticks_family', "Arial"),
125
+ },
126
+ 'gridcolor': settings.layout.get('gridcolor', '#bdbfc0')
127
+ },
128
+ yaxis={
129
+ 'title': y_title,
130
+ 'titlefont': {
131
+ "size": settings.layout.get('font_ylabel_size', 10),
132
+ "color": settings.layout.get('font_ylabel_color', "#000"),
133
+ "family": settings.layout.get('font_ylabel_family', "Arial"),
134
+ },
135
+ 'autorange': settings.layout['y_inv'],
136
+ 'range': range_y,
137
+ 'tickfont': {
138
+ "size": settings.layout.get('font_yticks_size', 10),
139
+ "color": settings.layout.get('font_yticks_color', "#000"),
140
+ "family": settings.layout.get('font_yticks_family', "Arial"),
141
+ },
142
+ 'gridcolor': settings.layout.get('gridcolor', '#bdbfc0')
143
+ },
144
+ paper_bgcolor=bg_color,
145
+ plot_bgcolor=bg_color
146
+ )
147
+
148
+ # update the x and y axis and add the linear and log only if the data are numeric
149
+ # pass if field is empty
150
+ try:
151
+ if isinstance(settings.x[0], (int, float)):
152
+ layout['xaxis'].update(type=settings.layout['x_type'])
153
+ except: # pylint:disable=bare-except # noqa: F401
154
+ pass
155
+ try:
156
+ if isinstance(settings.y[0], (int, float)):
157
+ layout['yaxis'].update(type=settings.layout['y_type'])
158
+ except: # pylint:disable=bare-except # noqa: F401
159
+ pass
160
+
161
+ return layout
162
+
163
+ @staticmethod
164
+ def tr(string, context=''):
165
+ """
166
+ Translates a string
167
+ """
168
+ if context == '':
169
+ context = 'Types'
170
+ return QCoreApplication.translate(context, string)
@@ -0,0 +1,63 @@
1
+ """
2
+ Polar chart factory
3
+
4
+ .. note:: This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+ """
9
+
10
+ import os
11
+ from plotly import graph_objs
12
+ from qgis.PyQt.QtGui import QIcon
13
+ from qplotly.vendor.DataPlotly.core.plot_types.plot_type import PlotType
14
+
15
+
16
+ class PolarChartFactory(PlotType):
17
+ """
18
+ Factory for polar charts
19
+ """
20
+
21
+ @staticmethod
22
+ def type_name():
23
+ return 'polar'
24
+
25
+ @staticmethod
26
+ def name():
27
+ return PlotType.tr('Polar Plot')
28
+
29
+ @staticmethod
30
+ def icon():
31
+ return QIcon(os.path.join(os.path.dirname(__file__), 'icons/polar.svg'))
32
+
33
+ @staticmethod
34
+ def create_trace(settings):
35
+ return [graph_objs.Scatterpolar(
36
+ r=settings.y,
37
+ theta=settings.x,
38
+ mode=settings.properties['marker'],
39
+ name=settings.properties['y_name'],
40
+ marker={
41
+ "color": settings.data_defined_colors if settings.data_defined_colors else settings.properties['in_color'],
42
+ "size": settings.data_defined_marker_sizes if settings.data_defined_marker_sizes else settings.properties['marker_size'],
43
+ "symbol": settings.properties['marker_symbol'],
44
+ "line": {
45
+ "color": settings.properties['out_color'],
46
+ "width": settings.properties['marker_width']
47
+ }
48
+ },
49
+ line={
50
+ "color": settings.properties['in_color'],
51
+ "width": settings.data_defined_stroke_widths if settings.data_defined_stroke_widths else settings.properties['marker_width'],
52
+ "dash": settings.properties['line_dash']
53
+ },
54
+ opacity=settings.properties['opacity'],
55
+ )]
56
+
57
+ @staticmethod
58
+ def create_layout(settings):
59
+ layout = super(PolarChartFactory, PolarChartFactory).create_layout(settings)
60
+
61
+ layout['polar'] = settings.layout['polar']
62
+
63
+ return layout
@@ -0,0 +1,74 @@
1
+ """
2
+ Base class for trace factories
3
+
4
+ .. note:: This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+ """
9
+
10
+ import os
11
+ from plotly import graph_objs
12
+ from qgis.PyQt.QtGui import QIcon
13
+ from qplotly.vendor.DataPlotly.core.plot_types.plot_type import PlotType
14
+
15
+
16
+ class ScatterPlotFactory(PlotType):
17
+ """
18
+ Factory for scatter plots
19
+ """
20
+
21
+ @staticmethod
22
+ def type_name():
23
+ return 'scatter'
24
+
25
+ @staticmethod
26
+ def name():
27
+ return PlotType.tr('Scatter Plot')
28
+
29
+ @staticmethod
30
+ def icon():
31
+ return QIcon(os.path.join(os.path.dirname(__file__), 'icons/scatterplot.svg'))
32
+
33
+ @staticmethod
34
+ def create_trace(settings):
35
+
36
+ if settings.properties.get('hover_label_text') is not None:
37
+ mode = settings.properties.get('marker') + \
38
+ settings.properties.get('hover_label_text')
39
+ else:
40
+ mode = settings.properties.get('marker')
41
+
42
+ return [graph_objs.Scatter(
43
+ x=settings.x,
44
+ y=settings.y,
45
+ mode=mode,
46
+ textposition="top center",
47
+ name=settings.data_defined_legend_title if settings.data_defined_legend_title != '' else settings.properties['name'],
48
+ ids=settings.feature_ids,
49
+ customdata=settings.properties['custom'],
50
+ text=settings.additional_hover_text,
51
+ hoverinfo=settings.properties['hover_text'],
52
+ marker={'color': settings.data_defined_colors if settings.data_defined_colors else settings.properties['in_color'],
53
+ 'colorscale': settings.properties['color_scale'],
54
+ 'showscale': settings.properties['show_colorscale_legend'],
55
+ 'reversescale': settings.properties['invert_color_scale'],
56
+ 'colorbar': {
57
+ 'len': 0.8},
58
+ 'size': settings.data_defined_marker_sizes if settings.data_defined_marker_sizes else settings.properties['marker_size'],
59
+ 'symbol': settings.properties['marker_symbol'],
60
+ 'line': {'color': settings.data_defined_stroke_colors if settings.data_defined_stroke_colors else settings.properties['out_color'],
61
+ 'width': settings.data_defined_stroke_widths if settings.data_defined_stroke_widths else settings.properties['marker_width']}
62
+ },
63
+ line={'width': settings.properties['marker_width'],
64
+ 'dash': settings.properties['line_dash']},
65
+ opacity=settings.properties['opacity']
66
+ )]
67
+
68
+ @staticmethod
69
+ def create_layout(settings):
70
+ layout = super(ScatterPlotFactory, ScatterPlotFactory).create_layout(settings)
71
+
72
+ layout['xaxis'].update(rangeslider=settings.layout['range_slider'])
73
+
74
+ return layout
@@ -0,0 +1,129 @@
1
+ """
2
+ Ternary plot factory
3
+
4
+ .. note:: This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+ """
9
+
10
+ import os
11
+ from plotly import graph_objs
12
+ from qgis.PyQt.QtGui import QIcon
13
+ from qplotly.vendor.DataPlotly.core.plot_types.plot_type import PlotType
14
+
15
+
16
+ class TernaryFactory(PlotType):
17
+ """
18
+ Factory for ternary plots
19
+ """
20
+
21
+ @staticmethod
22
+ def type_name():
23
+ return 'ternary'
24
+
25
+ @staticmethod
26
+ def name():
27
+ return PlotType.tr('Ternary Plot')
28
+
29
+ @staticmethod
30
+ def icon():
31
+ return QIcon(os.path.join(os.path.dirname(__file__), 'icons/scatterternary.svg'))
32
+
33
+ @staticmethod
34
+ def create_trace(settings):
35
+ # prepare the hover text to display if the additional combobox is empty or not
36
+ # this setting is necessary to overwrite the standard hovering labels
37
+ if not settings.additional_hover_text:
38
+ text = [
39
+ settings.properties['x_name'] + ': {}'.format(
40
+ settings.x[k]) + '<br>{}: {}'.format(
41
+ settings.properties['y_name'],
42
+ settings.y[k]) + '<br>{}: {}'.format(
43
+ settings.properties['z_name'], settings.z[k]) for k
44
+ in
45
+ range(len(settings.x))]
46
+ else:
47
+ text = [
48
+ settings.properties['x_name'] + ': {}'.format(
49
+ settings.x[k]) + '<br>{}: {}'.format(
50
+ settings.properties['y_name'],
51
+ settings.y[k]) + '<br>{}: {}'.format(
52
+ settings.properties['z_name'],
53
+ settings.z[k]) + '<br>{}'.format(
54
+ settings.additional_hover_text[k]) for k in
55
+ range(len(settings.x))]
56
+
57
+ return [graph_objs.Scatterternary(
58
+ a=settings.x,
59
+ b=settings.y,
60
+ c=settings.z,
61
+ name='{} + {} + {}'.format(settings.properties['x_name'],
62
+ settings.properties['y_name'],
63
+ settings.properties['z_name']),
64
+ hoverinfo='text',
65
+ text=text,
66
+ mode='markers',
67
+ marker={
68
+ 'color': settings.data_defined_colors if settings.data_defined_colors else settings.properties['in_color'],
69
+ 'colorscale': settings.properties['color_scale'],
70
+ 'showscale': settings.properties['show_colorscale_legend'],
71
+ 'reversescale':settings.properties['invert_color_scale'],
72
+ 'colorbar': {
73
+ 'len': 0.8
74
+ },
75
+ 'size': settings.data_defined_marker_sizes if settings.data_defined_marker_sizes else settings.properties['marker_size'],
76
+ 'symbol': settings.properties['marker_symbol'],
77
+ 'line': {
78
+ 'color': settings.data_defined_stroke_colors if settings.data_defined_stroke_colors else settings.properties['out_color'],
79
+ 'width': settings.data_defined_stroke_widths if settings.data_defined_stroke_widths else settings.properties['marker_width']
80
+ }
81
+ },
82
+ opacity=settings.properties['opacity']
83
+ )]
84
+
85
+ @staticmethod
86
+ def create_layout(settings):
87
+ layout = super(TernaryFactory, TernaryFactory).create_layout(settings)
88
+
89
+ # flip the variables according to the box orientation
90
+ if settings.properties['box_orientation'] == 'h':
91
+ x_title = settings.data_defined_y_title if settings.data_defined_y_title != ''\
92
+ else settings.layout['y_title']
93
+ y_title = settings.data_defined_x_title if settings.data_defined_x_title != ''\
94
+ else settings.layout['x_title']
95
+ else:
96
+ x_title = settings.data_defined_x_title if settings.data_defined_x_title != ''\
97
+ else settings.layout['x_title']
98
+ y_title = settings.data_defined_y_title if settings.data_defined_y_title != ''\
99
+ else settings.layout['y_title']
100
+ z_title = settings.data_defined_z_title if settings.data_defined_z_title != '' \
101
+ else settings.layout['z_title']
102
+
103
+ layout['xaxis'].update(title='')
104
+ layout['xaxis'].update(showgrid=False)
105
+ layout['xaxis'].update(zeroline=False)
106
+ layout['xaxis'].update(showline=False)
107
+ layout['xaxis'].update(showticklabels=False)
108
+ layout['yaxis'].update(title='')
109
+ layout['yaxis'].update(showgrid=False)
110
+ layout['yaxis'].update(zeroline=False)
111
+ layout['yaxis'].update(showline=False)
112
+ layout['yaxis'].update(showticklabels=False)
113
+ layout['ternary'] = {
114
+ 'sum': 100,
115
+ 'aaxis': {
116
+ 'title': x_title,
117
+ 'ticksuffix': '%',
118
+ },
119
+ 'baxis': {
120
+ 'title': y_title,
121
+ 'ticksuffix': '%'
122
+ },
123
+ 'caxis': {
124
+ 'title': z_title,
125
+ 'ticksuffix': '%'
126
+ },
127
+ }
128
+
129
+ return layout
@@ -0,0 +1,62 @@
1
+ """
2
+ Violin chart factory
3
+
4
+ .. note:: This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+ """
9
+
10
+ import os
11
+ from plotly import graph_objs
12
+ from qgis.PyQt.QtGui import QIcon
13
+ from qplotly.vendor.DataPlotly.core.plot_types.plot_type import PlotType
14
+
15
+
16
+ class ViolinFactory(PlotType):
17
+ """
18
+ Factory for violin charts
19
+ """
20
+
21
+ @staticmethod
22
+ def type_name():
23
+ return 'violin'
24
+
25
+ @staticmethod
26
+ def name():
27
+ return PlotType.tr('Violin Plot')
28
+
29
+ @staticmethod
30
+ def icon():
31
+ return QIcon(os.path.join(os.path.dirname(__file__), 'icons/violin.svg'))
32
+
33
+ @staticmethod
34
+ def create_trace(settings):
35
+ # flip the variables according to the box orientation
36
+ if settings.properties['box_orientation'] == 'h':
37
+ y = settings.x
38
+ x = settings.y
39
+ else:
40
+ x = settings.x
41
+ y = settings.y
42
+
43
+ return [graph_objs.Violin(
44
+ x=x or None,
45
+ y=y,
46
+ name=settings.data_defined_legend_title if settings.data_defined_legend_title != '' else settings.properties[
47
+ 'name'],
48
+ customdata=settings.properties['custom'],
49
+ orientation=settings.properties['box_orientation'],
50
+ points=settings.properties['box_outliers'],
51
+ fillcolor=settings.properties['in_color'],
52
+ line={
53
+ 'color': settings.properties['out_color'],
54
+ 'width': settings.properties['marker_width']
55
+ },
56
+ opacity=settings.properties['opacity'],
57
+ meanline={
58
+ 'visible': settings.properties['show_mean_line']
59
+ },
60
+ side=settings.properties['violin_side'],
61
+ box_visible=settings.properties['violin_box']
62
+ )]
File without changes