We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Display and Extract Trendline Equation from Scatter Series

Thread ID:

Created:

Updated:

Platform:

Replies:

119218 May 24,2015 05:43 PM UTC May 26,2015 01:33 PM UTC WPF 3
loading
Tags: SfChart
Coder
Asked On May 24, 2015 05:43 PM UTC

Hello,

Is it possible to display a linear trendline equation and extract the constants (a and b in the equation y = mx + b) to use?

I currently have the following code:

<syncfusion:SfChart x:Name="myChart" Header="Chart Header" HorizontalAlignment="Left" Margin="10" VerticalAlignment="Center">
                  
                <syncfusion:SfChart.PrimaryAxis>
                    <syncfusion:NumericalAxis FontSize="10" Header="x axis" LabelRotationAngle="0" ShowGridLines="True"/>
                </syncfusion:SfChart.PrimaryAxis>
                <syncfusion:SfChart.SecondaryAxis>
                    <syncfusion:NumericalAxis FontSize="10" Header="y axis" LabelRotationAngle="-45" />
                </syncfusion:SfChart.SecondaryAxis>

                <syncfusion:ScatterSeries x:Name="series1" ScatterWidth="10" ScatterHeight="10" ShowTooltip="True" syncfusion:ChartTooltip.EnableAnimation="True" ItemsSource="{Binding}">
                    <syncfusion:ScatterSeries.Trendlines>
                        <syncfusion:Trendline IsTrendlineVisible="True" Type="Linear" />
                    </syncfusion:ScatterSeries.Trendlines>
                </syncfusion:ScatterSeries>

            </syncfusion:SfChart>

Thanks.

Suresh S [Syncfusion]
Replied On May 25, 2015 12:51 PM UTC

Hi Coder,

Thanks for contacting Syncfusion support

Query1: (display trendline equation)

Currently we don’t have support for display trendline equation in chart area. However, we have considered “Implement trendline equation like excel chart” as a new feature request and will be implementing in any of our upcoming release.

Also, in the mean while we are working for any workaround possibilities to achieve this.

Query2: (get slope, intercept values of trendline)

We could extract the slope, intercept value of trendline as shown in the below code snippet

Code Snippet [C#]:

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)

{

      var slope = (series1.Trendlines[0] as Trendline).Slope;

      var intercept = (series1.Trendlines[0] as Trendline).Intercept;

}

Please let us know in case of any query

Regards,

Suresh S


Coder
Replied On May 25, 2015 08:48 PM UTC

Hi Suresh,

Thanks for the reply. I got clarification on this requirement, and it seems I need to use just y = mx. Is there a way in the control to force the trend line to start at (0,0)? Similar to how in Excel, you can choose to set the intercept to 0.

If not, I can get the equation of the trend line manually and plot the line. What's the best way to go about plotting a line? I'm thinking of taking a few data points and putting them in a LineSeries.

Suresh S [Syncfusion]
Replied On May 26, 2015 01:33 PM UTC

Hi Coder,

Query 1: Is there a way in the control to force the trend line to start at (0,0)?

Currently we don’t have support for editing intercept of trendline. However, we have considered the “Support for editing intercept of trendline” as a new feature and will be implementing in any of our upcoming release.

Query 2: What's the best way to go about plotting a line?

Yes, you can achieve the custom intercept requirement by plotting a line series using the trendline equation.

1.            Generate the data points using the TrendLine Equation, by substituting the x values of Scatter Series (existing series).

2.            And add (0,0) or any other point to the starting of your point collection and bind this collection to your line series.

Displaying trendline equation:

As a workaround, we have used text annotations to display trendline equation. We have prepared a sample based on this, please download from below location.

Please let us know in case of any query.

Regards,

Suresh S  


Attachment: trendline_7854294b.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;