【发布时间】:2018-10-02 05:09:08
【问题描述】:
我一直在尝试使用 Techart 为一个项目绘制几个图表。我已经成功地绘制了图表。我正在努力用一些标签来注释图表上的特定点。
具体问题是当我使用 $chart1->CalcXPos(someIndex);它总是返回 0 而不是像素值。我该如何解决这个问题?
$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");
【问题讨论】:
-
能否添加一些示例代码?
-
已添加示例代码。我很抱歉。
标签: php annotations teechart