简体   繁体   English

TeeChart for PHP:图像渲染和JavaScript导出之间的区别

[英]TeeChart for PHP : Differences between image render and JavaScript Export

I try to use the right axis of TeeChart for PHP. 我尝试为PHP使用TeeChart的右轴。 I'm aware that we need to link a valid serie to both vertical axis. 我知道我们需要将有效的系列链接到两个垂直轴。 In fact, I have tried a simple test with the custom axis demo on the Steema site. 实际上,我已经在Steema网站上使用自定义轴演示尝试了一个简单的测试。 I cut and pasted the demo and try to export it to javascript instead of rendering it. 我剪切并粘贴了该演示,然后尝试将其导出到javascript而不是呈现它。 I used this code to export to javascript : 我使用此代码导出到javascript:

echo  $tChart1->getChart()->getExport()->getImage()->getJavaScript()->Render()->toString();

Here is a snapshot of the 2 renders side-by-side (sorry to put it in a link, this forum don't allow me to post pictures yet...) 是2个渲染的并排快照(很抱歉,将其放在链接中,此论坛不允许我发布图片...)

Is there a way to get the right axis to show with the export? 有没有一种方法可以使右轴与导出一起显示?

EDIT: Here is the code to test on your side : 编辑:这是要在您这边测试的代码:

<?php 
    //Includes 
    include "../../../sources/TChart.php"; 

    $chart1 = new TChart(600,450); 
    $chart1->getChart()->getHeader()->setText("Custom Axes Demo"); 
    $chart1->getAspect()->setView3D(false); 

    $line1 = new Line($chart1->getChart()); 
    $line2 = new Line($chart1->getChart()); 
    $line1->setColor(Color::RED()); 
    $line2->setColor(Color::GREEN()); 
    $chart1->addSeries($line1); 
    $chart1->addSeries($line2); 

    // Speed optimization 
    $chart1->getChart()->setAutoRepaint(false); 

    for($t = 0; $t <= 10; ++$t) { 
      $line1->addXY($t, (10 + $t), Color::RED()); 
      if($t > 1) { 
        $line2->addXY($t, $t, Color::GREEN()); 
      } 
    }  

    $chart1->getAxes()->getLeft()->setStartPosition(0); 
    $chart1->getAxes()->getLeft()->setEndPosition(50);         
    $chart1->getAxes()->getLeft()->getAxisPen()->color = Color::RED(); 
    $chart1->getAxes()->getLeft()->getTitle()->getFont()->setColor(Color::RED()); 
    $chart1->getAxes()->getLeft()->getTitle()->getFont()->setBold(true); 
    $chart1->getAxes()->getLeft()->getTitle()->setText("1st Left Axis"); 

    $chart1->getAxes()->getTop()->getLabels()->setAngle(45); 
    $chart1->getAxes()->getTop()->getTitle()->getFont()->setColor(Color::YELLOW()); 
    $chart1->getAxes()->getTop()->getTitle()->getFont()->setBold(true); 

    $chart1->getAxes()->getBottom()->getLabels()->setAngle(0); 
    $chart1->getAxes()->getRight()->getLabels()->setAngle(45); 
    $chart1->getAxes()->getBottom()->getTitle()->getFont()->setColor(new Color(255,25,25)); 
    $chart1->getAxes()->getBottom()->getTitle()->getFont()->setBold(true); 
    $chart1->getAxes()->getRight()->getTitle()->getFont()->setColor(Color::BLUE()); 
    $chart1->getAxes()->getRight()->getTitle()->getFont()->setBold(true); 
    $chart1->getAxes()->getRight()->getTitle()->setText("OtherSide Axis"); 
    $chart1->getAxes()->getRight()->getLabels()->getFont()->setColor(Color::BLUE()); 
    $chart1->getAxes()->getRight()->getAxisPen()->setColor(Color::BLUE());         

    $chart1->getAxes()->getTop()->getTitle()->setText("Top Axis"); 
    $chart1->getAxes()->getBottom()->getTitle()->setText("Bottom Axis"); 

    $line1->setHorizontalAxis(HorizontalAxis::$BOTH); 
    $line1->setVerticalAxis(VerticalAxis::$BOTH); 

    $axis1 = new Axis(false, false, $chart1->getChart()); 
    $chart1->getAxes()->getCustom()->add($axis1); 
    $line2->setCustomVertAxis($axis1); 
    $axis1->setStartPosition(50); 
    $axis1->setEndPosition(100); 
    $axis1->getTitle()->getFont()->setColor(Color::GREEN());         
    $axis1->getTitle()->getFont()->setBold(true); 
    $axis1->getTitle()->setText("Extra Axis"); 
    $axis1->getTitle()->setAngle(90); 
    $axis1->setRelativePosition(20); 
    $axis1->getAxisPen()->setColor(Color::GREEN()); 
    $axis1->getGrid()->setVisible(false); 

    echo  $tChart1->getChart()->getExport()->getImage()->getJavaScript()->Render()->toString();?>

I've modified the end of your test page to show both the HTML5 and the PHP charts at the same page: 我已经修改了测试页的末尾,以在同一页上显示HTML5和PHP图表:

echo  $chart1->getChart()->getExport()->getImage()->getJavaScript()->Render()->toString();
$chart1->render("chart1.png");
$rand=rand();
print '<img src="chart1.png?rand='.$rand.'">';

Then, I've modified TeeChart PHP sources to also export the custom axes and the assign. 然后,我修改了TeeChart PHP源代码,以也导出自定义轴和分配。

It now looks like this: 现在看起来像这样:

左侧是html5,右侧是php

Please, send a mail to "info@steema.com" and we'll send you the modified unit (JavaScriptExport.php). 请发送邮件至“ info@st​​eema.com”,我们将向您发送修改后的单位(JavaScriptExport.php)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM