Date format in axes labels problem
Posted: Thu Sep 06, 2007 11:33 am
I have a Line Chart and will use datetime for the X-axe and doubles for Y-axe.
The line seems OK but the bottom lables is not showing datetimes, only plain numerical values.
I have tried almost anything, but not got it right.
What am I doing wrong?
Here is my code:
Friend Sub SetGraphPosition()
Dim strProcedureName As String = mcstrModuleName & "_SetGraphPosition"
Dim intIndex As Integer
Dim dtblLinePosition As New DataTable("dtblLinePosition")
Dim colXData As DataColumn
Dim colYData As DataColumn
Dim dtblRow As DataRow
Try
Me.TChart1.Header.Visible = False
Me.TChart1.Footer.Visible = False
colXData = New DataColumn("XData", Type.GetType("System.DateTime"))
colYData = New DataColumn("YData", Type.GetType("System.Double"))
dtblLinePosition.Columns.Add(colXData)
dtblLinePosition.Columns.Add(colYData)
For intIndex = 1 To gclsCurrentMeasurement.PositionsCount
dtblRow = dtblLinePosition.NewRow()
dtblRow("XData") = gclsCurrentMeasurement.MeasPositionDate(intIndex)
dtblRow("YData") = gclsCurrentMeasurement.RMSValue(intIndex, 1)
dtblLinePosition.Rows.Add(dtblRow)
Next intIndex
Me.TChart1.Axes.Bottom.Automatic = True
Me.TChart1.Axes.Bottom.Logarithmic = False
Me.TChart1.Axes.Bottom.Title.Caption = Nothing
Me.TChart1.Axes.Bottom.Title.Font.Size = 12
Me.TChart1.Axes.Bottom.Title.Font.Bold = True
Me.TChart1.Axes.Bottom.Labels.Exponent = False
Me.TChart1.Axes.Bottom.Labels.Angle = 90
Me.TChart1.Axes.Left.Automatic = False
Me.TChart1.Axes.Left.Logarithmic = True
Me.TChart1.Axes.Left.LogarithmicBase = 10
Me.TChart1.Axes.Left.Title.Caption = Nothing
Me.TChart1.Axes.Left.Title.Font.Size = 12
Me.TChart1.Axes.Left.Title.Font.Bold = True
Me.TChart1.Axes.Left.Labels.Exponent = False
Me.TChart1.Axes.Left.Labels.ValueFormat = "0"
Me.TChart1.Axes.Left.Labels.Items.Clear()
If (gclsCurrentMeasurement.BandStandardNo(1, 1) = 1) Then 'Normal
Me.TChart1.Axes.Left.Minimum = 10
Me.TChart1.Axes.Left.Maximum = 10000000
Me.TChart1.Axes.Left.Labels.Items.Add(10, "10nT")
Me.TChart1.Axes.Left.Labels.Items.Add(100, "100nT")
Me.TChart1.Axes.Left.Labels.Items.Add(1000, "1uT")
Me.TChart1.Axes.Left.Labels.Items.Add(10000, "10uT")
Me.TChart1.Axes.Left.Labels.Items.Add(100000, "100uT")
Me.TChart1.Axes.Left.Labels.Items.Add(1000000, "1mT")
Me.TChart1.Axes.Left.Labels.Items.Add(10000000, "10mT")
Else
Me.TChart1.Axes.Left.Minimum = 0.01
Me.TChart1.Axes.Left.Maximum = 10000
Me.TChart1.Axes.Left.Labels.Items.Add(0.01, "0.01%")
Me.TChart1.Axes.Left.Labels.Items.Add(0.1, "0.1%")
Me.TChart1.Axes.Left.Labels.Items.Add(1, "1%")
Me.TChart1.Axes.Left.Labels.Items.Add(10, "10%")
Me.TChart1.Axes.Left.Labels.Items.Add(100, "100%")
Me.TChart1.Axes.Left.Labels.Items.Add(1000, "1000%")
Me.TChart1.Axes.Left.Labels.Items.Add(10000, "10000%")
End If
Me.Line1 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
Me.Line1.Color = Color.Blue
Me.Line1.Visible = True
Me.Line1.XValues.DataMember = dtblLinePosition.Columns("XData").ToString()
Me.Line1.XValues.DateTime = True
Me.Line1.YValues.DataMember = dtblLinePosition.Columns("YData").ToString()
Me.Line1.DataSource = dtblLinePosition
Catch ex As Exception
Call ErrorLogWrite(strProcedureName, ex.Source & ": " & ex.GetType.ToString & "/" & ex.Message)
MessageBox.Show(gstrLge_UnexpectedError & ":" & ex.GetType.ToString & "/" & ex.Message _
& "/" & strProcedureName, _
My.Application.Info.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Kind Regards GoestaE
The line seems OK but the bottom lables is not showing datetimes, only plain numerical values.
I have tried almost anything, but not got it right.
What am I doing wrong?
Here is my code:
Friend Sub SetGraphPosition()
Dim strProcedureName As String = mcstrModuleName & "_SetGraphPosition"
Dim intIndex As Integer
Dim dtblLinePosition As New DataTable("dtblLinePosition")
Dim colXData As DataColumn
Dim colYData As DataColumn
Dim dtblRow As DataRow
Try
Me.TChart1.Header.Visible = False
Me.TChart1.Footer.Visible = False
colXData = New DataColumn("XData", Type.GetType("System.DateTime"))
colYData = New DataColumn("YData", Type.GetType("System.Double"))
dtblLinePosition.Columns.Add(colXData)
dtblLinePosition.Columns.Add(colYData)
For intIndex = 1 To gclsCurrentMeasurement.PositionsCount
dtblRow = dtblLinePosition.NewRow()
dtblRow("XData") = gclsCurrentMeasurement.MeasPositionDate(intIndex)
dtblRow("YData") = gclsCurrentMeasurement.RMSValue(intIndex, 1)
dtblLinePosition.Rows.Add(dtblRow)
Next intIndex
Me.TChart1.Axes.Bottom.Automatic = True
Me.TChart1.Axes.Bottom.Logarithmic = False
Me.TChart1.Axes.Bottom.Title.Caption = Nothing
Me.TChart1.Axes.Bottom.Title.Font.Size = 12
Me.TChart1.Axes.Bottom.Title.Font.Bold = True
Me.TChart1.Axes.Bottom.Labels.Exponent = False
Me.TChart1.Axes.Bottom.Labels.Angle = 90
Me.TChart1.Axes.Left.Automatic = False
Me.TChart1.Axes.Left.Logarithmic = True
Me.TChart1.Axes.Left.LogarithmicBase = 10
Me.TChart1.Axes.Left.Title.Caption = Nothing
Me.TChart1.Axes.Left.Title.Font.Size = 12
Me.TChart1.Axes.Left.Title.Font.Bold = True
Me.TChart1.Axes.Left.Labels.Exponent = False
Me.TChart1.Axes.Left.Labels.ValueFormat = "0"
Me.TChart1.Axes.Left.Labels.Items.Clear()
If (gclsCurrentMeasurement.BandStandardNo(1, 1) = 1) Then 'Normal
Me.TChart1.Axes.Left.Minimum = 10
Me.TChart1.Axes.Left.Maximum = 10000000
Me.TChart1.Axes.Left.Labels.Items.Add(10, "10nT")
Me.TChart1.Axes.Left.Labels.Items.Add(100, "100nT")
Me.TChart1.Axes.Left.Labels.Items.Add(1000, "1uT")
Me.TChart1.Axes.Left.Labels.Items.Add(10000, "10uT")
Me.TChart1.Axes.Left.Labels.Items.Add(100000, "100uT")
Me.TChart1.Axes.Left.Labels.Items.Add(1000000, "1mT")
Me.TChart1.Axes.Left.Labels.Items.Add(10000000, "10mT")
Else
Me.TChart1.Axes.Left.Minimum = 0.01
Me.TChart1.Axes.Left.Maximum = 10000
Me.TChart1.Axes.Left.Labels.Items.Add(0.01, "0.01%")
Me.TChart1.Axes.Left.Labels.Items.Add(0.1, "0.1%")
Me.TChart1.Axes.Left.Labels.Items.Add(1, "1%")
Me.TChart1.Axes.Left.Labels.Items.Add(10, "10%")
Me.TChart1.Axes.Left.Labels.Items.Add(100, "100%")
Me.TChart1.Axes.Left.Labels.Items.Add(1000, "1000%")
Me.TChart1.Axes.Left.Labels.Items.Add(10000, "10000%")
End If
Me.Line1 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
Me.Line1.Color = Color.Blue
Me.Line1.Visible = True
Me.Line1.XValues.DataMember = dtblLinePosition.Columns("XData").ToString()
Me.Line1.XValues.DateTime = True
Me.Line1.YValues.DataMember = dtblLinePosition.Columns("YData").ToString()
Me.Line1.DataSource = dtblLinePosition
Catch ex As Exception
Call ErrorLogWrite(strProcedureName, ex.Source & ": " & ex.GetType.ToString & "/" & ex.Message)
MessageBox.Show(gstrLge_UnexpectedError & ":" & ex.GetType.ToString & "/" & ex.Message _
& "/" & strProcedureName, _
My.Application.Info.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Kind Regards GoestaE