2

I try to use the right axis of TeeChart for PHP. 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. I cut and pasted the demo and try to export it to javascript instead of rendering it. I used this code to export to 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...)

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();?>
4
  • I don't have the right to see that snapshot
    – Yeray
    Commented Sep 4, 2015 at 13:20
  • Now everyone should have access. Sorry, first time working with Google Drive access management. Commented Sep 4, 2015 at 13:42
  • I see. Could you please arrange a simple example test project we can run as-is to reproduce the problem here?
    – Yeray
    Commented Sep 4, 2015 at 15:04
  • @Yeray See my edit on my original post... Commented Sep 8, 2015 at 11:58

1 Answer 1

0

I've modified the end of your test page to show both the HTML5 and the PHP charts at the same page:

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.

It now looks like this:

html5 on the left, php on the right

Please, send a mail to "[email protected]" and we'll send you the modified unit (JavaScriptExport.php).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.