ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  LinearZoneMeter Range
Posted by Heppy on Feb-16-2009 18:50
Attachments:
Hi Peter,

Peter I want to ask U about LinearZoneMeter Chart.
Why this chart range is not symetric (LOW and HIGH) ?
Though if us see the value of is same ex : (3521-2521=1000) and (1521 - 521 = 1000). But if value is small this chart is same, for ex : (3000-2000=1000) and (1000-0=1000).


Thanks :)
linearmeter.png
linearmeter1.png

  Re: LinearZoneMeter Range
Posted by Peter Kwan on Feb-17-2009 03:59
Hi Heppy,

I am not sure how you set up the top chart. Would you mind to inform me of your source code?

My guess is that "521" is not a number, but is a text string your code pass to ChartDirector. A text string (like "New York", "Apple", "Horse", "521", "ABC", etc.) has no meaning to ChartDirector, and is just for human reading. So it is possible ChartDirector will put "521" at the start of the meter scale, if your code ask it to do so.

Regards
Peter Kwan

  Re: LinearZoneMeter Range
Posted by Heppy on Feb-17-2009 09:33
Hi Peter,

This script to create linearzonemeter.

Thanks Peter :)



<?php
require_once("../ChartDirectorphp5/lib/phpchartdir.php");

/*
$start   = 0;
$low     = 1000;
$avg     = 2000;
$high    = 3000;
$mybrch  = 1721;
*/

$start   = 521;
$low     = 1521;
$avg     = 2521;
$high    = 3521;
$mybrch  = 1721;

# The value to display on the meter
$value = $mybrch;

# Create an LinearMeter object of size 210 x 45 pixels, using silver background with
# a 2 pixel black 3D depressed border.
//$m = new LinearMeter(210, 45, silverColor(), 0, -2);
$m = new LinearMeter(390, 100, 0xb7b7b7, 0, -2);

# Set the scale region top-left corner at (5, 5), with size of 200 x 20 pixels. The
# scale labels are located on the bottom (implies horizontal meter)
$m->setMeter(15, 5, 350, 40, Bottom);

# Set meter scale from 0 - 100
$m->setScale(0, $high);

# Add a title at the bottom of the meter with a 1 pixel raised 3D border
//$textBoxObj = $m->addTitle2(Bottom, "Branch Comparation", "arialbd.ttf", 8);
$textBoxObj = $m->addTitle2(Bottom, "", "arialbd.ttf", 8);
$textBoxObj->setBackground(Transparent, 0, 1);

# Set 3 zones of different colors to represent Good/Weak/Bad data ranges
$m->addZone($avg, $high, 0x33ff33, "High");
$m->addZone($low, $avg, 0xffff33, "Avg");
$m->addZone(0, $low, 0xff0033, "Low");

# Add empty labels (just need the ticks) at 0/20/50/80 as separators for zones
$m->addLabel(0, $start);
$m->addLabel($low, $low);
$m->addLabel($avg, $avg);
$m->addLabel($high, $high);
//$m->addLabel($value, $value);

# Add a blue (0000cc) pointer at the specified value
$m->addPointer($value, 0x0000cc);

# Add a semi-transparent blue (800000ff) pointer at the specified value, using
# triangular pointer shape
$pointerObj = $m->addPointer($value, 0x800000ff);
//$pointerObj->setShape(TriangularPointer);

# Add a label at bottom-left (10, 68) using Arial Bold/8 pts/red (c00000)
$m->addText(330, 90, "My Branch :", "arialbd.ttf", 8, 0x800000ff, BottomRight);

$textBoxObj = $m->addText(360, 90, $m->formatValue($value, ""), "arial.ttf", 8, 0xffffff, BottomRight);
$textBoxObj->setBackground(0x800000ff, -1, 0);




# output the chart
//header("Content-type: image/png");
//print($m->makeChart2(PNG));
#chart view

$chartURLft = $m->makeSession("chartft");

//$imageMapft = $m->getHTMLImageMap("BranchPNL_detailMTD.php?uid=137", "", "title='region:{xLabel} & kategori:{dataSet} & value:{value|0} & percentage:{percent}%'");

?>
<table align="left"><tr><td><br>
<img src="../ChartDirectorphp5/phpdemo/getchart.php?<?php echo $chartURLft?>" border="0" usemap="#mapft">
<map name="mapft"> <?php echo $imageMapft?></map>
</td></tr></table>

  Re: LinearZoneMeter Range
Posted by Peter Kwan on Feb-17-2009 17:42
Hi Heppy,

In your code, the meter scale is set to 0 - 3521:

$m->setScale(0, $high);

At the position 0, for some reason, your code puts the label 521 there.

$m->addLabel(0, $start);

I am not sure why your code puts the label 521 at the position 0. If you want to put a label at the position 0, I suggest you put the label 0 there.

$m->addLabel(0, 0);

If you want to put a label at the position 521, I suggest you put the label 521 there.

$m->addLabel($start, $start);

If you want the meter scale to be 521 to 3521, please set meter scale to 521 to 3521.

$m->setScale($start, $high);

Hope this can help.

Regards
Peter Kwan