Получение текста уравнения трендовой линии диаграммы
Contents
[
Hide
]
Вы можете получить текст уравнения трендлайна диаграммы с помощью Aspose.Cells для Python via .NET. Aspose.Cells для Python via .NET предоставляет свойство, которое возвращает текст уравнения трендлайна диаграммы. Для использования этого свойства сначала необходимо вызвать метод Chart.calculate().
На следующем скриншоте показана диаграмма с трендовой линией, и ее текст уравнения показан красным цветом. Мы получим этот текст с помощью свойства Trendline.data_labels.text в следующем образце кода.
Пример кода на C# для получения текста уравнения трендовой линии диаграммы
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 | |
# 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 workbook object from source Excel file | |
workbook = Workbook(dataDir + "source.xlsx") | |
# Access the first worksheet | |
worksheet = workbook.worksheets[0] | |
# Access the first chart inside the worksheet | |
chart = worksheet.charts[0] | |
# Calculate the Chart first to get the Equation Text of Trendline | |
chart.calculate() | |
# Access the Trendline | |
trendLine = chart.n_series[0].trend_lines[0] | |
# Read the Equation Text of Trendline | |
print("Equation Text: " + trendLine.data_labels.text) |
Вывод, созданный образцовым кодом
Это вывод консоли вышеуказанного образца кода.
Equation Text: y = 8.1333x + 5