Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
How to create a chart and set properties by only VB.NET code
posted

I'd like to create a chart,then set legend text and format  AxisY(datetime) by only VB.NET codes(not xaml).How to?

Best regards.

Parents
No Data
Reply
  • 30692
    Offline posted

    Here's an example of how to create and customize a chart manually. If you aren't using VS2010 you may need to add some underscores here and there as line continuations.

    Imports Infragistics.Windows.Chart
     
    Class MainWindow
        Public Sub New()
            InitializeComponent()
     
            Dim chart As New XamChart
            Dim series As New Series With {
                .ChartType = ChartType.Line,
                .Label = "Sample"}
            series.DataPoints.Add(
                New DataPoint() With {.Label = "A", .Value = 1})
            series.DataPoints.Add(
                New DataPoint() With {.Label = "B", .Value = 2})
            series.DataPoints.Add(
                New DataPoint() With {.Label = "C", .Value = 3})
            series.DataPoints.Add(
                New DataPoint() With {.Label = "D", .Value = 4})
     
            chart.Series.Add(series)
     
            Dim yAxis As New Axis With {
                .AxisType = AxisType.PrimaryY,
                .StrokeThickness = 2,
                .Stroke = New SolidColorBrush(Colors.Red)}
     
            chart.Axes.Add(yAxis)
     
            grid.Children.Add(chart)
        End Sub
    End Class

    Hope this helps!

    -Graham

Children
No Data