Skip to content

Commit 58a7621

Browse files
authored
Merge pull request #140 from Dessia-tech/dev
Towards 0.9.0
2 parents c7df9a3 + b233004 commit 58a7621

File tree

9 files changed

+321
-86
lines changed

9 files changed

+321
-86
lines changed

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
"format": "prettier --write \"src/**/*.ts\"",
1212
"lint": "tslint -p tsconfig.json"
1313
},
14+
"browser": {
15+
"fs": false,
16+
"path": false,
17+
"os": false
18+
},
1419
"repository": {
1520
"type": "git",
1621
"url": "git+https://github.com/Dessia-tech/plot_data.git"
@@ -39,6 +44,7 @@
3944
"dependencies": {
4045
"commitlint": "^13.2.1",
4146
"fast-deep-equal": "^3.1.3",
47+
"fs": "^0.0.1-security",
4248
"html-webpack-plugin": "^5.5.0",
4349
"ignore-errors": "^2.0.0",
4450
"ts-loader": "^9.2.6",

plot_data/core.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def to_dict(self):
5656
Redefines DessiaObject's to_dict() in order to remove keys where
5757
value is None.
5858
"""
59-
dict_ = DessiaObject.to_dict(self)
59+
dict_ = DessiaObject.to_dict(self, use_pointers=False)
6060
del dict_['object_class']
6161
new_dict_ = delete_none_from_dict(dict_)
6262
return new_dict_
@@ -167,21 +167,28 @@ class TextStyle(DessiaObject):
167167
"ideographic" or "bottom". More info on \
168168
https://www.w3schools.com/tags/canvas_textbaseline.asp
169169
:type text_align_y: str
170+
:param bold:
171+
:type bold: bool
172+
:param italic:
173+
:type italic: bool
174+
:param angle: Text angle in degrees. The angle is clockwise.
175+
:type angle: float
170176
"""
171177

172178
def __init__(self, text_color: colors.Color = None,
173179
font_size: float = None,
174180
font_style: str = None,
175181
text_align_x: str = None, text_align_y: str = None,
176182
bold: bool = None, italic: bool = None,
177-
name: str = ''):
183+
angle: float = None, name: str = ''):
178184
self.text_color = text_color
179185
self.font_size = font_size
180186
self.font_style = font_style
181187
self.text_align_x = text_align_x
182188
self.text_align_y = text_align_y
183189
self.bold = bold
184190
self.italic = italic
191+
self.angle = angle
185192
DessiaObject.__init__(self, name=name)
186193

187194

@@ -876,14 +883,15 @@ def __init__(self, primitive_groups: List[PrimitiveGroup],
876883
sizes = [sizes] * len(primitive_groups)
877884
self.sizes = sizes
878885
self.coords = coords
879-
if x_variable or y_variable:
880-
attribute_names = []
881-
if x_variable:
882-
attribute_names.append(x_variable)
883-
if y_variable:
884-
attribute_names.append(y_variable)
885-
self.association = {'associated_elements': associated_elements,
886-
'attribute_names': attribute_names}
886+
if associated_elements:
887+
self.association = {'associated_elements': associated_elements}
888+
if x_variable or y_variable:
889+
attribute_names = []
890+
if x_variable:
891+
attribute_names.append(x_variable)
892+
if y_variable:
893+
attribute_names.append(y_variable)
894+
self.association['attribute_names'] = attribute_names
887895
PlotDataObject.__init__(self, type_='primitivegroupcontainer',
888896
name=name)
889897

@@ -1027,7 +1035,8 @@ def __init__(self, plots: List[Subclass[PlotDataObject]],
10271035
def plot_canvas(plot_data_object: Subclass[PlotDataObject],
10281036
debug_mode: bool = False, canvas_id: str = 'canvas',
10291037
force_version: str = None,
1030-
width: int = 750, height: int = 400, page_name: str = None):
1038+
width: int = 750, height: int = 400, page_name: str = None,
1039+
display: bool = True):
10311040
"""
10321041
Creates a html file and plots input data in web browser
10331042
@@ -1089,12 +1098,14 @@ def plot_canvas(plot_data_object: Subclass[PlotDataObject],
10891098
with open(temp_file, 'wb') as file:
10901099
file.write(s.encode('utf-8'))
10911100

1092-
webbrowser.open('file://' + temp_file)
1101+
if display:
1102+
webbrowser.open('file://' + temp_file)
10931103
print('file://' + temp_file)
10941104
else:
10951105
with open(page_name + '.html', 'wb') as file:
10961106
file.write(s.encode('utf-8'))
1097-
webbrowser.open('file://' + os.path.realpath(page_name + '.html'))
1107+
if display:
1108+
webbrowser.open('file://' + os.path.realpath(page_name + '.html'))
10981109
print(page_name + '.html')
10991110

11001111

script/multiple_plots.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
""" ParallelPlot """
3333
parallelplot1 = plot_data.ParallelPlot(axes=['x', 'y', 'color', 'direction'])
34-
parallelplot2 = plot_data.ParallelPlot(axes=['x', 'color'])
34+
parallelplot2 = plot_data.ParallelPlot(axes=['y', 'color'])
3535

3636
"""Scatterplots"""
3737
scatterplot1 = plot_data.Scatter(x_variable='x', y_variable='y')
@@ -66,9 +66,11 @@
6666
histogram = plot_data.Histogram(x_variable='x')
6767

6868
"""Creating the multiplot"""
69-
plots = [parallelplot1, parallelplot2, scatterplot1,
70-
scatterplot2, scatterplot3, graph2d, primitive_group_container,
71-
histogram]
69+
# plots = [parallelplot1, parallelplot2, scatterplot1,
70+
# scatterplot2, scatterplot3, graph2d, primitive_group_container,
71+
# histogram]
72+
73+
plots = [parallelplot1, scatterplot1]
7274

7375
multiplot = plot_data.MultiplePlots(plots=plots, elements=elements,
7476
initial_view_on=True)

0 commit comments

Comments
 (0)