|
How to insert labels and swap y axis |
Posted by JuizyJ on Dec-12-2014 18:05 |
|
Hi,
I am trying to create the labels of red maker on every makers and how to i swap y
axis for set the zero value on the top please see at a picture. I would like to have a
suggestion.
this is my code.
require_once("/var/www/ChartDirector/lib/phpchartdir.php");
$barData = array(40);
$markData = array(12);
$markData2 = array(20);
$markData3 = array(33);
$markData4 = array(2);
$markData5 = array(19);
$markData6 = array(25);
$labels = array("Grp1");
$g1labels = array("SNP10-1");
$c = new XYChart(1024, 768);
$c->setBackground($c->linearGradientColor(0, 0, 0, $c->getHeight() / 2, 0xe8f0f8,
0xaaccff), 0x88aaee);
$c->setRoundedFrame();
$c->setDropShadow();
$title = $c->addTitle("Chromosome with Markers", "ariali.ttf", 15);
$title->setMargin2(0, 0, 12, 12);
$c->setPlotArea(50, $title->getHeight(), $c->getWidth() - 65, $c->getHeight() -
$title->getHeight() - 90, 0xe8f0f8, -1, Transparent, $c->dashLineColor(0x888888,
DotLine));
$legendBox = $c->addLegend($c->getWidth() / 2, $c->getHeight() - 15, false,
"arial.ttf", 8);
$legendBox->setAlignment(BottomCenter);
$legendBox->setBackground(0xe8f0f8, 0x445566);
$legendBox->setRoundedCorners(5);
$legendBox->setLineStyleKey();
$c->xAxis->setColors(Transparent);
$c->yAxis->setColors(Transparent);
$c->xAxis->setLabels($labels);
$markLayer = $c->addBoxWhiskerLayer(null, null, null, null, $markData, -1, 0xff0000);
$markLayer2 = $c->addBoxWhiskerLayer(null, null, null, null, $markData2, -1,
0xff0000);
$markLayer3 = $c->addBoxWhiskerLayer(null, null, null, null, $markData3, -1,
0xff0000);
$markLayer4 = $c->addBoxWhiskerLayer(null, null, null, null, $markData4, -1,
0xff0000);
$markLayer5 = $c->addBoxWhiskerLayer(null, null, null, null, $markData5, -1,
0xff0000);
$markLayer6 = $c->addBoxWhiskerLayer(null, null, null, null, $markData6, -1,
0xff0000);
$markLayer->setLineWidth(2);
$markLayer->setDataGap(0.1);
$markLayer2->setLineWidth(2);
$markLayer2->setDataGap(0.1);
$markLayer3->setLineWidth(2);
$markLayer3->setDataGap(0.1);
$markLayer4->setLineWidth(2);
$markLayer4->setDataGap(0.1);
$markLayer5->setLineWidth(2);
$markLayer5->setDataGap(0.1);
$markLayer6->setLineWidth(2);
$markLayer6->setDataGap(0.1);
$legendBox->addKey("Makers", 0xff0000, 2);
$barLayer = $c->addBarLayer($barData, 0x0066cc, "Chromosomes");
$barLayer->setBorderColor(Transparent, softLighting(Left));
$layoutLegendObj = $c->layoutLegend();
$c->packPlotArea(10, $title->getHeight(), $c->getWidth() - 15,
$layoutLegendObj->getTopY() - 10);
header("Content-type: image/png");
print($c->makeChart2(PNG));
Thank you so much
Juizy
|
Re: How to insert labels and swap y axis |
Posted by Peter Kwan on Dec-13-2014 01:13 |
|
Hi JuizyJ,
May be try:
$t = $markLayer->setDataLabelStyle("arialbd.ttf", 12, 0x000000);
$t->setAlignment(Right);
$t->setPos(0, -12);
$markLayer->setDataLabelFormat("Marker Name");
Hope this can help.
Regards
Peter Kwan |
Re: How to insert labels and swap y axis |
Posted by JuizyJ on Dec-15-2014 10:12 |
|
Peter Kwan wrote:
Hi JuizyJ,
May be try:
$t = $markLayer->setDataLabelStyle("arialbd.ttf", 12, 0x000000);
$t->setAlignment(Right);
$t->setPos(0, -12);
$markLayer->setDataLabelFormat("Marker Name");
Hope this can help.
Regards
Peter Kwan
Hi Peter Kwan,
It's work Thank you so much for help and how to change y axis to be 0 on the top of y
axis?
Thank you so much |
Re: How to insert labels and swap y axis |
Posted by JuizyJ on Dec-15-2014 10:20 |
|
and i would like to set the max value of y axis.
thank you for your kindness. |
Re: How to insert labels and swap y axis |
Posted by JuizyJ on Dec-15-2014 11:12 |
|
I try to use this code
$c->yAxis()->setLinearScale(100, 0, 2);
but y axis disappear. |
Re: How to insert labels and swap y axis |
Posted by Peter Kwan on Dec-15-2014 22:48 |
|
Hi JuizyJ,
You can use Axis.setReverse to have ChartDirector automatically reverse the axis:
$c->yAxis->setReverse();
If you want to configure the axis scale yourself, you should use a negative tick increment
for reversed axis, such as:
$c->yAxis->setLinearScale(60, 40, -2);
Hope this can help.
Regards
Peter Kwan |
Re: How to insert labels and swap y axis |
Posted by JuizyJ on Dec-16-2014 10:11 |
|
Peter Kwan wrote:
Hi JuizyJ,
You can use Axis.setReverse to have ChartDirector automatically reverse the axis:
$c->yAxis->setReverse();
If you want to configure the axis scale yourself, you should use a negative tick increment
for reversed axis, such as:
$c->yAxis->setLinearScale(60, 40, -2);
Hope this can help.
Regards
Peter Kwan
Thank you so much it very helpful cheer! |
|