SourceForge has been redesigned. Learn more.
Close

#4 Apha Support

open
nobody
None
5
2004-01-11
2004-01-11
Anonymous
No

I believe that you should include alpha support (mainly
just in chart background area).

I have edited my code to include this feature.

Edited files:

panachart.php
- added define("TRANSPARENCY", 1);
- added field to end of function chart .. added $trans =
0
- edited $this->m_backgroundColor = imagecolorallocate
($this->m_image, $vBackColor[0], $vBackColor[1],
$vBackColor[2]); and replaced it with if ($trans == 1) {
$this->m_backgroundColor
= imagecolorallocatealpha ($this->m_image, $vBackColor
[0], $vBackColor[1], $vBackColor[2], 127);
} else {
$this->m_backgroundColor
= imagecolorallocate ($this->m_image, $vBackColor[0],
$vBackColor[1], $vBackColor[2]);
}

here is the complete code:

<?php
/*
PanaChart - PHP Chart Generator - October 2003

Copyright (C) 2003 Eugen Fernea -
eugenf@panacode.com
Panacode Software - info@panacode.com
http://www.panacode.com/

This program is free software; you can redistribute it
and/or
modify it under the terms of the GNU General Public
License
as published by the Free Software Foundation;

This program is distributed in the hope that it will be
useful,
but WITHOUT ANY WARRANTY; without even the
implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General
Public License
along with this program; if not, write to the Free
Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/

define('HORIZONTAL', 0);
define('VERTICAL', 1);

define('SOLID', 0);
define('DASHED', 1);
define('DOTTED', 2);
define('MEDIUM_SOLID', 3);
define('MEDIUM_DASHED', 4);
define('MEDIUM_DOTTED', 5);
define('LARGE_SOLID', 6);
define('LARGE_DASHED', 7);
define('LARGE_DOTTED', 8);
define('TRANSPARENT', 2);

class series{
var $m_values, $m_seriesTitle, $m_strokeColor,
$m_fillColor;
var $m_chart, $m_type;

function series\(&$chart, $chartType, &$values,

$title, $style, $strokeColor, $fillColor){
$this->m_chart = &$chart;
$this->m_type = $chartType;
$this->m_style = (int)$style;
$this->m_seriesTitle = $title;
$this->m_values = &$values;
$vStrokeColor = _decode_color
($strokeColor);
$vFillColor= _decode_color($fillColor);

    $this-&gt;m\_strokeColor =

imagecolorallocate ($this->m_chart->m_image,
$vStrokeColor[0], $vStrokeColor[1], $vStrokeColor[2]);
$this->m_fillColor =
imagecolorallocate ($this->m_chart->m_image, $vFillColor
[0], $vFillColor[1], $vFillColor[2]);
}
}

class chart{
var $m_title, $m_width, $m_height;
var $m_strokeColor, $m_backgroundColor,
$m_fillColor, $m_fontColor, $m_fontWidth, $m_fontHeight;
var $m_maxFontWidth, $m_maxFontHeight;
var $m_minValue, $m_maxValue;
var $m_minCount, $m_maxCount;
var $m_image, $m_series;
var $m_labels, $m_labelsTextColor,
$m_labelsFont, $m_labelsFontWidth ,
$m_labelsFontHeight, $m_labelsDirection;
var $m_gridHColor, $m_gridVColor,
$m_showHGrid, $m_showVGrid;
var $m_numberOfDecimals,
$m_thousandsSeparator, $m_decimalSeparator;
var $m_style;
// Chart constructor
function chart($width, $height, $margin,
$backgroundColor, $trans = 1){
$this->m_title = "";
$this->m_width = $width;
$this->m_height = $height;
$this->m_image = imagecreate ($this-
>m_width, $this->m_height);
$this->m_margin = $margin;
$vBackColor = _decode_color
($backgroundColor);
if ($trans == 2) {
$this->m_backgroundColor
= imagecolorallocatealpha ($this->m_image, $vBackColor
[0], $vBackColor[1], $vBackColor[2], 127);
} else {
$this->m_backgroundColor
= imagecolorallocate ($this->m_image, $vBackColor[0],
$vBackColor[1], $vBackColor[2]);
}

    $this-&gt;m\_minValue = false;
    $this-&gt;m\_maxValue = 0;
    $this-&gt;m\_style = SOLID;
    $this-&gt;m\_strokeColor = $this-

>m_backgroundColor;
$this->m_fillColor = $this-
>m_backgroundColor;

    $this-&gt;m\_showHGrid = false;
    $this-&gt;$m\_showVGrid = false;

    $this-&gt;m\_numberOfDecimals = 0;
    $this-&gt;m\_thousandsSeparator = ',';
    $this-&gt;m\_decimalSeparator = '.';
\}

[the rest is the same]

Thanks.

Discussion


Log in to post a comment.