Page 1 of 1

different colors in one gantt bar

Posted: Wed Sep 14, 2005 8:49 am
by 9342814
Hi.

Is there anyway to draw a second color in a gantt bar???

For example, I want to draw an thin colored line a the bottom of a gantt bar to express the priority of the task.


Thanks in advance.

(D7 & TeeChart Pro 7)

Posted: Wed Sep 14, 2005 11:21 am
by narcis
Hi cbr,

You can use gradients in gantt bars. You'll find the gradient editor when using Chart Editor at Series\Gantt\Gradient.

Posted: Thu Sep 15, 2005 6:17 am
by 9342814
Hi Narcis,

thanks a lot, but it doesn't work. Because I have to draw every gantt bar in a different color according to its priority. Any idea? Is it possible to change the gradient color for each gantt bar?

Posted: Thu Sep 15, 2005 7:45 am
by narcis
Hi cbr,

Yes, it is possible using the series OnGetPointerStyle event and using code similar to:

Code: Select all

function TForm1.Series1GetPointerStyle(Sender: TChartSeries;
  ValueIndex: Integer): TSeriesPointerStyle;
begin
  With Series1.Pointer.Gradient do
    if (Series1.YValue[ValueIndex]<5) then
    begin
      StartColor:=clBlue;
      MidColor:=clRed;
    end
    else
      begin
        StartColor:=clYellow;
        MidColor:=clGreen;
      end;

  result:=psRectangle;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  With Series1 do
  begin
    FillSampleValues();
    ColorEachPoint:=False;
    Color:=clNone;
    Pointer.Gradient.Visible:=True;
  end;
end;

Posted: Fri Sep 16, 2005 12:32 pm
by 9342814
Hi narcis,

i've tried the code you send and it works quite good. But there is one last problem. By using the gradients, the gantt bars are drawn outside the axis. That means the gantt bars are not restricted by the axis.

Any Idea?

Posted: Fri Sep 16, 2005 2:06 pm
by narcis
Hi cbr,

That doesn't happen here using latest TeeChart sources in a new Delphi 7 project, dropping a TChart in a form, adding a TGanttSeries to it and using the code I posted.

Could you please post an example we can run "as-is" to reproduce the problem here? You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.

Posted: Wed Sep 21, 2005 2:53 pm
by Pep
Hi,
gradients, the gantt bars are drawn outside the axis. That means the gantt bars are not restricted by the axis.

Any Idea?
As I can see this is not related with Gradients, you can set Gradient visible to False and you will still seeing one bar outside the Axis limits. This is because you've set a SetMinMax values which are bigger and smaller of the gant start and end values respectively, changing :
Chart1.BottomAxis.SetMinMax(today - 3, today + 5);
by:
Chart1.BottomAxis.SetMinMax(today - 5, today + 7);

you will be able to see the complete gantt bar.

Posted: Thu Sep 22, 2005 7:35 am
by 9342814
Hi,

sorry, but in my opinion this is related with gradients.

I set gradient visible to false and the bars are restricted by the axis limits.

And I don't want to set the Axis MinMax Values depending on the start and end values because I want to use scrollbars to change the view.

There must be another way, any ideas ???

Thanks in advance.

Posted: Mon Sep 26, 2005 8:07 am
by Pep
Hi,

I'm sorry, you're correct, I just test it with a non CLX app. and worked fine. I've been able to reproduce it with a CLX app. It seems to be a bug, it has been added on our defect list and a fix for it will be considered to inclusion for the next maintenance releases.
For the moment I've not found a workaround.