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