كيفية إنشاء رسم بياني Waterfall
Contents
[
Hide
]
مخطط شلال المياه هو نوع خاص من المخطط يستخدم عادة لإظهار كيفية زيادة أو انخفاض الوضع الابتدائي. تحتوي Microsoft Excel على العديد من أنواع المخططات المحددة مسبقًا، بما في ذلك العمود والخط والدائري والشريطي والراداري، وما إلى ذلك، ولكن مخطط شلال المياه يتجاوز الرسوم البيانية الأساسية ويمكن إنشاؤه باستخدام أنواع المخططات الحالية مع التخصيص القليل أو الكبير.
تتيح API Aspose.Cells لبايثون via .NET إنشاء مخطط شلال بمساعدة مخطط خطي. كما تتيح تخصيص مظهر المخطط لمنحه شكل الشلال من خلال ضبط خصائص Series.up_bars وSeries.down_bars.
يُظهر المقتطف أدناه كيف يمكنك استخدام API Aspose.Cells لبايثون via .NET لإنشاء مخطط شلال من الصفر.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import Workbook | |
from aspose.cells.charts import ChartType, FormattingType | |
from aspose.pydrawing import Color | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create an instance of Workbook | |
workbook = Workbook() | |
# Retrieve the first Worksheet in Workbook | |
worksheet = workbook.worksheets[0] | |
# Retrieve the Cells of the first Worksheet | |
cells = worksheet.cells | |
# Input some data which chart will use as source | |
cells.get("A1").put_value("Previous Year") | |
cells.get("A2").put_value("January") | |
cells.get("A3").put_value("March") | |
cells.get("A4").put_value("August") | |
cells.get("A5").put_value("October") | |
cells.get("A6").put_value("Current Year") | |
cells.get("B1").put_value(8.5) | |
cells.get("B2").put_value(1.5) | |
cells.get("B3").put_value(7.5) | |
cells.get("B4").put_value(7.5) | |
cells.get("B5").put_value(8.5) | |
cells.get("B6").put_value(3.5) | |
cells.get("C1").put_value(1.5) | |
cells.get("C2").put_value(4.5) | |
cells.get("C3").put_value(3.5) | |
cells.get("C4").put_value(9.5) | |
cells.get("C5").put_value(7.5) | |
cells.get("C6").put_value(9.5) | |
# Add a Chart of type Line in same worksheet as of data | |
idx = worksheet.charts.add(ChartType.LINE, 4, 4, 25, 13) | |
# Retrieve the Chart object | |
chart = worksheet.charts[idx] | |
# Add Series | |
chart.n_series.add("$B$1:$C$6", True) | |
# Add Category Data | |
chart.n_series.category_data = "$A$1:$A$6" | |
# Series has Up Down Bars | |
chart.n_series[0].has_up_down_bars = True | |
# Set the colors of Up and Down Bars | |
chart.n_series[0].up_bars.area.foreground_color = Color.green | |
chart.n_series[0].down_bars.area.foreground_color = Color.red | |
# Make both Series Lines invisible | |
chart.n_series[0].border.is_visible = False | |
chart.n_series[1].border.is_visible = False | |
# Set the Plot Area Formatting Automatic | |
chart.plot_area.area.formatting = FormattingType.AUTOMATIC | |
# Delete the Legend | |
chart.legend.legend_entries[0].is_deleted = True | |
chart.legend.legend_entries[1].is_deleted = True | |
# Save the workbook | |
workbook.save(dataDir + "output_out.xlsx") |