Page 1 of 1

Rounded border and colored panel issue

Posted: Thu Nov 20, 2008 3:01 am
by 9337917
Folks,

If I set the back panel to some non-white color, and set borders visible and rounded:

Code: Select all

    Chart1.Border.Visible := TRUE;

    with Chart1 do begin
       BorderRound    := 100;
       BorderStyle  := bsSingle;

       Border.Width := 50;
       Border.Color := clRed;
    end
the back panel's square corners are clearly visible, sticking out on "the wrong side" of each rounded corner. Can they be, in effect, masked off or clipped?

I searched the forum, but came up empty-handed.

Thanks!
Regards,
richard diamond

Posted: Thu Nov 20, 2008 8:48 am
by narcis
Hi richard,

I think I don't get exactly what you reported. With both, v7 and v8, I get something this:

Image

Is this what you get? Anyway, I have added the issue to the defect list (TV52013579) to be fixed.

Posted: Thu Nov 20, 2008 2:30 pm
by 9337917
Narcís,

Sorry I wasn't clear (at all). It's simple to recreate, it's just my description that sucked.

Chart1.Color. That's what I should have said. Set Chart1.Color to something like clRed . I think then you'll see the issue I'm describing immediately.

By the way, there's a faint, but visible, white (rounded border) line JUST on the inside of each rounded corner in your screen shot. I've seen that before. Can that be taken out of a generated chart by setting a property to match Chart1.Color?

richard diamond

Posted: Thu Nov 20, 2008 2:43 pm
by 9337917
Narcís,

Uhhh.. I'm not awake yet.... NOT CLRED! (but you knew I didn't mean that!).

Please try setting Chart1.Color to anything BUT clRed. clBlue is a fine choice..;)

I need BrainChecker. For Christmas maybe, you'll get me that? Huh? Huh?


richard diamond

Posted: Mon Nov 24, 2008 10:52 am
by Pep
Hello,

to hide it change the BevelOuter to :

Chart1.BevelOuter := bvNone;

Posted: Mon Nov 24, 2008 4:04 pm
by 9337917
Pep,

Thank you for your reply..:)

I must have described the problem wrong, so maybe the screenshot (I made it Christmassy..;) I just uploaded will help. The English language can be very slippery. Perhaps that's why no one programs in it???!!!

I do set bvInner and bvOuter to bvNone, yet you see the effect. So there's something I'm leaving out of my problem description.

Regards,
richard diamond

Posted: Mon Nov 24, 2008 6:35 pm
by narcis
Hi richard,

In v8 there's it works almost fine but there's also a little problem which I already added to the defect list (TV52013598).

However, to solve this problem you can do something like code below. Specially note code in OnAfterDraw event. Can you please check if this works fine at your end?

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.ExplodeBiggest:= 20;
  Series1.Marks.Transparent:=true;
  Series1.Shadow.Visible := false;

  Chart1.Border.Visible := True;
  Chart1.BevelOuter := bvNone;
  chart1.Color := clred;

    with Chart1 do begin
       BorderRound    := 50;
       BorderStyle  := bsSingle;

       Border.Width := 25;
       Border.Color := clgreen
    end
    end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  Chart1.Canvas.Brush.Style := bsClear;
  Chart1.Canvas.pen.Color := clgreen;
  Chart1.Canvas.pen.Width := 50;
  Chart1.canvas.RoundRect(Chart1.ChartBounds,50,50);
end;
Thanks in advance.

Posted: Mon Nov 24, 2008 8:32 pm
by 9337917
Narcís,

I'm just going to start calling you Magic Man..:) It worked fine!!!

With just a few variations to your sample OnAfteDrawEvent, it does exactly what was needed!! It now responds perfectly to the users' requested width, rounding, and color choices:

Code: Select all

with Chart1.Canvas do begin
  Brush.Style := bsClear;
  Pen.Color   := clrGetBackPanelBorder;
  Pen.Width   := iGetBackPanelBorderWidth;
  RoundRect( Chart1.ChartBounds, Pen.Width, Pen.Width  );
end;
Thank you so much..:)

richard diamond

Posted: Tue Nov 25, 2008 11:09 am
by narcis
Hi richard,

You're welcome! I'm glad to hear that worked
I'm just going to start calling you Magic Man.
Je je, you'd better use Magic Team as I needed Pep's help here :wink:.

Posted: Tue Nov 25, 2008 4:06 pm
by 9337917
Narcís, okay, Dream Team it is...:)

I played with it a bit, and noticed a few things that might be of interest to others watching this thread, or reading it down the road in a search.

1) Your sample AfterDraw handler, which was great, had one small issue. The FormCreate border width of 25 in wasn't reflected in AfterChart's Pen.Width. Instead, it showed it at 50. I didn't notice that at first:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  Chart1.Canvas.Brush.Style := bsClear;
  Chart1.Canvas.pen.Color := clgreen;
  Chart1.Canvas.pen.Width := 25; // <=== (Border.Width)
  Chart1.canvas.RoundRect(Chart1.ChartBounds,50,50);
end;

Similarly, my code excerpt needed a parallel tweak:

Code: Select all

with Chart1.Canvas do begin
  Brush.Style := bsClear;
  Pen.Color   := clrGetBackPanelBorder;
  Pen.Width   := iGetBackPanelBorderWidth; // <=== (Border.Width)
  RoundRect( Chart1.ChartBounds, iRoundedAmt, iRoundedAmt ); //<== iRoundedAmt, *not* pen.width
end;
2) WHY do I bother pointing this out? This is the part that might be of interest to you. I found some value combinations of Pen.Width and the last two arguments to Chart1.Canvas.RoundedRect worked wonderfully. Others combinations not so hot, allowing the Chart's ChartBounds rect to peek out from each of the four corners, so they bled out of the rounded corners.

This general formula seems to work fine: Pen.Width < ( iRoundedAmt + 1 ) < Pen.Width * 2.5.

If, however, PenWidth was, say, 5, and the rounding amount passed as the last two parameters to RoundRect was 50 (both reasonable values), the back square peeks out of each corner.

So as long as the values used for Pen.Width and the rounding value are in a certain kind of relationship, this code works really well! Thank you AGAIN!

Regards,
richard diamond

p.s., I *was* surprised, and delighted, that Pep jumped in as well!

Posted: Fri Nov 28, 2008 9:43 am
by narcis
Hi richard,
Narcís, okay, Dream Team it is...
Thank you very much but honestly I think we really don't deserve this. A little bit exagerated :wink:.

I think only one Dream Team has existed. Well, for me 2 :wink: and we had the luck to enjoy both of them in Barcelona in the early 90's!

http://en.wikipedia.org/wiki/Dream_team
I played with it a bit, and noticed a few things that might be of interest to others watching this thread, or reading it down the road in a search.
Thank you very much for sharing your findings. I have added this information to the wish-list to be considered for inclusion in future releases too.