How to fix overlapping bars in multiple series bar chart of pChart?

April 02, 2019, at 1:30 PM

I'm using c-pChart library to draw charts, and generating some PDF files using mPDF library. I have to draw a multiple series bar chart. I did same as the example given in pChart website. But my bars are overlapping to each other.

I have searched through all the documentations of pChart as well as StackOverflow. But I couldn't find any resource that had this issue. The c-pChart I'm using is the latest version of pChart which is 2.1.4. I'm using PHP 7. Please refer to this git repo for c-pChart reference.

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);
$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
//"InnerTickWidth" => 20,
//"OuterTickWidth" => 20,
$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));

This is my code that produce an image file with bar chart drawn in it. The file name is "Test.png".

Can anyone help me draw bar chart without overlapping each others? I need to draw the bar chart without overlapping, and include it in PDF. Please refer to the link below for the current output from my code.


Rent Charter Buses Company
DB automatically replace the content in Wordpress

DB automatically replace the content in Wordpress

I'm using the dotted theme in WordpressI need to change the content in topbar, I cant change it through admin, because there is no option to change in topbar settings

PHP is_numeric vs ~(~(float)$value) performance and function

PHP is_numeric vs ~(~(float)$value) performance and function

Recently I wanted to search an array for numeric values (ints, doubles, and numbers with exponent notation) as quickly as possible

Problems with 'woocommerce_login_redirect' filter hook

Problems with 'woocommerce_login_redirect' filter hook

I'm having problems using the 'woocommerce_login_redirect' filter hookI want the user to be redirected to the front page on login, except for when logging in on the checkout page

Laravel backup error uploading large backup to s3

Laravel backup error uploading large backup to s3

I have a Laravel project that creates a new backup daily using spatie/laravel-backup and uploads it to s3It is properly configured, and it has been working for over a year without a problem