Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with TChart 1

Status
Not open for further replies.

xor2

Programmer
Mar 24, 2005
22
Hi!
I have several problems with TChart component and one line axis:

- How to display "Point" (circle on each (x,y) coordinates.
This options can be set in designing window (Series tabsheet->Point->Visible := true)); I have to do it from code

- is it possible to change the shape of Marks on each point?
I have value on yellow rectangular and when i have 2, 3 axises, one Mark may overlap with another. I would like to change Mark on only small number without rectangular

- How to print chart to fit all A4 Page in landscape printer mode ?

Really thanks for help
 
If I understand you correctly, you would like to:
[ul]
[li]Display the point co-ordinates when the mouse is over a point[/li]
[li]Alter the point marks to different shapes (on series)[/li]
[li]Print the chart in landscape on the default printer as large as possible[/li]
[/ul]

Most of this information is on the TeeChart website ( but here are a few starters:
1. Display point values - from their web site in fact, and adapted for my own use.
Code:
procedure TF_Main.QRChart_CUSUMMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
// Straight from the website for TeeChart!

var tmpL,tmpL2,ClickedValue : Integer;

begin
  clickedvalue := -1;
  tmpL2:= -1;

  With QRChart_CUSUM do
  begin
    If (Series1.Clicked(X, Y) <> -1) And (not OnSeriesPoint) Then
    begin
      Canvas.Brush.Style := bsSolid;
      Canvas.Pen.Color := clBlack;
      Canvas.Brush.Color := clWhite;
      if (abs(Series1.YScreenToValue(y)) > 2) and (B_Analyse.Enabled)then
        Canvas.Font.Color := clRed
      else
        Canvas.Font.Color := clMaroon;
      Canvas.Font.Height := -7;
      Canvas.Font.Size := 3;
      Canvas.TextOut(x+10,y,DateToStr(Series1.XScreenToValue(x)));  [b]// display the coordinate[/b]
      Canvas.TextOut(x+10,y+15,FormatFloat('#.0',Series1.YScreenToValue(y)));
      OnSeriesPoint := True;
      ClickedValue:= Series1.Clicked(x,y);
    End;

    //Repaint Chart to clear Textoutputted Mark
    If (ClickedValue=-1) And (OnSeriesPoint) Then
    begin
      OnSeriesPoint := False;
      invalidate;
    End;

    tmpL := QRChart_CUSUM.Legend.Clicked(X, Y);

    If (tmpL <> -1) And ((tmpL <> tmpL2) Or (not OnLegendPoint)) Then
    begin
      repaint;
      Canvas.Brush.Color := Series1.LegendItemColor(tmpL);
      Canvas.Rectangle( X, Y, X + 20, Y + 20);
      Canvas.Brush.Color := clWhite;
      Canvas.Font.Color := clMaroon;
      Canvas.TextOut(x+15,y+7,DateToStr(Series1.XValues[Series1.LegendToValueIndex(tmpl)]));
      Canvas.Font.Height := -7;
      Canvas.Font.Size := 4;
      tmpL2 := tmpL;
      OnLegendPoint := True;
    End;

    If (tmpL2 = -1) And (OnLegendPoint) Then
    begin
      OnLegendPoint := False;
      Invalidate;
    End;
  End;
end;

2. Point shape - check out the help on TSeriesPointerStyleType. But you can simply do this....
Code:
  Series1.Pointer.Style := psCircle;

3. Printing the chart in landscape orientation to full size:
First you need to set your margins on the page, then print it
Code:
procedure TF_Main.B_PrintClick(Sender: TObject);
// Send the graph to the printer in Landscape orientation - maximise to full page
var
  PrintRct : tRect;
  OldPOrient : tPrinterOrientation;
begin
  OldPOrient := Printer.Orientation;// store old orientation
  PrintRct.Top := 0;    // define the rectangle to max size
  PrintRct.Left := 0;
  PrintRct.Bottom := Printer.PageWidth-1;
  PrintRct.Right := Printer.PageHeight-1;
  with QRChart_CUSUM do begin
    Printer.Orientation := poLandScape; // set to landscape
    PrintRect(PrintRct); // print it
    Printer.Orientation := oldPOrient; // restore orientation
  end;
end;

Hope that helps!

Chris ;-)
 
I think Chris misunderstood your first request.
- How to display "Point" (circle on each (x,y) coordinates.
This options can be set in designing window (Series tabsheet->Point->Visible := true)); I have to do it from code

Only some series have a pointer. But if it is such a series then the following code will have the same effect as the ticking the checkbox you mentioned in the design window:
Code:
  Series1.Pointer.Visible := True;
The above will display the pointers on the series.

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Thank you Guys. I have solved problems.

There is another question.
Is it possible to have 3 charts on one TChart component?
I have 3 series (lines) and in various places overlap with others ?

Thanks


 
Can you just clarify, do you mean you want 3 line series on one TChart? Do you want the 3 series to overlap or not?

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
You will need 3 separate TChart objects.

Your best bet would be to do the following:
1) drop a TPanel on your form
2) select the TPanel, then drop a TChart (repeat this step 3 times)
3) set the Align property of the 1st TChart to alTop
4) set the Align property of the 2nd TChart to alBottom
5) set the Align property of the 3rd TChart to alClient
6) ensure the Height property is the same for all 3 charts

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
There is only one problem ;(
I have to print chart on whole A4 page.

Is it possible to do it with TChart?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top