チャートのトレンドラインの方程式テキストを取得する
Contents
[
Hide
]
Aspose.Cells for Python via .NETを使用してチャートのトレンドラインの方程式テキストを取得できます。Aspose.Cells for 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