Problems with Teechart PHP Source code

TeeChart for PHP
Post Reply
pacwin
Newbie
Newbie
Posts: 7
Joined: Mon Mar 02, 2009 12:00 am

Problems with Teechart PHP Source code

Post by pacwin » Tue Mar 03, 2009 12:56 am

I have been trying to generate a simple multiple series bar chart and having difficulty setting the Axis Labels.

I am using this method
from an arry to populate the Axis labels.

$teechart->getAxes()->getBottom()->getLabels()->getItems()->add($key,$val);

Where $key is an incrementing sequence and $val is text i.e "Q1 2005"

However the source code (and the obfuscated version)
return this exception:

PHP Fatal error: Call to undefined method ArrayObject::add() in C:\Program Files\CodeGear\Delphi for PHP\2.0\vcl\teechart\axis\AxisLabelsItems.php on line 0

This is because AxisLabelsItems inherits from ArrayObject and there is no method add defined for ArrayObject or obviously the descendant class. Probably what is meant here is the parent::append() method of ArrayObject.

Scanning through the source code I think I found a second instance where this phantom add method was being called: SliceValueList::setSlice

public function setSlice($index, $value) {
while ($index >= sizeof($this)) {

parent::add(0);
}

if ( ((int)parent::offsetGet($index)) != $value) {
parent::offsetSet($index, $value);
$this->OwnerSeries->repaint();
}
}

The method from AxisLabelsItems is


public function add($value, $text=null) {

$result = new AxisLabelItem($this->iAxis->chart);
$result->iAxisLabelsItems = $this;
$result->setTransparent(true);
$result->setValue($value);

parent::add($result);

if ($text != null) {
$result->setText($text);
}
return $result;
}

I can obviously procede by editing the source code but there are multiple other errors appearing which in some cases are points where the code times out and nothing is ever rendered (Im using this in Delphi 4 PHP context, sometimes under a debugger but in any case the times can exceed 10 minutes.)

php[5612]
PHP Fatal error: Class 'TextShape' not found in C:\Program Files\CodeGear\Delphi for PHP\2.0\vcl\teechart\styles\SeriesMarks.php on line 16

php[4716]
PHP Fatal error: Call to undefined method AxisLabelsItems::get() in C:\Program Files\CodeGear\Delphi for PHP\2.0\vcl\teechart\axis\AxisLabelsItems.php on line 50

I suspect this might be another call that should be to ArrayObject::offsetGet

In any event I would like to confiorm the easiest way to add a barchart so that the Axis Labels can be populated with the apropriate text (these Axis labels represet Quarter-Year Combinations as above)

Secondly Im faced with mixing obfuscated files with edited source to keep this working: which src files enable the charting license.?

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Mar 03, 2009 10:54 am

Hi pacwin,

thanks for the report, you're correct, there was a bug trying to set a specific labels for axis. I've fixed it in the source code and updated on our web site. Could you please check if it works fine now using the sources from our web site (at the private customers download page) ?

There's also another easy way (depending on how and when you need to modify the axis labels) to add data with specific texts, it's by using the AddYText(Yvalue,Text); or AddXYText(XValue,YValue,Text) methods :

Code: Select all

        $bar->addYText(10,"label");
        //$bar->addXYText(0,10,"label");             $chart->getChart()->getAxes()->getBottom()->getLabels()->setStyle(AxisLabelStyle::$TEXT);
        $bar->getMarks()->setVisible(false);

// To draw custom labels on the axis :
        $chart->getChart()->getAxes()->getBottom()->getLabels()->getItems()->clear();
        $chart->getChart()->getAxes()->getBottom()->getLabels()->getItems()->add(0,"mylabel");

Secondly Im faced with mixing obfuscated files with edited source to keep this working: which src files enable the charting license.?
I'm sorry, I'm not sure what you refer here, could you please explain me which the problem is ? Adding the include of the TChart.php file should be sufficient to work for both obfuscated and not obfuscated sources.

pacwin
Newbie
Newbie
Posts: 7
Joined: Mon Mar 02, 2009 12:00 am

Continuing problems with sourcecode

Post by pacwin » Wed Mar 04, 2009 11:12 am

Unfortunately we have been unable to proceed any further than two days ago. In fact we seem to have regressed. It was possible to add Series and assign values using the obfuscted trial code (11 Feb 2009 filedate)

