1
Support Questions / Re: Stylizing the basicTrendChart
« on: February 12, 2015, 07:45:38 AM »
Yhippee! after a bit more help (thanks) and some tinkering, it now works!
Thanks Archie for your help, not only for helping to make it work but also expanding my ability.
Now I know how to add my own properties and such
now just to wrap my head around classes and their methods interaction... maybe one day I may be as talented as you!
For any peeps who may want it, here is the final code:
Enjoy!
Thanks Archie for your help, not only for helping to make it work but also expanding my ability.
Now I know how to add my own properties and such
now just to wrap my head around classes and their methods interaction... maybe one day I may be as talented as you!
For any peeps who may want it, here is the final code:
Code: [Select]
Public Class BasicTrendChartEx
Inherits BasicTrendChart
Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
'* Fill in the background color
e.Graphics.FillRectangle(New SolidBrush(BackColour), 0, 0, Me.Width, Me.Height)
Dim x1, y1 As Integer
Dim x2, y2 As Integer
'* Draw the line connecting the points
If Points.Count > 1 Then
Dim index As Integer = 0
While index < (Points.Count - 2)
Try
'* calculate the x and y coordinates based on the Points collection
x1 = Me.Width - Convert.ToInt32((Me.Width / MaxPoints) * index)
y1 = Me.Height - Convert.ToInt32((Me.Height / (YMaximum - YMinimum)) * (Points(index) - YMinimum))
x2 = Me.Width - Convert.ToInt32((Me.Width / MaxPoints) * (index + 1))
y2 = Me.Height - Convert.ToInt32((Me.Height / (YMaximum - YMinimum)) * (Points(index + 1) - YMinimum))
'*^ this was y1
Dim StartPixel As New Point(x1, y1)
Dim EndPixel As New Point(x2, y2)
'e.Graphics.DrawLine(System.Drawing.Pens.Yellow, StartPixel, EndPixel)
e.Graphics.DrawLine(System.Drawing.Pens.Yellow, x1, y1, x2, y2)
Catch ex As Exception
Dim dbg = 0
End Try
index += 1
End While
End If
'* Draw the Axis
e.Graphics.DrawLine(System.Drawing.Pens.White, 0, 0, 0, Me.Height)
e.Graphics.DrawLine(System.Drawing.Pens.White, 0, Me.Height - 1, Me.Width, Me.Height - 1)
e.Graphics.DrawString(YMaximum.ToString, New Drawing.Font("Arial", 10.0!), System.Drawing.Brushes.White, 0.0!, 0.0!)
'* ^^^^^^^^^^^^^^^ this was MaxValue
e.Graphics.DrawString(YMinimum.ToString, New Drawing.Font("Arial", 10), System.Drawing.Brushes.White, 0, Me.Height - 16)
End Sub
Private _BackColour As Drawing.Color = Drawing.Color.Green
Public Property BackColour() As Drawing.Color
Get
Return _BackColour
End Get
Set(ByVal value As Drawing.Color)
_BackColour = value
End Set
End Property
End Class
Enjoy!