ver Dec27thv3
added chart property of bar direction
This commit is contained in:
@@ -130,4 +130,4 @@ if __name__ == '__main__':
|
||||
|
||||
path1 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx"
|
||||
path2 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold2.xlsx"
|
||||
print(compare_with_charts(path1, path2, chart_props=["type"]))
|
||||
print(compare_with_charts(path1, path2, chart_props=["type", "direction"]))
|
||||
|
||||
@@ -54,6 +54,7 @@ def load_sparklines(xlsx_file: str) -> Dict[str, str]:
|
||||
# width: number
|
||||
# height: number
|
||||
# type: "scatterChart" | "lineChart" | "barChart"
|
||||
# direction: "bar" (hori) | "col" (vert)
|
||||
# xtitle, ytitle, ztitle: str
|
||||
def load_charts(xlsx_file: str, **options) -> Dict[str, Any]:
|
||||
"""
|
||||
@@ -109,6 +110,8 @@ def load_charts(xlsx_file: str, **options) -> Dict[str, Any]:
|
||||
info["height"] = ch.height
|
||||
if "type" in chart_props:
|
||||
info["type"] = ch.tagname
|
||||
if "direction" in chart_props:
|
||||
info["direction"] = ch.barDir
|
||||
|
||||
if "xtitle" in chart_props:
|
||||
info["xtitle"] = ch.x_axis.title.tx.rich.p[0].r[0].t
|
||||
@@ -120,7 +123,7 @@ def load_charts(xlsx_file: str, **options) -> Dict[str, Any]:
|
||||
return chart_set
|
||||
|
||||
if __name__ == "__main__":
|
||||
path1 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx"
|
||||
path1 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold_line_scatter.xlsx"
|
||||
workbook1: Workbook = openpyxl.load_workbook(filename=path1)
|
||||
worksheet1: Worksheet = workbook1.active
|
||||
charts: List[ChartBase] = worksheet1._charts
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
},
|
||||
"options": {
|
||||
"chart_props": [
|
||||
"type"
|
||||
"type",
|
||||
"direction"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user