Retrieving Gantt bars from DBChart
Retrieving Gantt bars from DBChart
Hi,
I'd like to connect tasks in a gantt. I'm using data aware dbchart, so i thought this:
TChartSeries* myseries;
for(int i = 0; i<ChartListBox->Count; i++){
if(ChartListBox->Series->Active){
myseries = ChartListBox->Series;
break;
}
}
TGanttSeries* xseries = dynamic_cast<TGanttSeries*>(myseries);
if(xseries){
xseries->NextTask[0] = 1; //1. compiler error
xseries->NextTask->Items[0] = 1; //2. does nothing
}
which is how i understand the delphi code example in the help. Here I'm assuming 0 is the first gantt bar, 1 the next etc.
However, for code line 1) the compiler complains it could not find a match for operator TChartValueList::=(int)?,
and 2 does nothing.
Better yet, click a bar, (ctrl) click another bar, release ctrl, to join them graphically. Perhaps i'm being overly optimistic!
All help appreciated.
Cheers, nile.
I'd like to connect tasks in a gantt. I'm using data aware dbchart, so i thought this:
TChartSeries* myseries;
for(int i = 0; i<ChartListBox->Count; i++){
if(ChartListBox->Series->Active){
myseries = ChartListBox->Series;
break;
}
}
TGanttSeries* xseries = dynamic_cast<TGanttSeries*>(myseries);
if(xseries){
xseries->NextTask[0] = 1; //1. compiler error
xseries->NextTask->Items[0] = 1; //2. does nothing
}
which is how i understand the delphi code example in the help. Here I'm assuming 0 is the first gantt bar, 1 the next etc.
However, for code line 1) the compiler complains it could not find a match for operator TChartValueList::=(int)?,
and 2 does nothing.
Better yet, click a bar, (ctrl) click another bar, release ctrl, to join them graphically. Perhaps i'm being overly optimistic!
All help appreciated.
Cheers, nile.
To be or not to be. This is not the question. Rather it is a choice.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi nile,
Hope this helps!
You need to do this:However, for code line 1) the compiler complains it could not find a match for operator TChartValueList::=(int)?,
and 2 does nothing.
Code: Select all
Series1->NextTask->Value[i]=-1;
Not at all! You can do something like this:Better yet, click a bar, (ctrl) click another bar, release ctrl, to join them graphically. Perhaps i'm being overly optimistic!
Code: Select all
void __fastcall TForm4::FormCreate(TObject *Sender)
{
Series1->FillSampleValues();
//Reset all NextTastk values
for (int i = 0; i < Series1->Count(); i++) {
Series1->NextTask->Value[i]=-1;
}
BarIndex=-1;
}
//---------------------------------------------------------------------------
void __fastcall TForm4::Series1Click(TChartSeries *Sender, int ValueIndex, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if (BarIndex==-1) {
BarIndex=ValueIndex;
}
else
{
if (Shift.Contains(ssCtrl)) {
Series1->NextTask->Value[BarIndex]=ValueIndex;
Series1->Repaint();
BarIndex=-1;
}
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis,
Thanks and nicely done - but there is a problem. First, because i'm using a dbchart, i don't have access to the onclick event of a specific chart. No problem, i can get this using the ChartClickSeries event. However, when running the code, I can click on some bars, and the event fires. However i click on other bars, and no event fires. What am i doing wrong?
Thanks,
nile.
void __fastcall TChartsNew::ChartClickSeries(TCustomChart *Sender,
TChartSeries *Series, int ValueIndex, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
TGanttSeries* myseries;
if(Series->Name == "GanttChart"){
myseries = dynamic_cast<TGanttSeries*>(Series);
if(!myseries) return;
if (BarIndex==-1) {
BarIndex=ValueIndex;
}
else
{
if (Shift.Contains(ssCtrl)) {
myseries->NextTask->Value[BarIndex]=ValueIndex;
myseries->Repaint();
BarIndex=-1;
}
}
}
}
Thanks and nicely done - but there is a problem. First, because i'm using a dbchart, i don't have access to the onclick event of a specific chart. No problem, i can get this using the ChartClickSeries event. However, when running the code, I can click on some bars, and the event fires. However i click on other bars, and no event fires. What am i doing wrong?
Thanks,
nile.
void __fastcall TChartsNew::ChartClickSeries(TCustomChart *Sender,
TChartSeries *Series, int ValueIndex, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
TGanttSeries* myseries;
if(Series->Name == "GanttChart"){
myseries = dynamic_cast<TGanttSeries*>(Series);
if(!myseries) return;
if (BarIndex==-1) {
BarIndex=ValueIndex;
}
else
{
if (Shift.Contains(ssCtrl)) {
myseries->NextTask->Value[BarIndex]=ValueIndex;
myseries->Repaint();
BarIndex=-1;
}
}
}
}
To be or not to be. This is not the question. Rather it is a choice.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi nile,
This event is Series' OnClick event. Anyway you can use chart's OnClickSeries event and both events are available in TChart and TDBChart.
Your code works fine for me here. If problem persists 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.
This event is Series' OnClick event. Anyway you can use chart's OnClickSeries event and both events are available in TChart and TDBChart.
Your code works fine for me here. If problem persists 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.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis,
I've uploaded a 3mb monolithic plus project file zip. I'm using virtual tables for this exampled code. Just select the gantt, fill with act start/end and folder title in labels to see the issues with joining bars.
Thanks, nile.
I've uploaded a 3mb monolithic plus project file zip. I'm using virtual tables for this exampled code. Just select the gantt, fill with act start/end and folder title in labels to see the issues with joining bars.
Thanks, nile.
To be or not to be. This is not the question. Rather it is a choice.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi nile,
Thanks for the example project. I couldn't compile it here because it uses TSMDBGrid and TVirtualTable components which we don't have here. Also, running the exe you sent, I didn't see any problem in it. Could you please let us know which is the exact problem and the exact steps we should follow to reproduce it? You may also want to send us a simple example project we can run "as-is" so that we can debug it here.
Thanks in advance.
Thanks for the example project. I couldn't compile it here because it uses TSMDBGrid and TVirtualTable components which we don't have here. Also, running the exe you sent, I didn't see any problem in it. Could you please let us know which is the exact problem and the exact steps we should follow to reproduce it? You may also want to send us a simple example project we can run "as-is" so that we can debug it here.
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 |
Instructions - How to post in this forum |
Hi Narcis,
Ah, this is promising. If the exe ran as you expected, then perhaps i'm doing it wrong. I understood that you clicked a bar in the gantt, and then using ctrl, clicked another bar to join them up. When i do this on the exe i sent you, it's quite a hit and miss affair. So perhaps this is where i'm falling over.
Thanks, nile.
Ah, this is promising. If the exe ran as you expected, then perhaps i'm doing it wrong. I understood that you clicked a bar in the gantt, and then using ctrl, clicked another bar to join them up. When i do this on the exe i sent you, it's quite a hit and miss affair. So perhaps this is where i'm falling over.
Thanks, nile.
To be or not to be. This is not the question. Rather it is a choice.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi nile,
Yes, exactly, that's how it works. This works fine for me here as you can see in the video below. You'll have to open it in Internet Explorer.
http://www.teechart.net/files/public/su ... e.swf.html
Could you please let us know the exact steps we should follow to reproduce the issue here?
Thanks in advance.
Yes, exactly, that's how it works. This works fine for me here as you can see in the video below. You'll have to open it in Internet Explorer.
http://www.teechart.net/files/public/su ... e.swf.html
Could you please let us know the exact steps we should follow to reproduce the issue here?
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 |
Instructions - How to post in this forum |
Hi Narcis,
Fabulous demo! I can clearly see why i was being unsuccessful, as you have to be quite precise in where you position the mouse cursor prior to selecting: specifically on the actual bar, and NOT on the depth rendering, as i think i was doing.
Many thanks, Nile.
Fabulous demo! I can clearly see why i was being unsuccessful, as you have to be quite precise in where you position the mouse cursor prior to selecting: specifically on the actual bar, and NOT on the depth rendering, as i think i was doing.
Many thanks, Nile.
To be or not to be. This is not the question. Rather it is a choice.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Nile,
You're welcome. I'm glad to hear that helped.
Yes, you need to use as if it were a 2D chart. Setting the chart to be 2D may make things easier:
You're welcome. I'm glad to hear that helped.
Yes, you need to use as if it were a 2D chart. Setting the chart to be 2D may make things easier:
Code: Select all
Chart1->View3D=false;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |