Problems with charting

Posted by: gemini11 on 8 September 2017, 2:12 pm EST

  • Posted 8 September 2017, 2:12 pm EST

    I just upgraded to the latest version of Spread for WinForms.net to get the charting functions.


    I have been able to drop a chart (XY Scatter) )onto a spreadsheet and succesfully get it displayed.


    I need to be able to change what rows are used for the X and Y data at run time, as this is different for each data file read in.


    Is there any way to do this, or can it only be defined at design time?


    Thanks in advance.

  • Replied 8 September 2017, 2:12 pm EST

    Hello,

    You should be able to set the data source for X and Y values for XY chart.Here is an example that will give you an idea how to do that, 

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

    FpSpread1_Sheet1.Cells(0, 0).Text = "Category Names"
    FpSpread1_Sheet1.Cells(1, 0).Text = "12"
    FpSpread1_Sheet1.Cells(2, 0).Text = "24"
    FpSpread1_Sheet1.Cells(3, 0).Text = "36"
    FpSpread1_Sheet1.Cells(4, 0).Text = "12"
    FpSpread1_Sheet1.Cells(0, 1).Text = "Series 1"
    FpSpread1_Sheet1.Cells(1, 1).Value = 25
    FpSpread1_Sheet1.Cells(2, 1).Value = 34
    FpSpread1_Sheet1.Cells(3, 1).Value = 16
    FpSpread1_Sheet1.Cells(4, 1).Value = 47
    Dim plotarea As New FarPoint.Win.Chart.XYPlotArea()
    plotarea.Location = New PointF(0.2F, 0.2F)
    plotarea.Size = New SizeF(0.6F, 0.6F)
    Dim series1 As New FarPoint.Win.Chart.XYPointSeries()
    series1.XValues.DataSource = New
    FarPoint.Win.Spread.Chart.SeriesDataField(FpSpread1, "Category Names","Sheet1!A2:A5", FarPoint.Win.Spread.Chart.SegmentDataType.Text)
    series1.YValues.DataSource = New
    FarPoint.Win.Spread.Chart.SeriesDataField(FpSpread1, "Series 1","Sheet1!B2:B5")
    plotarea.Series.Add(series1)
    Dim model As New FarPoint.Win.Chart.ChartModel()
    model.PlotAreas.Add(plotarea)
    FpChart1.Model = model
    FpChart1.ViewType = FarPoint.Win.Chart.ChartViewType.View2D
    End Sub

    I hope it will help you.

    Thanks,

     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels