JpGraph: LinePlot->SetWeight will not work - php

I am using JpGraph version 3.5.0b1 to create some graphs for a PDF document and I have hit a problem that has taken half of my day trying to work out whats going wrong.
All i want to do is change the line thickness of my lineplot but no matter what I try, it always defaults to 1 (assuming 1 is the default).
I have done my research and know that I have to set it after I add it to the graph and also that if antialias is set to true then SetWeight is ignored. My code follows these rules and yet still nothing. I am able to change the colour of the line so I know its nothing to do with how I'm calling the methods.
Can anyone help me here please? I would be hugely grateful as it is starting to annoy me just a tad.
Anyway, here is a little snippet of my code:
$lineplot = new LinePlot($ydata, $xdata);
$graph->Add($lineplot);
$lineplot->SetColor("red");
$lineplot->SetWeight(2);

SetWeight() will do nothing until you turn off anti-aliasing. JpGraph mentions this in their manual in the using anti-aliasing page.
I tested this in version 3.5.0b1 and the following must be done:
// Ensure anti-aliasing is off. If it is not, you can SetWeight() all day and nothing will change.
$graph->img->SetAntiAliasing(false);
// Create linear plot
$lineplot = new LinePlot($ydata, $xdata);
// Add plot to graph
$graph->Add($lineplot);
// Set line weight. This must be done AFTER adding the plot to the graph in version 3.5.0b1. I haven't verified this in other versions.
$lineplot->SetWeight(2);

I ran into this same thing, seems to be a bug with 3.5 as far as I can tell. It's even ignored in the examples distributed with 3.5.
Falling back to 3.0.7 works for me, so try that if you don't need any 3.5-specific features.

I had similar problem, resolved by using $p1->SetStyle('solid') AFTER adding the lineplot to the graph:
$p1 = new LinePlot($min_values);
$graph->Add($p1);
$p1->SetWeight(3);
$p1->SetColor("blue");
$p1->SetLegend("Minimum Values");
$p1->SetStyle("solid");
Here's a related link, validating Sean's recommendation to place the SetWeight and SetColor method calls AFTER calling the Add lineplot method.

The issue for me here is that my registered JpGraph version 3.5.0b1 does not seem to work at all concerning the line weight and also for other display switches.
After downgrading to version 3.1.7p, everything worked fine independent of any anti-aliasing switches or the positioning of SetWeight after Add().
Thus, at the very moment, I can only recommend downgrading to a non-3.5.0b1 version.

Related

Why is this use of count() not valid in php?

