Page 1 of 1

How to add an unfilled bubble to a TBubbleSeries

Posted: Mon Apr 28, 2014 9:18 pm
by 16468326
Hello,

When adding a bubble to a TBubbleSeries, you specify the color. How can I specify that I want a particular bubble to be unfilled. i.e. the border of of the bubble should be there, but there should be no fill. I want to use this to indicate the value the bubble is supposed to represent is undefined (i.e. NAN). All the rest of the bubbles should be colored like normal.

Re: How to add an unfilled bubble to a TBubbleSeries

Posted: Tue Apr 29, 2014 8:43 am
by yeray
Hello David,

You can use null points (clNone color) in conjunction with OnGetPointerStyle as follows:

Code: Select all

uses BubbleCh, Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    tmpColor: TColor;
begin
  Chart1.View3D:=false;

  with Chart1.AddSeries(TBubbleSeries) as TBubbleSeries do
  begin
    for i:=0 to 9 do
    begin
      if i=5 then
        tmpColor:=clNone
      else
        tmpColor:=clTeeColor;

      AddBubble(i, random*1000, (1000/15.0)+Round(1000/(10+random*15)), '', tmpColor);
    end;

    OnGetPointerStyle:=BubbleGetPointerStyle;
  end;
end;

function TForm1.BubbleGetPointerStyle(Sender:TChartSeries; ValueIndex:Integer):TSeriesPointerStyle;
begin
  if Sender is TBubbleSeries then
    with Sender as TBubbleSeries do
    begin
      if IsNull(ValueIndex) then
        Pointer.Brush.Style:=bsClear
      else
        Pointer.Brush.Color:=Sender.ValueColor[ValueIndex];

      Result:=Pointer.Style;
    end;
end;

Re: How to add an unfilled bubble to a TBubbleSeries

Posted: Tue Apr 29, 2014 3:59 pm
by 16468326
Hi Yeray,

Thank you. That should work.