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

Message ListMessage List     Post MessagePost Message

  Bubbles Size Issue
Posted by Rick on Feb-22-2012 10:05
Hi Peter,

Sometimes when charting Bubble Charts, the Bubbles are too Big o too Small depending on the values of Y axis, X Axis and the Z values used (for example when mixing thousand values with percentages values). I know this is normal because the values passed to the chart.

# The XYZ points for the bubble chart
$dataX0 = array(1700, 3000, 1000, 17000);
$dataY0 = array(160, 690, 160, 750);
$dataZ0 = array(0.52, 0.105, 0.88, 0.140);

$dataX1 = array(0.500, 0.1000, 0.1300);
$dataY1 = array(40, 58, 85);
$dataZ1 = array(140, 202, 840);

$dataX2 = array(170, 300, 100, 170);
$dataY2 = array(16000, 6900, 1600, 7500);
$dataZ2 = array(52, 105, 88, 140);

$LayObj = $c->addScatterLayer($dataX0, $dataY0, "A",   GlassSphere2Shape, 15, 0xff3333);
$LayObj->setSymbolScale($dataZ0);

$LayObj = $c->addScatterLayer($dataX1, $dataY1, "B",   GlassSphere2Shape, 15, 0x0000ff);
$LayObj->setSymbolScale($dataZ1);


Is there any way to always have a Bubbles correctly showed in the chart according to the Z values?

I use to multiply or divide the Z values depending on the X/Y values but is not always work as I expect. Is there a better way to do this?

  Re: Bubbles Size Issue
Posted by Peter Kwan on Feb-23-2012 02:01
Hi Rick,

I believe by default, in a bubble chart, the z values are in pixel units (unless your code explicitly used the XAxisScale or YAxisScale constant to change it to x or y axis units). So z=140 means the bubble is 140 pixels in diameter. It does not matter what are the values in the x or y axis or what are your x and y data values.

So in your case, regardless of what are the (x, y) values, you can just set the z value to a reasonable ratio of your plot area size in pixels. For example, if your plot area size is 600 x 400 pixels, and you would like to largest bubble to be around 20% of the width or height (whichever is smaller) of the plot area, then you can scale your z value so that the largest value is 80.

For example:

$scaleFactor = 80.0 / max($dataZ);
for ($i = 0; $i < count($dataZ); ++$i) $dataZ[i] = $dataZ[i] * $scaleFactor;

Hope this can help.

Regards
Peter Kwan

  Re: Bubbles Size Issue
Posted by Rick on Feb-23-2012 03:18
Thanks Peter