There are a bunch of questions relating to errors with the count() logic in some phpmyadmin libraries but they all seem slightly different to this one.
I'm at a bit of a loss with this strange behavior in the 'Designer' tab. I'm informed that 'errors have been detected on the server!' and that I should 'look at the bottom of this window', but as you can see from the image there is nothing in the console and the error message is obscured:
After getting this popup every time I opened the Designer tab, I decided to track it down:
... and looking at the line in question, #405, in /usr/share/phpmyadmin/libraries/pmd_common.php, I found:
if (count($min_page_no[0])) {
... but isn't this a perfectly legal use of the count() function?
This is in a library file so how can I debug this? - I tried to var_dump($min_page_no[0]); and reload the page to see what I'm dealing with, but nothing was displayed.
Update your installation of phpMyAdmin.
I believe 4.7.8 addresses this, as evidenced by the release tag on this commit:
https://github.com/phpmyadmin/phpmyadmin/commit/c77cfa7d13370a7f1e3236c5896f89981e61406f
[Edit: And an explanation of why count isn't valid in this case: That particular index isn't always set. If they try to use count() on an array index that isn't set, it'll throw that warning.]

My php code is keep getting disable in wordpress editor after upgraded into latest version

My website had a older version of wordpress. Recently I upgraded it to the latest version. After that my php code what I write in the editor is keep getting disabled.
The old page which has php code in ti still works. Although in the editor the php codes are disabled. But if I try to save that it stops working. So i cannot update those page. And also I cannot create new page with php code in it
Exec-PHP plugin is installed.
If I write
<?php echo $c; ?>
It converts into
<!--?php echo $c; ?-->
How to fix that
attached image for better understanding.
Another way, which I don't quite recommend, is to follow this direction:
https://wordpress.org/support/topic/exec-php-to-work-in-php-7-needs-this/
This is basically updating the actual plugin, which will surely be overwritten by their next update.
This plugin requires a number of changes to work with php 7.
In exec-php.php
$GLOBALS[‘g_execphp_manager’] =& new ExecPhp_Manager();
must be changed to
$GLOBALS[‘g_execphp_manager’] = new ExecPhp_Manager();
In includes/manager.php from line 36
change each =& to =
In includes/admin.php lines 53,56,57,63,64,79 change =& to =
In includes/cache.php line 22,39 change =& to =
In includes/ajax.php line 64 change =& to =
I don't know about the plugin you use for this. However, I use xyzscripts for the same cause. It creates short-codes for me to use.
Here is an example:
Create your PHP code and get a Tracking Name.
You will then get your short-code as below, note the Tracking Name.
I personally think this is the best way as it allows re-usability and centralized location to update all your scripts.
XYZ WP PHP Code Download and Documentation
Thank you all for responding.
Apparently I find the solution by installing the Classic Editor plugin
https://en-gb.wordpress.org/plugins/classic-editor/
It prevents disabling the php code.
If you are facing similar problem you can try this one

CKFinder 3 upgrade difficulty

I'm following the CKFinder 2 to 3 upgrade guide and it's not making much sense. In CKFinder 2, the PHP code provided could be used to generate the JS snippet with appropriate config and params, like this:
require_once 'ckfinder/core/ckfinder_php5.php';
$finder = new CKFinder() ;
$finder->SelectFunction = 'ShowFileInfo' ;
$finder->DisableThumbnailSelection = true;
$finder->RememberLastFolder = true;
$finder->Id = $name;
$finder->StartupFolderExpanded = true;
$finder->Width = $width;
$finder->Height = $height;
echo $finder->CreateHtml();
This code picks up the config and incorporates it into the generated JS.
In 3 this seems to have disappeared entirely - the upgrade guide describes the changes needed in config.php, but there is no indication of how this is ever used since there is no other PHP involved, and it says
It is no longer possible to enable CKFinder on a page from the PHP level
All that is shown is how to create the JS snippet, which does not contain any config, and so will use incorrect settings. There is no indication of how the config properties set in config.php ever get to the JS code - as far as I can see there is no connection at all and no mention of any other PHP files, even though some are provided but not documented.
This makes no sense - PHP can quite happily generate HTML and JS that is run on the page, which is all the old CreateHTML function did. I don't understand why there is no mention of this mechanism since it was how we were supposed to use CKFinder previously - it's as if the migration guide is for some unrelated package!
If I update the config file and use the default JS widget code as suggested, it breaks the page completely, altering the MIME output type so it does not get rendered as HTML and appends this error:
{"error":{"number":10,"message":"Invalid command."}}
The docs cover various fine details of what PHP config settings mean, but nowhere that I've found says how it's ever loaded, triggered or associated with the JS. How is this supposed to work?
Indeed the CKFinder 3 documentation was lacking some important information. We're gradually adding new articles there. Based on topics you mentioned I just added:
Explanation how PHP code that worked for CKFinder 2 can be refactored to plain JavaScript in CKFinder 3. Should look familiar ;)
A table with Configuration Options Migration - JavaScript Settings which should help you with discovering again options like rememberLastFolder

How to access result set in phpDataMapper?

