2020年4月14日火曜日

Oxyplot LogarithmicAxis (07) Tick calculation for different bases

Tick calculation for different bases

Imports Oxyplot.Axes
Public Class Form
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim plotModel = New PlotModel With {
            .Title = "Tick calculation for different bases",
            .Background = OxyColors.White
        }
        Dim logarithmicAxis1 = New LogarithmicAxis With {
            .MajorGridlineStyle = LineStyle.Solid,
            .Maximum = 20000,
            .Minimum = 20,
            .MinorGridlineStyle = LineStyle.Solid,
            .Title = "Base 10"
        }
        plotModel.Axes.Add(logarithmicAxis1)
        Dim logarithmicAxis2 = New LogarithmicAxis With {
            .Base = 7,
            .MajorGridlineStyle = LineStyle.Solid,
            .Maximum = 10000,
            .Minimum = 2,
            .MinorGridlineStyle = LineStyle.Solid,
            .Position = AxisPosition.Bottom,
            .Title = "Base 7"
        }
        plotModel.Axes.Add(logarithmicAxis2)
        Dim logarithmicAxis3 = New LogarithmicAxis With {
            .Base = 5.5,
            .Maximum = 100,
            .Minimum = 1,
            .Position = AxisPosition.Top,
            .Title = "Base 5.5"
        }
        plotModel.Axes.Add(logarithmicAxis3)
        Dim logarithmicAxis4 = New LogarithmicAxis With {
            .Base = 2,
            .Maximum = 1000000,
            .Minimum = 1,
            .Position = AxisPosition.Right,
            .Title = "Base 2"
        }
        plotModel.Axes.Add(logarithmicAxis4)
        PlotView.Model = plotModel
    End Sub
End Class

2020年4月13日月曜日

Oxyplot TwoColorLineSeries (01) Temperature

Temperature

Imports Oxyplot.Axes
Imports Oxyplot.Series
Public Class Form
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim plotModel = New PlotModel With {
            .Title = "TwoColorLineSeries",
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Position = AxisPosition.Bottom,
            .Title = "Date"
        }
        plotModel.Axes.Add(linearAxisX)
        Dim linearAxisY = New LinearAxis With {
            .Title = "Temperature",
            .Unit = "°C",
            .ExtraGridlines = New Double() {0}
        }
        plotModel.Axes.Add(linearAxisY)
        Dim temperatures As Double() = New Double() {5, 0, 7, 7, 4, 3, 5, 5, 11, 4, 2, 3, 2, 1, 0, 2, -1, 0, 0, -3, -6, -13, -10, -10, 0, -4, -5, -4, 3, 0, -5}
        Dim twoColorLineSeries = New TwoColorLineSeries With {
            .Title = "Temperature at Eidesmoen, December 1986.",
            .TrackerFormatString = "December {2:0}: {4:0.0} °C",
            .Color = OxyColors.Red,
            .Color2 = OxyColors.LightBlue,
            .StrokeThickness = 3,
            .Limit = 0,
            .InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline,
            .MarkerType = MarkerType.Circle,
            .MarkerSize = 4,
            .MarkerStroke = OxyColors.Black,
            .MarkerStrokeThickness = 1.5
        }
        For i As Integer = 0 To temperatures.Length - 1
            twoColorLineSeries.Points.Add(New DataPoint(i + 1, temperatures(i)))
        Next i
        plotModel.Series.Add(twoColorLineSeries)
        plotModel.LegendSymbolLength = 24
        PlotView.Model = plotModel
    End Sub
End Class

2020年4月12日日曜日

Oxyplot Mouse Events (15) RectangleAnnotation click

RectangleAnnotation click

Imports Oxyplot.Axes
Imports Oxyplot.Annotations
Public Class Form
    Private WithEvents RectAnt As RectangleAnnotation
    Private plotModel As PlotModel
    Private clickTimes As Integer
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        plotModel = New PlotModel With {
            .Title = "RectangleAnnotation click",
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Position = AxisPosition.Bottom
        }
        plotModel.Axes.Add(linearAxisX)
        Dim linearAxisY = New LinearAxis()
        plotModel.Axes.Add(linearAxisY)
        RectAnt = New RectangleAnnotation With {
            .MinimumX = 10,
            .MaximumX = 60,
            .MinimumY = 10,
            .MaximumY = 20
        }
        plotModel.Annotations.Add(RectAnt)
        PlotView.Model = plotModel
        clickTimes = 0
    End Sub
    Private Sub RectAnt_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles RectAnt.MouseDown
        clickTimes = clickTimes + 1
        RectAnt.Text = String.Format("Clicked {0} times.", clickTimes)
        plotModel.InvalidatePlot(False)
    End Sub
