Markstip Tool

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jørgen
Newbie
Newbie
Posts: 14
Joined: Wed Oct 24, 2007 12:00 am

Markstip Tool

Post by Jørgen » Fri Nov 14, 2008 8:01 am

Hi

I have a small question regarding the Markstip tool. I have a chart with a highly varying number of series. To the chart I have attached TWO MarksTip Tools:
1. For all series show the Label
2. For one specific series only show X and Y values.

The hints are correctly displayed in the chart. However, the hints behaviour is a bit strange. Sometimes, they don't go aways and also they follow the mouse, i.e. if I click somewhere in the chart the hints moves to the mouse.

I guess that I have to use only one MarksTipTool and OnGetText and then somehow figure out which series is closest?

Sincerely, Jørgen

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Nov 14, 2008 8:59 am

Hi Jørgen,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here and let us know the TeeChart version you are using?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Jørgen
Newbie
Newbie
Posts: 14
Joined: Wed Oct 24, 2007 12:00 am

Post by Jørgen » Fri Nov 14, 2008 9:06 am

Hi Narcis

I'm using RAD 2007 (C++ personality) and TeeChart 8.04.


The code is pretty simple.
1. Add a TChart
2. Add two point series
3. Add two MarksTipTool and set one to all series and the other to Series2.
4. Add some points at run time.

Below is shown C++ constructer and dfm. Should I also upload project file and/or exe file?

Thanks for helping, Jørgen



__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
for (int i=0;i<100;i++)
{
Series1->AddXY(i,random(i));
Series2->AddXY(i,random(i));
}
}

object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 592
ClientWidth = 872
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Chart1: TChart
Left = 96
Top = 72
Width = 681
Height = 457
Title.Text.Strings = (
'TChart')
View3D = False
TabOrder = 0
ColorPaletteIndex = 13
object Series1: TPointSeries
Marks.Arrow.Visible = True
Marks.Callout.Brush.Color = clBlack
Marks.Callout.Arrow.Visible = True
Marks.Visible = False
ClickableLine = False
Pointer.InflateMargins = True
Pointer.Style = psRectangle
Pointer.Visible = True
XValues.Name = 'X'
XValues.Order = loAscending
YValues.Name = 'Y'
YValues.Order = loNone
end
object Series2: TPointSeries
Marks.Arrow.Visible = True
Marks.Callout.Brush.Color = clBlack
Marks.Callout.Arrow.Visible = True
Marks.Visible = False
ClickableLine = False
Pointer.InflateMargins = True
Pointer.Style = psRectangle
Pointer.Visible = True
XValues.Name = 'X'
XValues.Order = loAscending
YValues.Name = 'Y'
YValues.Order = loNone
end
object ChartTool1: TMarksTipTool
MouseDelay = 50
Style = smsXY
end
object ChartTool2: TMarksTipTool
MouseDelay = 50
Series = Series2
Style = smsXY
end
end
end

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Nov 18, 2008 12:45 pm

Hi Jørgen,

In that case you'd better use one single tool for all series and customize its text depending on clicked series, for example:

Code: Select all

//---------------------------------------------------------------------------
void __fastcall TForm3::ChartTool1GetText(TMarksTipTool *Sender,
	  AnsiString &Text)
{
	if (ValueIndex != -1) {
		Text = Chart1->Series[SeriesIndex]->Labels->Labels[ValueIndex];

		if (SeriesIndex == 0) {
			Text = Text + ": " + FloatToStr(Chart1->Series[SeriesIndex]->XValues->Value[ValueIndex]) +
					" " + FloatToStr(Chart1->Series[SeriesIndex]->YValues->Value[ValueIndex]);
		}
	}
}
//---------------------------------------------------------------------------

void __fastcall TForm3::Chart1MouseMove(TObject *Sender, TShiftState Shift,
	  int X, int Y)
{
	int i;
	for (i = 0; i < Chart1->SeriesCount(); i++) {
		ValueIndex = Chart1->Series[i]->Clicked(X,Y);

		if (ValueIndex != -1) {
			SeriesIndex = i;
			break;
		}
	}
}
//---------------------------------------------------------------------------
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply