gap in Pie Chart

77 views
Skip to first unread message

Serge Skorodinsky

unread,
Jun 8, 2022, 3:08:11 PM6/8/22
to JpGraph
Why my Pie chart does have such gap?
PieChart_withGap.png
My code to reproduce the problem is here:
--------------
$Data = array ( 5, 8, 7, 7); //other dataset may not show such gaps
$Legend = array ( 'first', 'second', 'third', 'fourth');
$Colors =  array('red','green', 'blue', 'darkgreen');  

// Create the Pie Graph.
$graph = new PieGraph(500, 280);
$graph->SetShadow(); 
$graph->ClearTheme();

// Set A title for the plot
$graph->title->Set("Just a title");
$graph->title->SetFont(FF_FONT1,FS_BOLD);


// Create
$p1 = new PiePlot($Data);
//legend
$p1->SetLegends($Legend);  
$p1->SetCenter(0.32 );

$graph->Add($p1);

$p1->ShowBorder();
$p1->SetColor('black');
$p1->SetSliceColors($Colors);  //OR per theme

$graph->Stroke('myimage.png');
echo "<img  src=myimage.png alt='It is chart.'/>  <BR><BR>\n";
------------------ 

w1djm...@gmail.com

unread,
Jun 8, 2022, 3:19:39 PM6/8/22
to JpGraph
What version of JPGraph and PHP are you using? With the latest of both (4.4.0 and 8.1.6) there are no gaps.
listgraphtest.php.png

w1djm...@gmail.com

unread,
Jun 8, 2022, 3:24:27 PM6/8/22
to JpGraph
It's worth noting that the values in the sample with the gap add up to 99.9 so the gap is likely 0.1 % that would be required to get to 100%. Double check your values and make sure they add up to 100%.

On Wednesday, June 8, 2022 at 3:08:11 PM UTC-4 serg...@gmail.com wrote:

Serge Skorodinsky

unread,
Jun 9, 2022, 10:46:02 AM6/9/22
to JpGraph
jpGraph latest is ver4.4.1.
jpGraph v4.4.1 and php V5.6.40 - there is a gap. But on 4.4.1 and 7.2.29 - there is no gap... 
Seems like time to update php... Thank you.

Serge Skorodinsky

unread,
Jun 9, 2022, 10:49:17 AM6/9/22
to JpGraph

You wrote: " t's worth noting that the values in the sample with the gap add up to 99.9 so the gap is likely 0.1 % that would be required to get to 100%. Double check your values and make sure they add up to 100%.
"

Sorry, did not really get it. What do you mean? What to double check?

Claude Deslandes

unread,
Jun 10, 2022, 12:07:32 AM6/10/22
to JpGraph
Good day,

   That a look at SetLabelType(PIE_VALUE_ADJPER) as described in https://jpgraph.net/download/manuals/classref/PiePlot.html in the SetLabelType section!!

    Description:
Specify if the value displayed by each slice (if the $pieplot->value->Show()) have been called shold be absolute or in percent.

The following values are allowed arguments:

  • PIE_VALUE_ABS
  • PIE_VALUE_PER
  • PIE_VALUE_ADJPER. This is a special case of the percentage. Specifying this value will adjust integer percetage values so that the total sum will always be 100%. This is done with the the Hare/Niemeyer method. This makes most sense when used together with a format string for labels of "%d" so it will only display a whole integer value without any deciamals.
The defauklt is to show percent. 

Claude :-)


w1djm...@gmail.com

unread,
Jun 10, 2022, 8:12:56 AM6/10/22
to JpGraph
Your percentages do not add up to 100 which is why there is a gap.
Reply all
Reply to author
Forward
0 new messages