I started learning this very nice PHP ORM api last week: http://phpdatamapper.com/
and have been trying to get up to speed with it
What I'm not seeing in the site documentation, is how to iterate with "$postMapper->all()"?
http://phpdatamapper.com/documentation/usage/finders/
When I try to iterate through the value returned from ->all(), it seems only to have gotten the last element in the table.
Here's the code I have:
// $postMapper uses phpDataMapper framework. It works to create the schema & insert values
$postEntities = $postMapper->all();
$postEntities->execute(); // tried adding this to help things
foreach ( $postEntities as $postEntity);
{
echo $postEntity->title;
echo "<br/>";
}
I see other folks are forking it from GitHub and using it in their projects, so I believe I'm making some mistake in my call logic.
It would be great if someone could share a small example of how to access the query data correctly when using mapper->all()? This is an important part of a PHP stack and I would very much like to be able to use this particular solution in my projects going forward. Thanks
Ok, this turned out to be a "not so smart" mistake on my part. The font in my IDE was too small I guess, and I didn't see the ';' at the end of the line that declares the for loop.
So the ORM is all good, just my code wasn't. I'm updating this in case someone else can learn from my mistake - other option is to just delete the post all together (... not sure which is better)

NetBeans-Xdebug works, but won't expose some PHP variables

UPDATE -- working on getting WAMP with phpDeveloper/Xdebug going. I still want NetBeans -- I just want to compare, see if I get some insights.
I am using NetBeans 6.9 with LAMP and Xdebug to work on PHP code. The Variables display works well, but lately it works less well. For example below, $authorized should be visible in the variables pane below the code and should expose its value. But it doesn't show, nor its value, and mousing over the code doesn't help. (The $this object is showing and it does go on and on, but $authorized isn't in there, and it wouldn't make sense if it were.)
This behavior is consistent. Maybe it's a function of the complexity of the code? Or rampant object usage? it seems to have started when I took up CodeIgniter.
Of course the variables are hidden when I need them most ... or so it seems to the poor human. What am I missing?
NetBeans debugger http://themanthursday.com/wiki/Debugger_Display.png
There's a better example below. When I'm stepping through this code, Variables displays only Superglobals and $this, just as in the picture. I can't see any values, even mere strings.
(Nagging thought: I bet the $CI SuperObject has something to do with all this ...)
class Product_documents {
function getProductImage_all($id)
//Return an array of all documents for this product
{
$imgPath = $this->_getProductImage_folder($id);
$arrayPossibleFilenames = $this->_getProductImage_possible_files($id);
foreach ($arrayPossibleFilenames as $imgFile) {
$imgPathFull = $imgPath.$imgFile;
$file_exists = get_file_info($imgPathFull);
if ($file_exists)
{
$arrayFilesPresent[] = $imgPathFull;
}
}
return $arrayFilesPresent;
}
}
Right click on the variable pane. Select "Filters". You will find the secret.
Came across this site that has a very nice link to an Xdebug page that walks one through the process of upgrading Xdebug by compiling a 'more latest' version:
http://icephoenix.us/php/xdebug-doesnt-show-local-variables-in-komodo-netbeans-or-eclipse-pdt/
Variables inside by objects/classes are showing up again! Yeah!
No watches, no 'this may make Xdebug freak out' messages - just good ol' variables that now fully expose the failure of my solution... (haha).
David
I've seen stuff like this before in Netbeans. I expect it's just a bug involving Netbean's interaction with XDebug. One possible workaround that I've seen before is adding a "Watch" for the variable that you can't see. For your example, you could go to the "Watches" tab and type in $authorized. It should show up once it has been set.
I think it comes down to the singleton pattern that is implemented in CodeIgniter as "Super Object". I never have restarted this project to test Kamal's idea. Shortly after he posted, I concluded the singleton was the reason (I did not try to guess whether Kamal has the solution or not). Thus my response to this post.
(2015) In php.ini under [xdebug], set xdebug.show_local_vars=1 if you want all the local variables in debug mode.
Try initializing $authorized to bool false.
I've seen Netbeans not show me variables initialized with a return value from a function without a doctype, but it's hit or miss enough to not be make a pattern out of.

Categories