View unanswered posts | View active topics It is currently Thu Mar 28, 2024 11:23 pm



Reply to topic  [ 1 post ] 
Weird bug with 2 bar charts 
Author Message
pChart user
pChart user

Joined: Mon Jan 30, 2012 2:23 pm
Posts: 5
Post Weird bug with 2 bar charts
I've stumbled upon a weird bug where only the first bar is drawn, second one the scale is drawn but not the bar.
Print only either one works, swapping their sequence also reproduce the same bug.

Not sure if this is relevant, dumping the $data->getData() shows differences in the Axis[1], technically they should be same.

Second bug is setSerieDrawable() not working in this case also. Hence replaced with removeSerie() since both data are independent.

pChart version: 2.1.3

Here are the simplified version to reproduce the bug.
Code:
<?php
  /* pChart library inclusions */
  include("../class/pData.class.php");
  include("../class/pDraw.class.php");
  include("../class/pImage.class.php");

  $data = new pData();

  $picture = new pImage(800, 550, $data);
  $picture->setShadow(TRUE,array('X'=>1, 'Y'=>1, 'R'=>0, 'G'=>0, 'B'=>0, 'Alpha'=>10));
  $picture->Antialias = TRUE;
  $picture->setFontProperties(array('FontName' => '../fonts/GeosansLight.ttf', 'FontSize' => 14, 'R' => 80, 'G' => 80, 'B' => 80));

  $data->setAxisPosition(0, AXIS_POSITION_RIGHT);
  $data->setAxisUnit(0, '%');

  $ScaleSettings  = array(
    'Mode' => SCALE_MODE_MANUAL,
    'ManualScale' => array(
      0 => array('Min' => 0, 'Max' => 100),
      1 => array('Min' => 0, 'Max' => 100),
    ),
    'RemoveXAxis' => TRUE,
    'DrawXLines' => FALSE,
  );
  $settings = array(
    'Gradient' => TRUE,
    'GradientMode' => GRADIENT_SIMPLE,
    'DisplayPos' => LABEL_POS_INSIDE,
    'DisplayValues' => TRUE,
    'DisplayR' => 255,
    'DisplayG' => 255,
    'DisplayB' => 255,
    'DisplayShadow' => TRUE,
  );

  /* ----- Data1 ----- */
  $data->addPoints(array(62), 'Data1');
  $data->setAxisName(0, 'Data1');

  $ScaleSettings['ManualScale'] = array(
    0 => array('Min' => 0, 'Max' => 100),
    1 => array('Min' => 0, 'Max' => 100),
  );
  $settings['OverrideColors'] = array(0 => array('R'=>224, 'G'=>100, 'B'=>46, 'Alpha'=>100));

  $picture->setGraphArea(550, 130, 650, 310);
  $picture->drawScale($ScaleSettings);
  $picture->drawBarChart($settings);
//var_dump($data->getData());

  // /* ----- Data2 ----- */
  $data->removeSerie('Data1');
  $data->addPoints(array(-48), 'Data2');
  $data->setAxisName(0, 'Data2');
  $data->setAxisDisplay(0, AXIS_FORMAT_CUSTOM, 'YAxisFormat');

  $ScaleSettings['ManualScale'] = array(
    0 => array('Min' => -100, 'Max' => 0),
    1 => array('Min' => 0, 'Max' => 100),
  );
  $settings['OverrideColors'] = array(0 => array('R'=>46, 'G'=>151, 'B'=>224, 'Alpha'=>100));

  $picture->setGraphArea(550, 310, 650, 490);
  $picture->drawScale($ScaleSettings);
  $picture->drawBarChart($settings);
//var_dump($data->getData());

  $picture->autoOutput("pictures/example.my.png");

function YAxisFormat($value) {
  return(abs($value) . '%');
}
?>


Tue Jan 31, 2012 4:02 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron