SetCenter is not working?

334 views
Skip to first unread message

Arie

unread,
Apr 17, 2013, 10:15:22 AM4/17/13
to jpg...@googlegroups.com
Hello,

Ik heb onderstaande code :

<?php
include
('dbconn.php');

// Het bibliotheek bestand invoegen
require_once
('jpgraph/src/jpgraph.php');
require_once
('jpgraph/src/jpgraph_pie.php');

// A new pie graph
$graph
= new PieGraph(400,150,"auto");
$graph
->SetShadow();

//get data from database
$sql
="SELECT afkomst, COUNT(*) AS 'count' FROM overzicht WHERE DATE(datum) = CURDATE() GROUP BY afkomst";
$result
= mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
 
while ($row = mysql_fetch_assoc($result)) {
      $legends
[] = $row["afkomst"];
      $data
[] = $row["count"];
 
}
}

// Setup the pie plot
$p1
= new PiePlot($data);

// Adjust size and position of plot
$p1
->SetSize(0.4);
$p1
->SetCenter(0.10,0.30);

// Setup slice labels and move them into the plot
$p1
->value->SetFont(FF_ARIAL,FS_NORMAL,11);
$p1
->value->SetColor("darkred");
$p1
->SetLabelPos(0.65);

// Use absolute values (type==1)
$p1
->SetLabelType(PIE_VALUE_ABS);

// Label format
$p1
->value->SetFormat("%d");
$p1
->value->HideZero();
$p1
->value->Show();

// Set legends
$p1
->SetLegends($legends);
$graph
->legend->Pos(-0.00,0.05);
$graph
->legend->SetLayout(LEGEND_VERT);

// Explode all slices
$p1
->ExplodeAll(8);

// Add drop shadow
$p1
->SetShadow();

// Finally add the plot
$graph
->Add($p1);

// ... and stroke it
$graph
->Stroke();

?>

Is doesn't matter what I fill in for SetCenter, the pie still standing in the center of the plot.

All I want is to get the piew a little bit to the left .......... ;-)

Any idea what I'm missing here?

Kind regards,

Arie

Shinichi Goh

unread,
Apr 18, 2013, 1:05:19 AM4/18/13
to jpg...@googlegroups.com
Arie,

According to your code, I run the following sample and it moves a little bit left instead of staying in the center.

<?php
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_pie.php");

$graph = new PieGraph(400,150,"auto");
$graph->SetShadow();

$data = array(45, 23, 18, 32);
$pieplot = new PiePlot($data);
$pieplot->SetSize(0.4);
$pieplot->SetCenter(0.30,0.50);

$graph->Add($pieplot);

$graph->Stroke();
?>

SetCenter(0.3,0.50) 0.5 is in the middle, if you move left you can try 0.3 or 0.2

I hope I have answered your question.

Arie

unread,
Apr 18, 2013, 10:58:53 AM4/18/13
to jpg...@googlegroups.com
Hi Shinichi,

I copy / paste your code in a test file (make one little change, about the location of the libraries) but I got it in the middle of the image. I have changed the values to `(0.1,0.1) and (0.2,0.3) but the pie is still in the middle.

Can it be that this is a browser issue? I test it in Firefox 20.0.1 (as far as I know the latest release)

The test file is here : http://www.pmazorgverzekering.nl/overzicht2/test.php and the pie is in the middle

I have used the code :
<?php
require_once
('jpgraph/src/jpgraph.php');
require_once
('jpgraph/src/jpgraph_pie.php');

$graph
= new PieGraph(400,150,"auto");
$graph
->SetShadow();

$data
= array(45, 23, 18, 32);
$pieplot
= new PiePlot($data);
$pieplot
->SetSize(0.35);
$pieplot
->SetCenter(0.10,0.10);


$graph
->Add($pieplot);

$graph
->Stroke();
?>

Kind regards,

Arie

Shinichi Goh

unread,
Apr 18, 2013, 9:31:21 PM4/18/13
to jpg...@googlegroups.com
Dear Arie

To verify with your question, I have attached the result of your test.php page for you in both browser, Google Chrome and Firefox (both are the latest version as of today 2013/04/19).

* Below is the result from Google Chrome Browser

* Here's the result using Firefox 20.0

* I have tested changing the value to (0.3,0.5) and the result is as following:

According to the result here, the graph moves left to 0.3 position. Could it be your browser problem?

Best Regards,
Shin

Arie

unread,
Apr 19, 2013, 5:52:20 AM4/19/13
to jpg...@googlegroups.com
Hi Shinichi,

This is really getting me crazy ............... ;-)

The first two images of you were a copy of my test.php? In that test I use (0.1,0.1) just to see if something happens. But you don't get it also from the center.

In the last image you have changes it to (0.3,0.5) and it goed to the left as it should be ...............

But I change my code in the test.php in (0.3,0.5) and then it is still in the middle ................ arghhhhhhhhhhh

Here is the code that I use now for the test.php on http://www.pmazorgverzekering.nl/overzicht2/test.php

<?php
require_once
('jpgraph/src/jpgraph.php');
require_once
('jpgraph/src/jpgraph_pie.php');

$graph
= new PieGraph(400,150,"auto");
$graph
->SetShadow();

$data
= array(45, 23, 18, 32);

$pieplot
= new PiePlot($data);
$pieplot
->SetSize(0.35);

$pieplot
->SetCenter(0.3,0.5);


$graph
->Add($pieplot);

$graph
->Stroke();
?>

Do you see on this test.php the pie to the left?

Kind regards,

Arie


Shinichi Goh

unread,
Apr 19, 2013, 6:46:10 AM4/19/13
to jpg...@googlegroups.com
Dear Arie,

Below is the result of your test file in my browser:


Have you tried using the other browser? Could it be possible that your browser still remember old cache? Please try clear the cache of your browser, restart your pc and try again? or if possible, please try with other browser and compare the result.

Regards,
Shin

Arie

unread,
Apr 22, 2013, 11:01:13 AM4/22/13
to jpg...@googlegroups.com
Hi Shinichi,

I have tried it in Firefox, Chrome, Safari and IE9 but all with the same results and I have deleted the caches.

Kind regards,

Arie
Reply all
Reply to author
Forward
0 new messages