Marks position with SubChartTool

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Eic2
Newbie
Newbie
Posts: 2
Joined: Mon Sep 25, 2017 12:00 am

Marks position with SubChartTool

Post by Eic2 » Wed Jan 24, 2018 4:33 pm

Hello,

I am currently working with subChartTool and have some visual problems when i manually move marks in a sub chart.
1)At first everything is place where i want but as soon as a draw occur, the marks are draw like if the TChart is at the TopLeft of the parent TChart, as you can see in the attachment.
The marks still react whith the mouseOver in the expected position and not where they are draw.(in the attachment 4th Mark text color is reacting to the cursor).
2)The same problem happen with tips too.
3)When i set Tchart->Title->AdjustFrame = true; in a sub chart, the title of all the subchart in the same row are draw on each other.(attachment : titles B1 and B2 in the 2nd chart title position).

Do you have any way to avoid this problem ?

Another question : Is their a way to detect if a TChart is a subchart without accessing to the subChartTool?
Attachments
marksMultiChart.png
marksMultiChart.png (37.67 KiB) Viewed 8668 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Marks position with SubChartTool

Post by Yeray » Fri Jan 26, 2018 9:03 am

Hello,
Eic2 wrote:1)At first everything is place where i want but as soon as a draw occur, the marks are draw like if the TChart is at the TopLeft of the parent TChart, as you can see in the attachment.
The marks still react whith the mouseOver in the expected position and not where they are draw.(in the attachment 4th Mark text color is reacting to the cursor).
I can't reproduce this problem. I can drag the marks and they are redrawn at the correct positions for me.
Eic2 wrote:2)The same problem happen with tips too.
I see a different problem. Mark tips don't seem to appear in a subchart for me here.
Eic2 wrote:3)When i set Tchart->Title->AdjustFrame = true; in a sub chart, the title of all the subchart in the same row are draw on each other.(attachment : titles B1 and B2 in the 2nd chart title position).
I can reproduce this one. It seems the vertical position is correct, but the horizontal position is wrong.
I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1978

Here the test project. Could you please modify it or arrange a new simple project we can run as-is to reproduce all the problems here?
testSubChart.zip
(84.35 KiB) Downloaded 718 times
Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Eic2
Newbie
Newbie
Posts: 2
Joined: Mon Sep 25, 2017 12:00 am

Re: Marks position with SubChartTool

Post by Eic2 » Fri Feb 02, 2018 3:45 pm

Thanks for your reply,

1) Most of the time i display the chart through image, so i place everything with code.
You can find my test project in attachment, I've try to make it as simple as possible. It work with c++Builder.

2) In my project the tips currently don't work with subcharts, It seem that i have made a change that broke it and can't figure what.

3)Do you have any way to solve the problem before it's solve ?
Attachments
testProjectTeeChart.zip
(57.57 KiB) Downloaded 721 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Marks position with SubChartTool

Post by Yeray » Mon Feb 05, 2018 12:32 pm

Hello,

1) I could reproduce this issue thanks to your application. You are manually positioning the marks positions relative to your subcharts, but they are absolute pixel positions, relative to the main chart.
So you should store the SubCharts positions and use it as Offsets in your MoveMarks function.

2) I've tried removing most part of the code in your project and I can't find what's wrong either. I've even tried in a new simple project and it seems to work fine:

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   subChartTool = new TSubChartTool(Chart1);
   Chart1->Tools->Add(subChartTool);

   AddSubChart("SubChart1");
   AddSubChart("SubChart2");
   AddSubChart("SubChart3");

   PlaceSubCharts();
   Chart1->Draw();
}
//---------------------------------------------------------------------------
void TForm1::AddSubChart(String ATitle)
{
	TChart * subChart = subChartTool->Charts->AddChart(ATitle);

	subChart->Color=clBtnFace;
	subChart->View3D=False;

	subChart->Title->Caption=ATitle;
	subChart->Title->Show();

	TDonutSeries * series = new TDonutSeries(subChart);
	subChart->AddSeries(series);

	series->FillSampleValues();

	series->Marks->Arrow->Hide();
	series->Marks->Callout->Arrow->Hide();

	TMarksTipTool * marksTip = new TMarksTipTool(subChart);
	subChart->Tools->Add(marksTip);
	marksTip->SystemHints=false;

	Chart1->Draw();
}
//---------------------------------------------------------------------------
void TForm1::PlaceSubCharts()
{
  int i, iOffsetY, iEqualWidth;
  int iDeltaOffsetY = 0;
  double dCoeff1 = 0.5;
  double dCoeff2 = 0.5;

  TSubChartTool * subChartTool = dynamic_cast<TSubChartTool*>(Chart1->Tools->Items[0]);

  TSubChart * subChart1 = subChartTool->Charts->Items[0];
  subChart1->Top = 0;
  subChart1->Height = Chart1->Height * dCoeff1;
  subChart1->Left = 0;
  subChart1->Width = Chart1->Width;

  if (subChartTool->Charts->Count > 1)
  {
	iOffsetY = subChart1->Top + subChart1->Height + iDeltaOffsetY;
	iEqualWidth = (Chart1->Width - 0) / (subChartTool->Charts->Count - 1);
	for (int i=1; i<subChartTool->Charts->Count; i++)
	{
	  subChartTool->Charts->Items[i]->Top = iOffsetY;
	  subChartTool->Charts->Items[i]->Height = Chart1->Height * dCoeff2;
	  if (i > 1)
		subChartTool->Charts->Items[i]->Left = (i - 1) * iEqualWidth + ((i > 1) ? 1 : 0);
	  else
		subChartTool->Charts->Items[i]->Left = 0;

	  subChartTool->Charts->Items[i]->Width = iEqualWidth;
	}
  }
}
3) You could try using a TAnnotationTool instead of a Title.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply