Page 1 of 1

Changing point of TPOINTSERIES

Posted: Mon Nov 05, 2012 8:41 am
by 16462341
Hi,

In the case of linepen I can just the BorderEditor to change the line - for instance to make it dashed etc... (see attached photo)

Is there any possibility to use a simlar dialog box to change the point of the TPointSeries?

I know I can use the the ChartEditor - but it is so complicated and contains too many details...

Isn't there a possibility to change just the point of the TPointSeries itself? (change it from a square to a circle to a triangle, start etc?) similar to the border editor?

Actually, what I'm looking for is a predefined combobox where you can choose between the appearance of the TPoint i.e., square, circle, triangle, star etc

Re: Changing point of TPOINTSERIES

Posted: Mon Nov 05, 2012 4:25 pm
by yeray
Hi,

I'm afraid there's not a component for this. However, you can always create your own combobox with the pointer styles:
Square
Circle
Triangle
Down Triangle
Cross
Diagonal Cross
Star
Diamond
Small Dot
Nothing
Left Triangle
Right Triangle
Hexagon
Visual

Re: Changing point of TPOINTSERIES

Posted: Wed Nov 07, 2012 7:37 am
by 16462341
Can you give me a short example of how to put the actual images of the Square, Circle, triangle, Down Triangle etc. into the combobox?

Of course, I can put the text insie a combobox but how do I "take" the actual images from the TPointerSeries and put it into the combobox?

Re: Changing point of TPOINTSERIES

Posted: Wed Nov 07, 2012 11:08 am
by yeray
Hi Friis,

As you'll see in the TeeChart sources if you have them, we basically call the TPointSeries Pointer.DrawPointer() method in the TComboFlat's OnDrawItem event to do so.

Re: Changing point of TPOINTSERIES

Posted: Wed Nov 07, 2012 3:11 pm
by 16462341
Hi,

I have tried to use this method but it gives me a "Acces violation error"

Code: Select all

procedure TForm10.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin

with Control as TComboBox do
    begin
      Series1.Pointer.DrawPointer(TCanvas3D(canvas),true,0,0,5,5,clred,PSCircle);
    end;

end;

Re: Changing point of TPOINTSERIES

Posted: Thu Nov 08, 2012 11:31 am
by yeray
Hi Friis,

This seems to work fine for me here:

Code: Select all

uses Series, TeCanvas;

var Series1: TPointSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  Series1:=Chart1.AddSeries(TPointSeries) as TPointSeries;
  Series1.FillSampleValues;

  ComboBox1.Items.Add('Square');
  ComboBox1.Items.Add('Circle');
  ComboBox1.Items.Add('Triangle');
  ComboBox1.Items.Add('Down Triangle');
  ComboBox1.Items.Add('Cross');
  ComboBox1.Items.Add('Diagonal Cross');
  ComboBox1.Items.Add('Star');
  ComboBox1.Items.Add('Diamond');
  ComboBox1.Items.Add('Small Dot');
  ComboBox1.Items.Add('Nothing');
  ComboBox1.Items.Add('Left Triangle');
  ComboBox1.Items.Add('Right Triangle');
  ComboBox1.Items.Add('Hexagon');
  ComboBox1.Items.Add('Visual');

  ComboBox1.ItemIndex:=0;
  ComboBox1.Style:=csOwnerDrawFixed;
end;

procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var ACanvas: TTeeCanvas3D;
    tmp: TColor;
    tmpStyle: TSeriesPointerStyle;
begin
  ComboBox1.Canvas.FillRect(Rect);

  With Series1.Pointer do
  begin
    ACanvas:=TTeeCanvas3D.Create;
    ACanvas.ReferenceCanvas:=ComboBox1.Canvas;
    tmp:=ParentSeries.SeriesColor;
    tmpStyle:=TSeriesPointerStyle(Index);

    DrawPointer(ACanvas, false, Rect.Left+6, Rect.Top+6+2, 4, 4, tmp, tmpStyle);
  end;
  With ComboBox1, Canvas do
  begin
    Brush.Style:=bsClear;
    TextOut(Rect.Left+14,Rect.Top+2,Items[Index]);
  end;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  Series1.Pointer.Style:=TSeriesPointerStyle(ComboBox1.ItemIndex);
end;