I've been trying to use Teechart to draw a couple of graphs for a project. I've managed to draw the graphs just fine. What I am struggling with is annotating specific points on the graph with some labels.
The specific problem is that when I use $chart1->CalcXPos(someIndex); it always returns 0 instead of a value of the pixels. How can I got about resolving this?
$chart1 = new TChart(640,480);
$varname = new Line($chart1->getChart());
$someYValues = array(2,3,5,7,11,13);
$theXValues = array(-3,-1,1,3,4,5);
$i=0;
foreach($someYValues as $x){
$varname->addXY($theXValues[$i],$someYValues[$i]);
$i++;
}
$varname->Setcolor(Color::BLUE());
$chart1->getAxes()->getBottom()->getTitle()->setText("X-axis label (units)");
$chart1->getAxes()->getLeft()->getTitle()->setText("Y-axis label (units)");
$tool=new Annotation($chart1->getChart());
$tool->getShape()->setCustomPosition(true);
//$chart1->paint;
$xvalue = $chart1->getAxes()->getBottom()->CalcXPosValue($theXValues[2]);
$yvalue = $chart1->getAxes()->getLeft()->CalcYPosValue($someYValues[2]);
//$xvalue = $varname->CalcXPosValue($theXValues[2]);
//$yvalue = $varname->CalcYPosValue($someYValues[2]);
echo $xvalue;
echo $yvalue;
$tool->setTop($xvalue);
$tool->setLeft($yvalue);
$tool->setText("Random Text ");
$chart1->render("ecg.png");