Page 1 of 1

Date format in axes labels problem

Posted: Thu Sep 06, 2007 11:33 am
by 9641600
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

Posted: Thu Sep 06, 2007 12:04 pm
by narcis
Hi GoestaE,

Setting XValues.DateTime=true should be enough. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Wed Sep 12, 2007 3:19 pm
by 9641600
narcis wrote:Hi GoestaE,

Setting XValues.DateTime=true should be enough. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Hello, I have solved my problem in a way I do not understand.
I had two styles set to the chart, and when I added the styles in the properties windows, I could not get the date format, only numeric, but if I added the styles by code instead, then it worked correct...
Maybe you can find the reason for this?

Kind Regards
GoestaE

Posted: Thu Sep 13, 2007 7:35 am
by narcis
Hi GoestaE,

I'm not sure what you exactly mean with "styles set to the chart". Which exact properties were you using in the chart editor and which properties had to use at run-time? Could you please elaborate on that?

Thanks in advance!