pChart 2.x forum
http://wiki.pchart.net/forum/

Weird bug with 2 bar charts
http://wiki.pchart.net/forum/viewtopic.php?f=5&t=2338
Page 1 of 1

Author:  ckng [ Tue Jan 31, 2012 4:02 pm ]
Post subject:  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) . '%');
}
?>

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/