Super 2d/3d Graph Library

Enhance your .NET application adding nice charts within minutes! Save time and money!


Example 44: Trend lines in XY charts

This sample will plot a X/Y (scatter) chart and a trend line.

 

You may also obtain the equation factors for the trend line calling CalculationTrendLine property which will return a TrendLine object containing the values of the formula y = bx + a.

 

Steps to run this sample:

1. Create a new Windows application project (VB.NET)

2. Add Super 2d/3d Graph Library to the toolbox pallete and drag a chart to Form1.

3. Add a Label control below the chart control.

4. Copy and paste de following code:

Form Code
Imports Super2d3dGraphLibrary

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

  Dim sf As New SeriesFactory
  sf.AddPoint(1, 2)
 
sf.AddPoint(1.7, 4)
 
sf.AddPoint(4.2, 6)
 
sf.AddPoint(5, 8)
 
sf.AddPoint(6, 10)
 
sf.AddPoint(8.2, 12)

  With Super2d3dGraph1
    ' Initial setup: license, title and chart style
    .LicenseeIdentifier =
"PROF"
    .Title =
"Trend Line Sample"
    .Style = STYLE2D3D.STYLE2D_XY

    ' Assign data
    .Series = sf.Series
    .ShowValues =
False

    ' Setup y-axis
    .YAxisScaleMode = SCALEMODE.SCALEMODE_FIXED
    .YAxisScaleMinimum = 0
    .YAxisScaleMaximum = 14
    .YAxisNumericFormat =
"0"

    ' Setup x-axis
    .XAxisScaleMode = SCALEMODE.SCALEMODE_FIXED
    .XAxisScaleMinimum = 0
    .XAxisScaleMaximum = 10
    .XAxisNumericFormat =
"0"
    .ShowDividersX =
True
    .ShowXAxis =
True

    ' Look and feel
    .WallsBackStyle = STYLEWALLBACKGROUND.STYLEWALLBACKGROUND_GRADIENT
    .WallsBackColorPrincipal = Color.LightGray
    .WallsBackColorSecondary = Color.LightGray
    .SeriesColor =
New Color() {Color.Black}
    .ShowDataTable =
False
    .ShowLegend =
False

    ' Draw trend line
    .Calculation = CALCULATION.CALCULATION_AVERAGE
    .CalculationLineStyle =
New Pen(Color.Blue, 2)

    ' Refresh chart
    .RefreshChart()

    ' Print trend line equation below chart
    Dim trendLine As Trendline = .CalculationTrendLine(0)
    Label1.Text =
"Equation: y = " & trendLine.b & " x + " & trendLine.a

End With

End Sub

End Class

Result:


 

License & Purchase Info


Current version: 14

Super 2d/3d Graph Library is available as:
-Standard License (99€)
-Premium License (149€)
-Enterprise License (299€)

Click here for more details & purchase

Contact Info


Feel free to contact us
for questions related to any of our products or custom .Net development. We usually respond in the same labor day.

Software Siglo XXI

Main support service: support@softwaresigloxxi.com

Sales and other enquiries: contact@softwaresigloxxi.com