如何在pChart的多个系列条形图中修复重叠的条形?

时间:2019-04-01 09:34:30

标签: php pchart

我正在使用c-pChart库绘制图表,并使用mPDF库生成一些PDF文件。我必须绘制多个系列的条形图。我做了与pChart网站中给出的示例相同的操作。但是我的酒吧互相重叠。

我搜索了pChart的所有文档以及StackOverflow。但是我找不到任何存在此问题的资源。我使用的c-pChart是pChart的最新版本,即2.1.4。我使用的是PHP7。请参阅此git repo以获取c-pChart参考。 https://github.com/szymach/c-pchart

require_once __DIR__ . '/libPDF/vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use CpChart\Chart\Pie;
use CpChart\Data;
use CpChart\Image;


$MyData = new Data();
$MyData->addPoints(array(1,2,16,12,8,3),"Probe 1");
$MyData->addPoints(array(3,12,15,8,5,-5),"Probe 2");
$MyData->addPoints(array(2,0,5,18,19,22),"Probe 3");

$MyData->setSerieTicks("Probe 2",4);
$MyData->addPoints(array("Jan","Feb","Mar","Apr","May","Jun"),"Labels");
$MyData->setSerieDescription("Labels","Months");
$MyData->setAbscissa("Labels");

$MyData->setAxisName(0,"Temperatures");

$myPicture = new Image(1000, 500, $MyData);
$myPicture->drawRectangle(0, 0, 999, 499, ["R" => 0, "G" => 0, "B" => 0]);

$scaleSettings = [
"XMargin" => 10,
"YMargin" => 10,
"Floating" => TRUE,
"GridR" => 200,
"GridG" => 200,
"GridB" => 200,
"DrawSubTicks" => TRUE,
"CycleBackground" => TRUE,
"LabelRotation" => 20,
//"GridTicks" => 50
//"Pos" => SCALE_POS_TOPBOTTOM
//"InnerTickWidth" => 20,
//"OuterTickWidth" => 20,
"Mode"=>SCALE_MODE_FLOATING 
];

$myPicture->setGraphArea(90,60,920,420);
$myPicture->drawScale($scaleSettings);
$myPicture->setFontProperties(["FontName" => "pf_arma_five.ttf", 
  "FontSize" => 11]);
$myPicture -> drawBarChart(array("DisplayOrientation"=>ORIENTATION_AUTO,"DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"Rounded"=>TRUE,"Surrounding"=>60,"Interleave"=>3));

$myPicture -> drawLegend(490,40,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->Render("Test.png");

这是我的代码,它生成带有条形图的图像文件。文件名为“ Test.png”。

谁能帮助我绘制条形图而不互相重叠?我需要绘制不重叠的条形图,并将其包含在PDF中。请从下面的链接获取我的代码的当前输出。

https://www.dropbox.com/s/alqy4zsz70k1nqv/emobarTest.png?dl=0

0 个答案:

没有答案