إنشاء رسم بياني لأسهم High Low Close (HLC)
سيناريوهات الاستخدام المحتملة
يستخدم مخطط الأسهم High-Low-Close (HLC) أربع أعمدة من البيانات. العمود الأول هو فئة، عادة تاريخ ولكن يمكن أيضًا استخدام أسماء الأسهم. الأعمدة الثلاثة التالية بالترتيب هي للأسعار المرتفعة، منخفضة، والإغلاق. يتم توضيح نطاق السعر لكل فئة بخط عمودي من الأدنى إلى الأعلى، ويتم عرض سعر الإغلاق باستخدام دبوس امتدادي لليمين من هذا الخط.
تحسينات الرؤية في الرسم البياني
في بعض الأحيان، لجعل الرسم البياني يبدو أكثر تفاعلية، يمكننا تعديل مظهر العلامة (الإغلاق)، أو جعلها تظهر على المحور الثانوي.
الكود المثالي
الكود العينة التالي يحمل ملف إكسل العينة ويولد ملف إكسل الناتج.
from aspose.cells import Workbook | |
from aspose.cells.charts import ChartMarkerType, ChartType, FormattingType, LegendPositionType | |
from aspose.cells.drawing import FillType | |
from aspose.pydrawing import Color | |
# Create an instance of Workbook | |
workbook = Workbook("High-Low-Close.xlsx") | |
# Access the first worksheet. | |
worksheet = workbook.worksheets[0] | |
# Create High-Low-Close-Stock Chart | |
pieIdx = worksheet.charts.add(ChartType.STOCK_HIGH_LOW_CLOSE, 5, 6, 20, 12) | |
# Retrieve the Chart object | |
chart = worksheet.charts[pieIdx] | |
# Set the legend can be showed | |
chart.show_legend = True | |
# Set the chart title name | |
chart.title.text = "High-Low-Close Stock" | |
# Set the Legend at the bottom of the chart area | |
chart.legend.position = LegendPositionType.BOTTOM | |
# Set data range | |
chart.set_chart_data_range("A1:D9", True) | |
# Set category data | |
chart.n_series.category_data = "A2:A9" | |
# Set the marker with the built-in data | |
chart.n_series[2].marker.marker_style = ChartMarkerType.DASH | |
chart.n_series[2].marker.marker_size = 20 | |
chart.n_series[2].marker.area.formatting = FormattingType.CUSTOM | |
chart.n_series[2].marker.area.foreground_color = Color.maroon | |
# Fill the PlotArea area with nothing | |
chart.plot_area.area.fill_format.fill_type = FillType.NONE | |
# Save the Excel file | |
workbook.save("out.xlsx") |