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

Message ListMessage List     Post MessagePost Message

  Bubble Chart - addExtraField - PHP
Posted by Jorge Eduardo on Dec-07-2015 02:22
Attachments:
Hi Peter,  I know there is a ton of questions about the addExtraField to put data over a
chart.  However I can't find any issue in my code which is not rendering the desired labels
over my bubble chart.

This is my php bubble chart script:

# Create a XYChart WxH
$c = new XYChart(500, 350, Transparent);

# Set the plotarea at (30-x, 20-y) and of size 200-x X 200-y pixels
$c->setPlotArea(120,30, 350, 270, 0xffffff, -1, -1, Transparent, Transparent);

# Add a title to the chart using 18pts Times Bold Italic font
$c->addTitle($title, "arialbd.ttf", 12);

# Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this as
# the guideline when putting ticks on the y-axis.
$c->yAxis->setTickDensity(50);
$c->xAxis->setTickDensity(50);

# Set the axes line width to 3 pixels
$c->xAxis->setWidth(3);
$c->yAxis->setWidth(3);
$c->yAxis->setAutoScale(0.1,0.1,0);

# Add titles to the axes using 12pt Arial Bold Italic font
$c->yAxis->setTitle("Ventas (MM)", "arialbi.ttf", 10);
$c->yAxis->setLabelFormat("COP$ {value|0}MM");
$c->yAxis->setLabelStyle("arial.ttf", 10);
$c->xAxis->setTitle("Empleados", "arialbi.ttf", 10);
$c->xAxis->setLabelFormat("{value|0}");
$c->xAxis->setLabelStyle("arial.ttf", 12);

# Add a data-chart layer to the chart
$scatterLayerObj = $c->addScatterLayer($dataX, $dataY, $title, GlassSphere2Shape, 15,
-1 );
# Set the default line width to 2 pixels
$scatterLayerObj->setSymbolScale($dataZ);
$scatterLayerObj->addExtraField($labels);
$scatterLayerObj->setDataLabelFormat("{value}");
$scatterLayerObj->setDataLabelStyle("arial.ttf",12,0xffffff);



# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
Screenshot from 2015-12-06 13_21_26.png

  Re: Bubble Chart - addExtraField - PHP
Posted by Peter Kwan on Dec-07-2015 17:06
Hi Jorge,

In your case, there are two issues:

(a) By default, the labels will be rendered on top of the symbols. In your case, you are
using white labels on a white background, so you may not see the labels. May be you can
try:

#black labels
$scatterLayerObj->setDataLabelStyle("arial.ttf",12,0x000000);

(b) Your code has added an extra field array. However, it has not specified how that array
should be used. The array can be used as data labels, in tooltips, in legend text, etc.. If
you would like to use the array in labels, you can configure the label format to be:

#use the extra field as the label
$scatterLayerObj->setDataLabelFormat("{field0}");

Hope this can help.

Regards
Peter Kwan

  Re: Bubble Chart - addExtraField - PHP
Posted by Jorge Eduardo on Dec-07-2015 22:49
Hi Peter as usual,  your support is awesome,  thanks,  by the way, are any plans of
releasing a javascript version?
Thanks,  have a nice day.

  Re: Bubble Chart - addExtraField - PHP
Posted by Peter Kwan on Dec-09-2015 00:58
Hi Jorge,

I assume you are referring to running Javascript on the browser (as opposed to using
Javascript on the server, which ChartDirector has already supported for over 10 years).

We can considering the option of rendering on the  browser side using Javscript, but it is
not likely to be available in the near term (next few months). ChartDirector can plot large
amount of data points (millions) and many charts in ChartDirector can be rather complicated
(like 3D surface charts), and browser side Javascript may not be powerful enough to handle
them. So even if it is available sometime in the future, it is like to be a trim down version of
ChartDirector.

Regards
Peter Kwan

  Re: Bubble Chart - addExtraField - PHP
Posted by Peter Kwan on Dec-09-2015 00:58
Hi Jorge,

I assume you are referring to running Javascript on the browser (as opposed to using
Javascript on the server, which ChartDirector has already supported for over 10 years).

We can considering the option of rendering on the  browser side using Javscript, but it is
not likely to be available in the near term (next few months). ChartDirector can plot large
amount of data points (millions) and many charts in ChartDirector can be rather complicated
(like 3D surface charts), and browser side Javascript may not be powerful enough to handle
them. So even if it is available sometime in the future, it is likely to be a trim down version
of ChartDirector.

Regards
Peter Kwan