8000 replaced position argument by data_source. · alixdamman/larray@34ec5a4 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit 34ec5a4

Browse files
committed
replaced position argument by data_source.
syntax is now: sheet[graph_position].make_plot(data_source)
1 parent e11147f commit 34ec5a4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

larray/inout/xw_excel.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ def load(self, header=True, convert_float=True, nb_axes=None, index_col=None, fi
620620
else:
621621
return Array(list_data)
622622

623-
def make_plot(self, position: str, width: int=427, height: int=230, title: str=None, template: str=None,
623+
def make_plot(self, data_source: str, width: int=427, height: int=230, title: str=None, template: str=None,
624624
min_y: Union[int, float]=None, max_y: Union[int, float]=None,
625625
xticks_spacing: Union[int, float]=None, customize_func: Callable=None,
626626
customize_kwargs: Dict[str, str]=None) -> Any:
@@ -632,7 +632,7 @@ def make_plot(self, position: str, width: int=427, height: int=230, title: str=N
632632
raise ValueError(f"Could not find template file {template}")
633633
title = str(title) if title is not None else None
634634
sheet = self.sheet.xw_sheet.api
635-
data_range = self.xw_range.api
635+
data_range = sheet.Range(data_source)
636636
top_left_cell = data_range.Cells(1, 1)
637637
# expand if current range is one cell
638638
if data_range.Count == 1:
@@ -644,12 +644,11 @@ def make_plot(self, position: str, width: int=427, height: int=230, title: str=N
644644
top_left_cell.Value = ''
645645
# start chart
646646
sheet_charts = sheet.ChartObjects()
647-
position = sheet.Range(position)
648-
left, top = position.Left, position.Top
647+
range_chart = self.xw_range.api
648+
left, top = range_chart.Left, range_chart.Top
649649
obj = sheet_charts.Add(left, top, width, height)
650650
obj_chart = obj.Chart
651-
source = data_range
652-
obj_chart.SetSourceData(source)
651+
obj_chart.SetSourceData(data_range)
653652
obj_chart.ChartType = ChartType.xlLine
654653
# title
655654
if title is not None:

larray/tests/test_excel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ def test_make_plot():
261261
with open_excel(filepath='test_make_plot.xlsx', visible=False, overwrite_file=True) as wb:
262262
sheet = wb[0]
263263
sheet["B2"] = population_be.dump()
264-
sheet["B2"].make_plot("B8")
265-
sheet["B2:F4"].make_plot("L8")
264+
sheet["B8"].make_plot("B2")
265+
sheet["L8"].make_plot("B2:F4")
266266
wb.save()
267267

268268

0 commit comments

Comments
 (0)
0