End Class

2020年4月11日土曜日

Oxyplot Mouse Events (10) MouseDown

MouseDown

Imports Oxyplot.Series
Public Class Form
    Private WithEvents Model As PlotModel
    Private countA As Double
    Private Function CalcFunc(ByVal x As Double) As Double
        Return Math.Sin(countA * x)
    End Function
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Model = New PlotModel With {
            .Subtitle = "Left click to add series.",
            .Title = "MouseDown",
            .LegendSymbolLength = 40,
            .Background = OxyColors.White
        }
        PlotView.Model = Model
    End Sub
    Private Sub Model_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Model.MouseDown
        If e.ChangedButton = OxyMouseButton.Left Then
            countA = Model.Series.Count + 1
            Model.Series.Add(New FunctionSeries(AddressOf CalcFunc, 0, 10, 1000))
            Model.InvalidatePlot(True)
            e.Handled = True
        End If
    End Sub
End Class

2020年4月10日金曜日

Oxyplot Mouse Events (12) Hover

Hover

Imports Oxyplot.Series
Public Class Form
    Private WithEvents Model As PlotModel
    Private series As LineSeries
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Model = New PlotModel With {
            .Title = "Hover",
            .Background = OxyColors.White
        }
        PlotView.Model = Model
        series = Nothing
    End Sub
    Private Sub Model_MouseEnter(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseEnter
        Model.Subtitle = "The mouse entered"
        series = New LineSeries()
        Model.Series.Add(series)
        Model.InvalidatePlot(False)
        e.Handled = True
    End Sub
    Private Sub Model_MouseMove(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseMove
        If Not IsNothing(series) And Not IsNothing(series.XAxis) Then
            series.Points.Add(series.InverseTransform(e.Position))
            Model.InvalidatePlot(False)
        End If
    End Sub
    Private Sub Model_MouseLeave(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseLeave
        Model.Subtitle = "The mouse left"
        Model.InvalidatePlot(False)
        e.Handled = True
    End Sub

2020年4月9日木曜日

Oxyplot Mouse Events (08) TextAnnotation

TextAnnotation

Imports Oxyplot.Axes
Imports Oxyplot.Annotations
Public Class Form
    Private WithEvents TextAnt As TextAnnotation
    Private plotModel As PlotModel
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        plotModel = New PlotModel With {
            .Subtitle = "Click the text",
            .Title = "TextAnnotation",
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Maximum = 20,
            .Minimum = -20,
            .Position = AxisPosition.Bottom
        }
        plotModel.Axes.Add(linearAxisX)
        Dim linearAxisY = New LinearAxis With {
            .Maximum = 10,
            .Minimum = -10
        }
        plotModel.Axes.Add(linearAxisY)
        TextAnt = New TextAnnotation With {
            .Text = "Click here",
            .TextPosition = New DataPoint(4, -2)
        }
        plotModel.Annotations.Add(TextAnt)
        PlotView.Model = plotModel
    End Sub
    Private Sub TextAnt_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles TextAnt.MouseDown
        If Not e.ChangedButton = OxyMouseButton.Left Then
            Return
        End If
        If TextAnt.Background.IsUndefined() = True Then
            TextAnt.Background = OxyColors.LightGreen
        Else
            TextAnt.Background = OxyColors.Undefined
        End If
        plotModel.InvalidatePlot(False)
        e.Handled = True
    End Sub
End Class

2020年4月8日水曜日

Oxyplot Mouse Events (07) PolygonAnnotation


PolygonAnnotation

Imports Oxyplot.Axes
Imports Oxyplot.Annotations
Public Class Form
    Private WithEvents PolygonAnt As PolygonAnnotation
    Private hitCount As Integer
    Private plotModel As PlotModel
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        plotModel = New PlotModel With {
            .Subtitle = "Click the polygon",
            .Title = "PolygonAnnotation",
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Maximum = 20,
            .Minimum = -20,
            .Position = AxisPosition.Bottom
        }
        plotModel.Axes.Add(linearAxisX)
        Dim linearAxisY = New LinearAxis With {
            .Maximum = 20,
            .Minimum = -20
        }
        plotModel.Axes.Add(linearAxisY)
        PolygonAnt = New PolygonAnnotation With {
            .Text = "Polygon 1"
        }
        PolygonAnt.Points.Add(New DataPoint(4, -2))
        PolygonAnt.Points.Add(New DataPoint(8, -4))
        PolygonAnt.Points.Add(New DataPoint(17, 7))
        PolygonAnt.Points.Add(New DataPoint(5, 8))
        PolygonAnt.Points.Add(New DataPoint(2, 5))
        plotModel.Annotations.Add(PolygonAnt)
        PlotView.Model = plotModel
        hitCount = 1
    End Sub
    Private Sub PolygonAnt_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles PolygonAnt.MouseDown
        If Not e.ChangedButton = OxyMouseButton.Left Then
            Return
        End If
        hitCount = hitCount + 1
        PolygonAnt.Text = String.Format("Hit # {0}", hitCount)
        plotModel.InvalidatePlot(False)
        e.Handled = True
    End Sub
End Class

2020年4月7日火曜日

Oxyplot Mouse Events (01) Mouse events

Mouse events
Imports Oxyplot.Axes
Imports Oxyplot.Series
Public Class Form
    Private WithEvents Model As PlotModel
    Private lineSeries As LineSeries
    Private linearAxisX As LinearAxis
    Private linearAxisY As LinearAxis
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Model = New PlotModel With {
            .Subtitle = "Left click and drag",
            .Title = "Mouse events",
            .Background = OxyColors.White
        }
        linearAxisX = New LinearAxis With {
            .Maximum = 1,
            .Minimum = -1,
            .Position = AxisPosition.Bottom
        }
        Model.Axes.Add(linearAxisX)
        linearAxisY = New LinearAxis With {
            .Maximum = 1,
            .Minimum = -1
        }
        Model.Axes.Add(linearAxisY)
        PlotView.Model = Model
        lineSeries = Nothing
    End Sub
    Private Sub Model_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Model.MouseDown
        If e.ChangedButton = OxyMouseButton.Left Then
            lineSeries = New LineSeries With {
                .Title = String.Format("LineSeries {0}", Model.Series.Count + 1),
                .MarkerType = MarkerType.None,
                .StrokeThickness = 2
            }
            lineSeries.Points.Add(linearAxisX.InverseTransform(e.Position.X, e.Position.Y, linearAxisY))
            Model.Series.Add(lineSeries)
            Model.InvalidatePlot(False)
            e.Handled = True
        End If
    End Sub
    Private Sub Model_MouseMove(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseMove
        If Not IsNothing(lineSeries) Then
            lineSeries.Points.Add(linearAxisX.InverseTransform(e.Position.X, e.Position.Y, linearAxisY))
            Model.InvalidatePlot(False)
            e.Handled = True
        End If
    End Sub
    Private Sub Model_MouseUp(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseUp
        If Not IsNothing(lineSeries) Then
            lineSeries = Nothing
            e.Handled = True
        End If
    End Sub
End Class

2020年4月6日月曜日

Oxyplot Mouse Events (06) ArrowAnnotation

ArrowAnnotation

Imports Oxyplot.Axes
Imports Oxyplot.Annotations
Public Class Form
    Private WithEvents ArrowAnt As ArrowAnnotation
    Private plotModel As PlotModel
    Private lastPoint As DataPoint
    Private moveStartPoint As Boolean
    Private moveEndPoint As Boolean
    Private originalColor As OxyColor
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        plotModel = New PlotModel With {
            .Subtitle = "Click and drag the arrow.",
            .Title = "ArrowAnnotation",
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Maximum = 60,
            .Minimum = -40,
            .Position = AxisPosition.Bottom
        }
        plotModel.Axes.Add(linearAxisX)
        Dim linearAxisY = New LinearAxis With {
            .Maximum = 10,
            .Minimum = -10
        }
        plotModel.Axes.Add(linearAxisY)
        ArrowAnt = New ArrowAnnotation With {
            .StartPoint = New DataPoint(8, 4),
            .Text = "Move me!"
        }
        plotModel.Annotations.Add(ArrowAnt)
        PlotView.Model = plotModel

        lastPoint = DataPoint.Undefined
        moveStartPoint = False
        moveEndPoint = False
        originalColor = ArrowAnt.Color
    End Sub
    Private Sub ArrowAnt_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles ArrowAnt.MouseDown
        If Not e.ChangedButton = OxyMouseButton.Left Then
            Return
        End If
        lastPoint = ArrowAnt.InverseTransform(e.Position)
        If Not e.HitTestResult.Index = 2 Then
            moveStartPoint = True
        Else
            moveStartPoint = False
        End If
        If Not e.HitTestResult.Index = 1 Then
            moveEndPoint = True
        Else
            moveEndPoint = False
        End If
        originalColor = ArrowAnt.Color
        ArrowAnt.Color = OxyColors.Red
        plotModel.InvalidatePlot(False)
        e.Handled = True
    End Sub
    Private Sub ArrowAnt_MouseMove(sender As Object, e As OxyMouseEventArgs) Handles ArrowAnt.MouseMove
        Dim thisPoint = ArrowAnt.InverseTransform(e.Position)
        Dim dx = thisPoint.X - lastPoint.X
        Dim dy = thisPoint.Y - lastPoint.Y
        If moveStartPoint = True Then
            ArrowAnt.StartPoint = New DataPoint(ArrowAnt.StartPoint.X + dx, ArrowAnt.StartPoint.Y + dy)
        End If
        If moveStartPoint = True Then
            ArrowAnt.EndPoint = New DataPoint(ArrowAnt.EndPoint.X + dx, ArrowAnt.EndPoint.Y + dy)
        End If
        lastPoint = thisPoint
        plotModel.InvalidatePlot(False)
        e.Handled = True
    End Sub
    Private Sub ArrowAnt_MouseUp(sender As Object, e As OxyMouseEventArgs) Handles ArrowAnt.MouseUp
        ArrowAnt.Color = originalColor
        plotModel.InvalidatePlot(False)
    End Sub
End Class

2020年4月5日日曜日

Oxyplot Mouse Events (02) MouseDown HitTestResult

MouseDown HitTestResult

Imports Oxyplot.Axes
Imports Oxyplot.Series
Public Class Form
    Private WithEvents Line As LineSeries
    Private WithEvents Scatter As ScatterSeries
    Private plotModel As PlotModel
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        plotModel = New PlotModel With {
            .Subtitle = "Index of nearest point in LineSeries: 0",
            .Title = "MouseDown HitTestResult",
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Position = AxisPosition.Bottom
        }
        Dim linearAxisY = New LinearAxis()
        plotModel.Axes.Add(linearAxisX)
        plotModel.Axes.Add(linearAxisY)
        Line = New LineSeries()
        Line.Points.Add(New DataPoint(0, 10))
        Line.Points.Add(New DataPoint(10, 40))
        Line.Points.Add(New DataPoint(40, 20))
        Line.Points.Add(New DataPoint(60, 30))
        plotModel.Series.Add(Line)
        Scatter = New ScatterSeries()
        Scatter.Points.Add(New ScatterPoint(0, 15))
        Scatter.Points.Add(New ScatterPoint(10, 45))
        Scatter.Points.Add(New ScatterPoint(40, 25))
        Scatter.Points.Add(New ScatterPoint(60, 35))
        plotModel.Series.Add(Scatter)
        PlotView.Model = plotModel
    End Sub
    Private Sub Line_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Line.MouseDown
        plotModel.Subtitle = String.Format("Index of nearest point in LineSeries: {0}", Math.Round(e.HitTestResult.Index))
        plotModel.InvalidatePlot(False)
    End Sub
    Private Sub Scatter_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Scatter.MouseDown
        plotModel.Subtitle = String.Format("Index of nearest point in ScatterSeries: {0}", CInt(e.HitTestResult.Index))
        plotModel.InvalidatePlot(False)
    End Sub
End Class

2020年4月4日土曜日

Oxyplot Mouse Events (04) Add arrow annotations

Add arrow annotations

Imports Oxyplot.Axes
Imports Oxyplot.Series
Imports Oxyplot.Annotations
Public Class Form
    Private WithEvents Model As PlotModel
    Private arrow As ArrowAnnotation
    Private linearAxisY As LinearAxis
    Private linearAxisX As LinearAxis
    Private Function CalcFunc(ByVal x As Double) As Double
        Return Math.Sin(x / 4) * Math.Acos(Math.Sin(x))
    End Function
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Model = New PlotModel With {
            .Subtitle = "Press and drag the left mouse button",
            .Title = "Add arrow annotations",
            .Background = OxyColors.White
        }
        linearAxisX = New LinearAxis With {
            .Position = AxisPosition.Bottom
        }
        Model.Axes.Add(linearAxisX)
        linearAxisY = New LinearAxis()
        Model.Axes.Add(linearAxisY)
        Dim functionSeries = New FunctionSeries(AddressOf CalcFunc, 0, Math.PI * 8, 2000) With {
            .Title = "sin(x/4)*acos(sin(x))"
        }
        Model.Series.Add(functionSeries)
        arrow = Nothing
        PlotView.Model = Model
    End Sub
    Private Sub Model_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Model.MouseDown
        If e.ChangedButton = OxyMouseButton.Left Then
            arrow = New ArrowAnnotation()
            arrow.StartPoint = linearAxisX.InverseTransform(e.Position.X, e.Position.Y, linearAxisY)
            arrow.EndPoint = arrow.StartPoint
            Model.Annotations.Add(arrow)
            e.Handled = True
        End If
    End Sub
    Private Sub Model_MouseMove(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseMove
        If Not IsNothing(arrow) Then
            arrow.EndPoint = linearAxisX.InverseTransform(e.Position.X, e.Position.Y, linearAxisY)
            arrow.Text = String.Format("Y = {0:0.###}", arrow.EndPoint.Y)
            Model.InvalidatePlot(False)
            e.Handled = True
        End If
    End Sub
    Private Sub Model_MouseUp(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseUp
        If Not IsNothing(arrow) Then
            arrow = Nothing
            e.Handled = True
        End If
    End Sub
End Class

2020年4月3日金曜日

Oxyplot Mouse Events (03) MouseDown

MouseDown

Imports Oxyplot.Axes
Imports Oxyplot.Series
Public Class Form
    Private WithEvents Model As PlotModel
    Private WithEvents Line As LineSeries
    Private indexOfPointToMove As Integer
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Model = New PlotModel With {
            .Subtitle = "Left click to edit or add points.",
            .Title = "MouseDown",
            .LegendSymbolLength = 40,
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Position = AxisPosition.Bottom
        }
        Model.Axes.Add(linearAxisX)
        Dim linearAxisY = New LinearAxis()
        Model.Axes.Add(linearAxisY)
        Line = New LineSeries With {
            .Color = OxyColors.SkyBlue,
            .MarkerFill = OxyColors.SkyBlue,
            .MarkerSize = 6,
            .MarkerStroke = OxyColors.White,
            .MarkerStrokeThickness = 1.5,
            .MarkerType = MarkerType.Circle,
            .Title = "LineSeries1"
        }
        Line.Points.Add(New DataPoint(0, 10))
        Line.Points.Add(New DataPoint(10, 40))
        Line.Points.Add(New DataPoint(40, 20))
        Line.Points.Add(New DataPoint(60, 30))
        Model.Series.Add(Line)
        PlotView.Model = Model
        indexOfPointToMove = -1
    End Sub
    Private Sub Line_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Line.MouseDown
        If e.ChangedButton = OxyMouseButton.Left Then
            Dim indexOfNearestPoint As Integer = CInt(Math.Round(e.HitTestResult.Index))
            Dim nearestPoint As ScreenPoint = Line.Transform(Line.Points(indexOfNearestPoint))
            If (nearestPoint - e.Position).Length < 10 Then
                indexOfPointToMove = indexOfNearestPoint
            Else
                Dim i As Integer = CInt(e.HitTestResult.Index + 1)
                Line.Points.Insert(i, Line.InverseTransform(e.Position))
                indexOfPointToMove = i
            End If
            Line.LineStyle = LineStyle.DashDot
            Model.InvalidatePlot(False)
            e.Handled = True
        End If
    End Sub
    Private Sub Line_MouseMove(sender As Object, e As OxyMouseEventArgs) Handles Line.MouseMove
        If indexOfPointToMove >= 0 Then
            Line.Points(indexOfPointToMove) = Line.InverseTransform(e.Position)
            Model.InvalidatePlot(False)
            e.Handled = True
        End If
    End Sub
    Private Sub Line_MouseUp(sender As Object, e As OxyMouseEventArgs) Handles Line.MouseUp
        indexOfPointToMove = -1
        Line.LineStyle = LineStyle.Solid
        Model.InvalidatePlot(False)
        e.Handled = True
    End Sub
    Private Sub Model_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Model.MouseDown
        If e.ChangedButton = OxyMouseButton.Left Then
            Line.Points.Add(Line.InverseTransform(e.Position))
            indexOfPointToMove = Line.Points.Count - 1
            Model.InvalidatePlot(False)
            e.Handled = True
        End If
    End Sub
End Class

2020年4月2日木曜日

Oxyplot Mouse Events (11) Select range

Select range

Imports Oxyplot.Annotations
Imports Oxyplot.Axes
Imports Oxyplot.Series
Public Class Form
    Private range As RectangleAnnotation
    Private WithEvents Model As PlotModel
    Private startx As Double
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Model = New PlotModel With {
            .Subtitle = "Integrating from x.xx to x.xx",
            .Title = "Select range",
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Position = AxisPosition.Bottom
        }
        Model.Axes.Add(linearAxisX)
        Dim linearAxisY = New LinearAxis()
        Model.Axes.Add(linearAxisY)
        Dim functionSeries = New FunctionSeries(AddressOf Math.Cos, 0, 40, 0.1)
        Model.Series.Add(functionSeries)
        range = New RectangleAnnotation With {
            .MinimumX = 0,
            .MaximumX = 0,
            .Fill = OxyColor.FromAColor(120, OxyColors.SkyBlue)
        }
        Model.Annotations.Add(range)
        PlotView.Model = Model
        startx = Double.NaN
    End Sub
    Private Sub Model_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Model.MouseDown
        If e.ChangedButton = Global.Oxyplot.OxyMouseButton.Left Then
            startx = range.InverseTransform(e.Position).X
            range.MinimumX = startx
            range.MaximumX = startx
            PlotView.Model.InvalidatePlot(True)
            e.Handled = True
        End If
    End Sub
    Private Sub Model_MouseMove(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseMove
        If Not Double.IsNaN(startx) Then
            Dim x = range.InverseTransform(e.Position).X
            range.MinimumX = Math.Min(x, startx)
            range.MaximumX = Math.Max(x, startx)
            range.Text = String.Format("∫ cos(x) dx =  {0:0.00}", Math.Sin(range.MaximumX) - Math.Sin(range.MinimumX))
            PlotView.Model.Subtitle = String.Format("Integrating from {0:0.00} to {1:0.00}", range.MinimumX, range.MaximumX)
            PlotView.Model.InvalidatePlot(True)
            e.Handled = True
        End If
    End Sub
    Private Sub Model_MouseUp(sender As Object, e As OxyMouseEventArgs) Handles Model.MouseUp
        startx = Double.NaN
    End Sub
End Class

2020年4月1日水曜日

Oxyplot Mouse Events (05) LineAnnotation

LineAnnotation

Imports Oxyplot.Axes
Imports Oxyplot.Annotations
Public Class Form
    Private WithEvents LineAnt As LineAnnotation
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim Model = New PlotModel With {
            .Subtitle = "Click and drag the annotation line.",
            .Title = "LineAnnotation",
            .Background = OxyColors.White
        }
        Dim linearAxisX = New LinearAxis With {
            .Maximum = 80,
            .Minimum = -20,
            .Position = AxisPosition.Bottom
        }
        Dim linearAxisY = New LinearAxis With {
            .Maximum = 10,
            .Minimum = -10
        }
        Model.Axes.Add(linearAxisX)
        Model.Axes.Add(linearAxisY)
        LineAnt = New LineAnnotation With {
            .Type = LineAnnotationType.Vertical,
            .X = 1
        }
        Model.Annotations.Add(LineAnt)
        PlotView.Model = Model
    End Sub
    Private Sub LineAnt_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles LineAnt.MouseDown
        If Not e.ChangedButton = Global.Oxyplot.OxyMouseButton.Left Then
            Return
        End If
        LineAnt.StrokeThickness *= 2
        PlotView.Model.InvalidatePlot(False)
        e.Handled = True
    End Sub
    Private Sub LineAnt_MouseMove(sender As Object, e As OxyMouseEventArgs) Handles LineAnt.MouseMove
        LineAnt.X = LineAnt.InverseTransform(e.Position).X
        PlotView.Model.InvalidatePlot(False)
        e.Handled = True
    End Sub
    Private Sub LineAnt_MouseUp(sender As Object, e As OxyMouseEventArgs) Handles LineAnt.MouseUp
        LineAnt.StrokeThickness = 1
        PlotView.Model.InvalidatePlot(False)
        e.Handled = True
    End Sub
End Class

OxyPlot 1 ShowCases(1) Normal distribution

Normal distribution


Imports Oxyplot.Axes
Imports Oxyplot.Series

Public Class Form
    Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim Model = New PlotModel With {
            .Title = "Normal distribution",
            .Subtitle = "Probability density function",
            .Background = OxyColors.White
        }
        Dim linearAxisY = New LinearAxis With {
            .Position = AxisPosition.Left,
            .Minimum = -0.05,
            .Maximum = 1.05,
            .MajorStep = 0.2,
            .MinorStep = 0.05,
            .TickStyle = TickStyle.Inside
        }
        Model.Axes.Add(linearAxisY)
        Dim linearAxisX = New LinearAxis With {
            .Position = AxisPosition.Bottom,
            .Minimum = -5.25,
            .Maximum = 5.25,
            .MajorStep = 1,
            .MinorStep = 0.25,
            .TickStyle = TickStyle.Inside
        }
        Model.Axes.Add(linearAxisX)
        Model.Series.Add(CreateNormalDistributionSeries(-5, 5, 0, 0.2))
        Model.Series.Add(CreateNormalDistributionSeries(-5, 5, 0, 1))
        Model.Series.Add(CreateNormalDistributionSeries(-5, 5, 0, 5))
        Model.Series.Add(CreateNormalDistributionSeries(-5, 5, -2, 0.5))
        PlotView.Model = Model
    End Sub
    Private Function CreateNormalDistributionSeries(ByVal x0 As Double, ByVal x1 As Double, ByVal mean As Double, ByVal variance As Double, Optional ByVal n As Integer = 1001) As DataPointSeries
        Dim ls = New LineSeries With {
            .Title = String.Format("μ={0}, σ²={1}", mean, variance)
        }
        For i As Integer = 0 To n - 1
            Dim x As Double = x0 + ((x1 - x0) * i / (n - 1))
            Dim f As Double = 1.0 / Math.Sqrt(2 * Math.PI * variance) * Math.Exp(-(x - mean) * (x - mean) / 2 / variance)
            ls.Points.Add(New DataPoint(x, f))
        Next i
        Return ls
    End Function
End Class

OxyPlot ExampleBrowser.WPF Gallery for Visual Basic

OxyPlot.WindowsForms.2.0.0の動作確認メモ
ExampleBrowser.WPFの一部をVisual BasicのWindows フォームに置き換えてみました。

関連サイト

免責事項

STRONGoO(以下、「当サイト」とします。)における免責事項は、下記の通りです。

コメントについて
次の各号に掲げる内容を含むコメントは、当サイト管理人の裁量によって承認せず、削除する事があります。

  • 特定の自然人または法人を誹謗し、中傷するもの
  • 極度にわいせつな内容を含むもの
  • 禁制品の取引に関するものや、他者を害する行為の依頼など、法律によって禁止されている物品、行為の依頼や斡旋などに関するもの
  • その他、公序良俗に反し、または管理人によって承認すべきでないと認められるもの

当サイトの情報の正確性について
当サイトのコンテンツや情報において、可能な限り正確な情報を掲載するよう努めています。しかし、誤情報が入り込んだり、情報が古くなったりすることもあります。必ずしも正確性を保証するものではありません。また合法性や安全性なども保証しません。

損害等の責任について
当サイトに掲載された内容によって生じた損害等の一切の責任を負いかねますので、ご了承ください。
また当サイトからリンクやバナーなどによって他のサイトに移動された場合、移動先サイトで提供される情報、サービス等について一切の責任も負いません。
当サイトの保守、火災、停電、その他の自然災害、ウィルスや第三者の妨害等行為による不可抗力によって、当サイトによるサービスが停止したことに起因して利用者に生じた損害についても、何ら責任を負うものではありません。
当サイトを利用する場合は、自己責任で行う必要があります。

当サイトで掲載している画像の著作権や肖像権等について
当サイトで掲載している画像の著作権や肖像権等は、各権利所有者に帰属します。万が一問題がある場合は、お問い合わせよりご連絡いただけますよう宜しくお願い致します。

無断転載の禁止について
当サイトに存在する、文章や画像、動画等の著作物の情報を無断転載することを禁止します。引用の範囲を超えるものについては、法的処置を行います。転載する際には、お問い合わせよりご連絡いただけますよう宜しくお願い致します。