Page 1 of 1
show selected bar on gantt chart
Posted: Wed Feb 25, 2009 2:54 pm
by 13051613
Hello, i have this gantt charts in the same forms:
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:
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?
Posted: Thu Feb 26, 2009 10:27 am
by yeray
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;
}
Posted: Mon Mar 02, 2009 12:34 pm
by 13051613
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?
Posted: Mon Mar 02, 2009 1:20 pm
by 13051613
i have found the correct options.
it's ok.
Posted: Mon Mar 02, 2009 2:29 pm
by yeray
Hi Pujol,
I'm happy to see you solved it!
Posted: Mon Mar 02, 2009 5:09 pm
by 13051613
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:
after i do the click the bar change its Y value!!
there's an error on my code? or it's a bug?
thanks in advance
Posted: Tue Mar 03, 2009 3:17 pm
by narcis
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
Posted: Tue Mar 03, 2009 4:12 pm
by 13051613
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.
Posted: Tue Mar 03, 2009 4:21 pm
by narcis
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.
Posted: Tue Mar 03, 2009 4:43 pm
by 13051613
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
Posted: Wed Mar 04, 2009 8:59 am
by 13051613
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.
Posted: Wed Mar 04, 2009 9:51 am
by narcis
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.
Posted: Wed Mar 04, 2009 9:56 am
by 13051613
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.