show selected bar on gantt chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

show selected bar on gantt chart

Post by Pujol1986 » Wed Feb 25, 2009 2:54 pm

Hello, i have this gantt charts in the same forms:

Image

like you can see, i have selected 1 bar in the upper chart, this bar changes its color to darkgreen.

in the other chart, you can see that it's 1 bar selected (the same bar as in the upper chart).

look at this picture now:

Image

another bar is selected, but in the second chart we can't see it because there are a lot of bars over it, in the same position.

how i can do that my selected bar will be show over the other bars?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Feb 26, 2009 10:27 am

Hi Pujol,

The gantts are shown taking in consideration their order in the series' valuelist. So, to show a gantt hided below another, you could swap the gantt for the first one. Here there is a method you could use:

Code: Select all

private void GantToFront(int ValueIndex)
        {
            double tmp = gantt1.StartValues[0];
            gantt1.StartValues[0] = gantt1.StartValues[ValueIndex];
            gantt1.StartValues[ValueIndex] = tmp;

            tmp = gantt1.EndValues[0];
            gantt1.EndValues[0] = gantt1.EndValues[ValueIndex];
            gantt1.EndValues[ValueIndex] = tmp;

            tmp = gantt1.YValues[0];
            gantt1.YValues[0] = gantt1.YValues[ValueIndex];
            gantt1.YValues[ValueIndex] = tmp;

            Color tmpcolor = gantt1.Colors[0];
            gantt1.Colors[0] = gantt1.Colors[ValueIndex];
            gantt1.Colors[ValueIndex] = tmpcolor;

            string tmpstring = gantt1.Labels[0];
            gantt1.Labels[0] = gantt1.Labels[ValueIndex];
            gantt1.Labels[ValueIndex] = tmpstring;

            tmp = gantt1.NextTasks[0];
            gantt1.NextTasks[0] = gantt1.NextTasks[ValueIndex];
            gantt1.NextTasks[ValueIndex] = tmp;
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Mon Mar 02, 2009 12:34 pm

this code doesn't work with teechart v3 for visual basic .net

i have now this sub on my aplication:

Code: Select all

   Private Sub gantttofront(ByVal valueindex As Integer)
        Dim tmp As Double
        Dim tmpcolor As Color
        Dim tmpstring As String
        tmp = Gantt1(0).X
        Gantt1(0).X = Gantt1(valueindex).X
        Gantt1(valueindex).X = tmp

        '  tmp = Gantt1(0).EndValues
        '  Gantt1(0).EndValues = Gantt1(valueindex).EndValues
        '  Gantt1(valueindex).EndValues = tmp

        tmp = Gantt1(0).Y
        Gantt1(0).Y = Gantt1(valueindex).Y
        Gantt1(valueindex).Y = tmp

        tmpcolor = Gantt1(0).Color
        Gantt1(0).Color = Gantt1(valueindex).Color
        Gantt1(valueindex).Color = tmpcolor

        tmpstring = Gantt1(0).Label
        Gantt1(0).Label = Gantt1(valueindex).Label
        Gantt1(valueindex).Label = tmpstring

        ' tmp = Gantt1(0).NextTasks
        ' Gantt1(0).NextTasks = Gantt1(valueindex).NextTasks
        ' Gantt1(valueindex).NextTasks = tmp
    End Sub
like you can see there are some lines comented with ' simbol

this lines doesn't work because the 'EndValues' and 'NextTasks' atributes is not avaiable on VB.Net version.

how i can do this?

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Mon Mar 02, 2009 1:20 pm

i have found the correct options.

it's ok.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Mar 02, 2009 2:29 pm

Hi Pujol,

I'm happy to see you solved it!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Mon Mar 02, 2009 5:09 pm

well, i have now a new problem, but i don't know if this is a bug or error on my code...

this is my code:

Code: Select all

  
 Private Sub gantttofront(ByVal valueindex As Integer)
        Dim tmp As Double
        Dim tmpcolor As Color
        Dim tmpstring As String

        tmp = Gantt1.StartValues(0)
        Gantt1.StartValues(0) = Gantt1.StartValues(valueindex)
        Gantt1.StartValues(valueindex) = tmp

        tmp = Gantt1.EndValues(0)
        Gantt1.EndValues(0) = Gantt1.EndValues(valueindex)
        Gantt1.EndValues(valueindex) = tmp

        Gantt1.Draw()
    End Sub
this will change the startvalues and endvalues of the bar in position 'valueindex' and 0

i'm right?

well... i click on the bar that is marked with a red circle on the upper chart, then the program will execute the code to change bar values.

befor make the click we can see it:

Image

after i do the click the bar change its Y value!!

Image

there's an error on my code? or it's a bug?

thanks in advance ;)

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 03, 2009 3:17 pm

Hi Pujol1986,

I think this is a bug in your code. Besides changing StartValues and EndValues you should also change YValues, Labels and NextTasks as Yeray did in his example
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Tue Mar 03, 2009 4:12 pm

Hi Narcís,

My code is not like Yerays example, i have wrotte only the code that i paste in my last post.

i only change the startvalues and the endvalues of two gantt bars.

i don't change the YValues, the labels or the nexttask.

The same code has been tested on aplication with manual datasource and it works.

My aplication datasource is a Oracle DataBase.

Thanks in advance.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 03, 2009 4:21 pm

Hi Pujol1986,
i don't change the YValues, the labels or the nexttask.
I think that's the problem.
The same code has been tested on aplication with manual datasource and it works.
It may work by some lucky coincidence. However, I think this is the problem given the images you posted.

If this doesn't help 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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Tue Mar 03, 2009 4:43 pm

Hi Narcís,

tomorrow i will do an example of the error and send it to steema.

I only change the startvalues and the endvalues because i commented the other lines to know in what line the error is.

Thank you

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Wed Mar 04, 2009 8:59 am

Hi Narcís,

I'm working with oracle.
Can you test my aplication if i send you the tables scripts and data?

what did you need? the folder of the aplication?

thanks in advance.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 04, 2009 9:51 am

Hi Pujol1986,

You could create a test data table at runtime as Christopher Ireland's example here.

You should send project files but it's not necessary to send compiled files ("bin" and "obj" folders).

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Wed Mar 04, 2009 9:56 am

I have done an aplication with oracle datasource and changed the startvalues and endvalues of two lines, and it WORKS!

i can't reproduce the bug in another project.

i'll check and test my code again to find the problem (i don't think that's a bug of TeeChart)

i'll post what was the problem when i found it.

Thanks for all.

Post Reply