Page 1 of 1

Can't get multiline property to work

Posted: Sat Dec 13, 2008 1:20 pm
by 15051019
We are using a Line Chart, on an Access 2007 form, to plot floating-point instrument values against a common datetime bottom axis. However the bottom axis labels are not being wrapped over two lines even though the multiline property for the axis is checked.

The data is being fetched from an Access query which returns a recordset with columns as shown below:

datetime value1 value2 value3 etc

The datetime is f the format 'dd/mm/yyyy hh:mm:ss'.

Any idea why the multiline setting isnt working please ?

Posted: Mon Dec 15, 2008 8:27 am
by narcis
Hi Chints,

Are you doing as in the example at C:\Program Files\Steema Software\TeeChart Pro v8 ActiveX Control\Examples\Visual Basic\Visual Basic 5 & 6\Multiline Axis Labels? Is this example working fine at your end? Which TeeChart version are you using?

Thanks in advance.

Posted: Mon Dec 15, 2008 10:06 am
by 15051019
Yes, the example works fine on the same machine. The main differences between my project and the example are:

- My chart has multiple series sharing a common bottom axis
- The series data is from a query recordset

Just a thought - The bottom axis labels are releated to the column in the query caled 'DateTime'. There isn't any issue with reserved keywords here is there ?

Posted: Mon Dec 15, 2008 10:16 am
by narcis
Hi Chints,
Yes, the example works fine on the same machine. The main differences between my project and the example are:

- My chart has multiple series sharing a common bottom axis
- The series data is from a query recordset
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.
Just a thought - The bottom axis labels are releated to the column in the query caled 'DateTime'. There isn't any issue with reserved keywords here is there ?
Not that I know of but there is VB/VBA reserved keyword called "DateTime" so you could try renaming this field.

Thanks in advance.

Posted: Mon Dec 15, 2008 10:54 am
by 15051019
It's difficult to produce a cut down example because the query won't work without the back end SQL Server database.

However, am I right in thinking there are two ways of producing the bottom axis labels, ie:

1) Currently I am using the following VB code to associate each point in the series with a datetime label.

me.Tchart0.Series(0).LabelsSource = "DateTime"


2) I have tried to copy the Steema example you mentioned above, ie dont use the .LabelsSource property, but instead use the following:

me.Tchart0.Axis.bottom.Increment = TChart0.GetDateTimeStep (dtOneSecond)

The mulitiline property works fine with this, but how do I set the axis labels to start at the correct time? (it currently defaults to year 1900)

Posted: Mon Dec 15, 2008 2:07 pm
by narcis
Hi Chints,
The mulitiline property works fine with this, but how do I set the axis labels to start at the correct time? (it currently defaults to year 1900)
This is most likely because of what's described here:

http://msdn.microsoft.com/en-us/library ... adate.aspx

Posted: Mon Dec 15, 2008 2:16 pm
by 15051019
Fair enough, but is there a property of the bottom axis I can write to to set the start datetime label value of the axis ?

The vb example you referred to starts from the current datetime but I'm not sure how.

Posted: Mon Dec 15, 2008 2:59 pm
by narcis
Hi Chints,

You can use SetMinMax method as shown here:

http://www.teechart.net/support/viewtopic.php?t=5657

Hope this helps!

Posted: Mon Dec 15, 2008 4:33 pm
by 15051019
OK I seem to have solved the initial multiline problem:

- I removed the following for each series -
.Labelsource = "Datetime" lines

- and added the following for each series
.XValues.Valuesource = "DateTime"

- and used the setminmax method as you suggested

However, this is now causing problems with my cursor tool:

Before the above change, the 'OnCursorToolChange' event was returning the Series array index position in the 'XVal' parameter. (eg a number 1-2000 if there are 2000 points)

Now the 'OnCursorToolChange' returns a datetime value in 'XVal'.

I was using the following line to get the Y value of a series at the cursor position:

me.txtbox.value = Tchart0.Series(0).Yvalues.Value(XVal)

This no longer works because Xval is a datetime value - any ideas please ?

Posted: Mon Dec 15, 2008 4:40 pm
by narcis
Hi Chints,
OK I seem to have solved the initial multiline problem:
I'm glad to hear that.
Before the above change, the 'OnCursorToolChange' event was returning the Series array index position in the 'XVal' parameter. (eg a number 1-2000 if there are 2000 points)

Now the 'OnCursorToolChange' returns a datetime value in 'XVal'.

I was using the following line to get the Y value of a series at the cursor position:

me.txtbox.value = Tchart0.Series(0).Yvalues.Value(XVal)

This no longer works because Xval is a datetime value - any ideas please ?
Here you are mixing series x values with series value indexes and that doesn't always coincide. You should do this:

Code: Select all

    Index = Tchart0.Series(0).XValues.Locate(XVal)
    
    If Index <> -1 Then
        Tchart0.Series(0).YValues.Value (Index)
    End If
Or something like in the interpolating example here.

Posted: Mon Dec 15, 2008 5:02 pm
by 15051019
Thanks for the support - the 'Locate' method looks like the answer, but it just returns -1 for all cursor positions on the chart.

Does the input parameter for the Locate method need to be in a specific format ?

Posted: Tue Dec 16, 2008 8:23 am
by narcis
Hi Chints,

No, the problem here is that XVal need to have exactly the same X value points have in the series otherwise Locate method doesn't find them and returns -1. In that case you'd better try using the interpolating example I pointed you in earlier posts.

Thanks in advance.

Posted: Tue Dec 16, 2008 10:09 am
by 15051019
I've used the 'snap' setting for the cursor and the Locate function now works fine.

Thanks for your help :)

Posted: Tue Dec 16, 2008 10:14 am
by narcis
Hi Chints,

I'm glad to hear you could solve the problem. This is because Snap moves the cursor to exact series points.