However we have not been able to proceed with your revised source code beyond calling the following code:


$barseries = new Bar($teechart->getChart());

or alternately

$teechart->getChart()->addSeries(new Bar($teechart->getChart()));

this raises a PHP fatal exception:


php[4536]
PHP Fatal error: Call to a member function count() on a non-object in C:\Program Files\CodeGear\Delphi for PHP\2.0\vcl\teechart\Chart.php on line 1461

This is because adding a series to the series collection must call Series::maxTextWidth

public function maxTextWidth() {
$tmpResult = 0;
for ($t = 0; $t < $this->series->count(); $t++) {
$s = $this->series->getSeries($t);
if ($s->getLabels()->count() > 0) {
for ($tt = 0; $tt < $s->getCount(); $tt++) {
$tmpResult = max($tmpResult,
$this->multiLineTextWidth($s->getLabels()->getString($tt))->width);
}
}
}
return $tmpResult;
}

however the problem here is that the class variable sLabels is not always being treated as an array (nor is $s necessarily not null if its creating a Bar and not yet adding it to the series collection, therefore count() fails as its not a descendant of ArrayObject.

If its a plain array then I guess we want count($s->getLabels()). There are a couple of other oddities in this class which will probably cause
failure. This is where sLabels is being treated as some object:

i.e (getLabels is returning an Array())

$this->getLabels()->setString($tmpIndex, $source->sLabels[$valueIndex]); (Line 998)

$this->getLabels()->setString($valueIndex, $text); (line 1049)
and see the commented out line 3178.

and also
$this->sLabels->exchange($a, $b); // TODO array exchange (line 2859)

wheras exchange is a member function of Series, ColorlIst, SliceValueList, ExplodedSliceList, SeriesCollection and Value List but not evidently of anything to do with Series labels.

What i meant by mixing obfuscted and source code was that we had some success in getting the evaluation code to render charts but could not render any charts with the source code. My question was which of the source code files enable the full product as opposed to the evaluation? so that we could at least limp along with a partly working chart until it was fixed.

I think you should supply both human readable and obfuscted licensed code so that the obfuscted code can be deployed protecting your and my investment.

in any event we cannot deploy anything right now so if you would make the necessary changes/fixes and test it so that basic chart functionality is working that would be appreciated.

Cheers,
Steve Cooney

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Mar 04, 2009 1:22 pm

Hi Steve,

I've fixed all of these problems into the latest sources updated on our web site. Could you please download and check if now works fine for you ?
In the case you still having problems, please let me know which part of code you're using in order to check it here and change/fix all relevant parts.
I think you should supply both human readable and obfuscted licensed code so that the obfuscted code can be deployed protecting your and my investment.
Yes, you're correct, we forgot to add a link into the "Private Customers download" page for source code customers to be able to download the obfuscated version. Now it has been added. Thanks for the advise !
What i meant by mixing obfuscted and source code was that we had some success in getting the evaluation code to render charts but could not render any charts with the source code. My question was which of the source code files enable the full product as opposed to the evaluation? so that we could at least limp along with a partly working chart until it was fixed.
It's very strange, the Eval version uses the same code as the registered one, it only modifyes the output but internally generates the chart using the same sources. The code was specially designed in this way in order to save this kind of problems. Please make sure you're using the samve Build for both (in case you test it with both).
in any event we cannot deploy anything right now so if you would make the necessary changes/fixes and test it so that basic chart functionality is working that would be appreciated.
Sure, I've fixed all the parts you mentioned and updated sources on our web site. Please check them and do not hesitate to contact me in the case you still having problems.

pacwin
Newbie
Newbie
Posts: 7
Joined: Mon Mar 02, 2009 12:00 am

Availability of Obfuscated PHP Code

Post by pacwin » Thu Mar 05, 2009 9:41 am

Unfortunately my Steema supplied password and so forth will not allow the jar installer to provide the sources.zip file. Instead we get an "Activation Error" dialogue "License CANNOT BE Activated. Please verify details and retry, or use activation by phone."

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Mar 05, 2009 12:38 pm

Hi Steve,

yes, sorry I forgot to update the obfuscated installer which allow to be activated for source code customers.
Now, it has been updated on our web site, at the same location.

Post Reply