Page 1 of 1

chart SetVisible affects Annotation

Posted: Tue Jul 09, 2013 5:47 am
by 9529132
I got two charts and I use chart.SetVisible to switch between the displays. I have both colorband and annotations on both charts and the chart that got initially displayed can show the Annotations correctly, but when I switch between the two charts, all Annotations were gone. Would any please suggest how to solve this problem? Below are the codes I used.

Both charts have colorband and annotations.

Code: Select all

	m_chart2.GetTools().Add(tcColorband);
	m_chart2.GetTools().Add(tcColorband);
	m_chart2.GetTools().GetItems(0).GetAsColorband().SetStartValue(0.5);
	m_chart2.GetTools().GetItems(0).GetAsColorband().SetEndValue(6.0);
	m_chart2.GetTools().GetItems(0).GetAsColorband().SetColor(LIGHTYELLOW);
	m_chart2.GetTools().GetItems(0).GetAsColorband().SetTransparency(95);
	m_chart2.GetTools().GetItems(0).GetAsColorband().SetAxis(v);
	m_chart2.GetTools().GetItems(0).SetActive(TRUE);

	m_chart2.GetTools().GetItems(1).GetAsColorband().SetStartValue(12);
	m_chart2.GetTools().GetItems(1).GetAsColorband().SetEndValue(18);
	m_chart2.GetTools().GetItems(1).GetAsColorband().SetColor(LIGHTBLUE);
	m_chart2.GetTools().GetItems(1).GetAsColorband().SetTransparency(95);
	m_chart2.GetTools().GetItems(1).GetAsColorband().SetAxis(v);
	m_chart2.GetTools().GetItems(1).SetActive(TRUE);

	m_chart2.GetTools().Add(tcAnnotate);
	m_chart2.GetTools().GetItems(2).GetAsAnnotation().SetPositionUnits(puPercent);
	m_chart2.GetTools().GetItems(2).GetAsAnnotation().SetLeft(15);
	m_chart2.GetTools().GetItems(2).GetAsAnnotation().SetTop(10);
	m_chart2.GetTools().GetItems(2).GetAsAnnotation().SetText(_T("VCi"));

	m_chart2.GetTools().Add(tcAnnotate);
	m_chart2.GetTools().GetItems(3).GetAsAnnotation().SetPositionUnits(puPercent);
	m_chart2.GetTools().GetItems(3).GetAsAnnotation().SetLeft(45);
	m_chart2.GetTools().GetItems(3).GetAsAnnotation().SetTop(10);
	m_chart2.GetTools().GetItems(3).GetAsAnnotation().SetText(_T("VAi"));
This is how I switch the display.

Code: Select all

	m_chart1.SetVisible(TRUE);
	m_chart2.SetVisible(FALSE);

Re: chart SetVisible affects Annotation

Posted: Tue Jul 09, 2013 10:13 am
by yeray
Hi,

Try using

Code: Select all

SetPositionUnits(puPixels);
And then positioning the annotation with absolute values in pixels. With puPercent the annotations positions are recalculated at each repaint