The code I wrote to bind the ConstantLine's Value property:
' View chart of difference between actual and normal worktime
Dim vDiagram As New XYDiagram2D()
Dim vArgumentDataMember As String = GetPropertyName(Function(wtd As WorkTimeDifference) wtd.Date)
Dim vValueDataMember As String = GetPropertyName(Function(wtd As WorkTimeDifference) wtd.WorkTimeDifference)
Dim vDisplayName As String = "Actual - normal worktime"
Dim vWorkTimeDifferenceBinding As New Binding("WorkTimeDifferenceForChart")
vWorkTimeDifferenceBinding.Source = Me.DataContext
Dim vWorkTimeDifferenceSeries As New AreaSeries2D With {.DisplayName = vDisplayName, .ArgumentScaleType = ScaleType.DateTime, .ValueDataMember = vValueDataMember, .ArgumentDataMember = vArgumentDataMember, .Transparency = 0.4, .Label = New SeriesLabel With {.Visible = False}}
vWorkTimeDifferenceSeries.SetBinding(AreaSeries2D.DataSourceProperty, vWorkTimeDifferenceBinding)
vDiagram.Series.Add(vWorkTimeDifferenceSeries)
Dim vAverageBinding As New Binding("AverageWorkTimeDifference")
vAverageBinding.Source = Me.DataContext
Dim vAverageLine As New ConstantLine()
vAverageLine.SetBinding(ConstantLine.ValueProperty, vAverageBinding)
vAverageLine.Brush = Brushes.Orange
vAverageLine.ShowBehind = True
Dim vAverageTitleBinding As New Binding("AverageWorkTimeDifference")
vAverageTitleBinding.StringFormat = "({0:n3}) Average difference"
Dim vAverageTitle As New ConstantLineTitle()
vAverageTitle.SetBinding(ConstantLineTitle.TextProperty, vAverageTitleBinding)
vAverageTitle.Foreground = Brushes.Orange
vAverageTitle.Alignment = ConstantLineTitleAlignment.Far
vAverageLine.Title = vAverageTitle
' Default settings
vDiagram.SeriesTemplate = New LineSeries2D()
vDiagram.AxisY = New AxisY2D()
vDiagram.AxisX = New AxisX2D()
vDiagram.AxisY.ConstantLines.Add(vAverageLine)
Me.WorkTimeChartControl.Diagram = vDiagram
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.
Facebook
Twitter
Google+