Hi Ivan,
Thank you for using Syncfusion products.
We have analyzed your requirement and we have updated the calculation method in trendline in sample with the PolynomialSlopes property as per the below code snippet.
Code Snippet
XAML
<chart:SfChart LayoutUpdated="sfchart_LayoutUpdated">
…
</chart:SfChart>
|
C#
public partial class MainWindow : SampleLayoutWindow
{
bool isValueCalulated;
private void sfchart_LayoutUpdated(object sender, EventArgs e)
{
if (!isValueCalulated)
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(CalculatePolynomialTrendline));
}
private void CalculatePolynomialTrendline()
{
foreach (CartesianSeries series in this.sfchart.Series)
{
foreach (var trendline in series.Trendlines)
{
var itemsSource = series.ItemsSource as ObservableCollection<Model>;
for (int i = 0; i < (series.ItemsSource as ObservableCollection<Model>).Count; i++)
{
var x = i;
var y = trendline.PolynomialSlopes.Select((t, index) => t * Math.Pow(x, (double)index)).Sum();
}
}
isValueCalulated = true;
}
}
}
|
Please find the modified sample from the link below.
Regards,
Samuel