|
help with DB and the chart |
Posted by carlos villanueva on May-19-2011 22:14 |
|
I am doing a test of speed.
Everything is fine, but I don?t know how to adapt the pchart with DB. This is what I have done, but it does?t load the results.
I put a sql, the programs and a PDF (graphic) of what I get.
Thanks for you help
|
Re: help with DB and the chart |
Posted by Peter Kwan on May-20-2011 01:23 |
|
Hi carlos,
I think your chart accurately reflects your data.
The two issues I found in your chart is:
(a) There is not enough space on the left side for the y-axis labels.
(b) The x-axis labels overlap, because they are too long.
It seems your x-axis labels can be very long, so you need to reserve a lot of space on the x-axis for the labels. I suggest you to configure the x-axis labels to run vertically.
May be you can try the following code. I have made the left side wider at 100 pixels for the y-axis labels, and have reserve a lot of space at the bottom for the x-axis labels. Also, I have rotated the x-axis labels by 90 degrees, so it runs vertically.
# Create a XYChart object of size 640 x 600 pixels
$c = new XYChart(640, 600);
# Add a title to the chart using 18pts Times Bold Italic font
$c->addTitle("VELOCIDAD", "timesbi.ttf", 18);
# Set the plotarea at (100, 40) and of size 500 x 280 pixels. Use a vertical gradient
# color from light blue (eeeeff) to deep blue (0000cc) as background. Set border and
# grid lines to white (ffffff).
$c->setPlotArea(100, 40, 500, 280, $c->linearGradientColor(60, 40, 60, 280, 0xeeeeff,
0x0000cc), -1, 0xffffff, 0xffffff);
# Add a multi-color bar chart layer using the supplied data. Use soft lighting effect
# with light direction from left.
$barLayerObj = $c->addBarLayer3($data);
$barLayerObj->setBorderColor(Transparent, softLighting(Left));
# Set x axis labels using the given labels
$c->xAxis->setLabels($labels);
# Draw the ticks between label positions (instead of at label positions)
$c->xAxis->setTickOffset(0.5);
# Add a title to the y axis with 10pts Arial Bold font
$c->yAxis->setTitle("Euros", "arialbd.ttf", 10);
# Set axis label style to 8pts Arial Bold
$c->xAxis->setLabelStyle("arialbd.ttf", 8, 0x000000, 90);
$c->yAxis->setLabelStyle("arialbd.ttf", 8);
# Set axis line width to 2 pixels
$c->xAxis->setWidth(2);
$c->yAxis->setWidth(2);
# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
Hope this can help.
Regards
Peter Kwan |
Re: help with DB and the chart |
Posted by carlosv56 on May-20-2011 15:07 |
|
I tried again. And it works
Thanks |
Re: help with DB and the chart |
Posted by carlos villanueva on May-21-2011 00:27 |
|
In my work it goes
But at home don?t. Please see the attachment.
Something I don?t understand.
Could you help me
Thanks
|
Re: help with DB and the chart |
Posted by Peter Kwan on May-21-2011 03:15 |
|
Hi Carlos,
I am not sure which part is incorrect in your chart. Both of your charts look normal.
In your "house.pdf", the first 2 bars are zero, and all the other bars are close to -0.000013. Does this reflect your real data? If this reflects your real data, then the chart is normal.
In your "img1.pdf", there are 5 bars, all close to -0.000013. The five bars look different in length, because your y-axis are from -0.0000130587315 to -0.0000130587365. On your "house.pdf", the y-axis starts from 0 to -0.000016, so all the bars that are close to -0.000013 appears the same length. The "house.pdf" must start the y-axis at 0, because you have two bars that are 0 (the first two bars). If you do not want the first two bars, please remove them before passing the data to ChartDirector.
Hope this can help.
Regards
Peter Kwan |
Re: help with DB and the chart |
Posted by carlos villanueva on May-21-2011 14:19 |
|
yes. Is so little the difference that is difficult to see.
Thanks for your help. Blessings |
|