[42] | 1 | <?php
|
---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
---|
| 3 | require_once ('jpgraph/jpgraph_matrix.php');
|
---|
| 4 | require_once ('jpgraph/jpgraph_iconplot.php');
|
---|
| 5 |
|
---|
| 6 | $data = array(
|
---|
| 7 | array(0,1,2,3,4,5,6,7,8,9,10),
|
---|
| 8 | array(10,9,8,7,6,5,4,3,2,1,0),
|
---|
| 9 | array(0,1,2,3,4,5,6,7,8,9,10),
|
---|
| 10 | array(10,9,8,17,6,5,4,3,2,1,0),
|
---|
| 11 | array(0,1,2,3,4,4,9,7,8,9,10),
|
---|
| 12 | array(8,1,2,3,4,8,3,7,8,9,10),
|
---|
| 13 | array(10,3,5,7,6,5,4,3,12,1,0),
|
---|
| 14 | array(10,9,8,7,6,5,4,3,2,1,0),
|
---|
| 15 | );
|
---|
| 16 |
|
---|
| 17 | $nrow = count($data); $ncol = count($data[0]);
|
---|
| 18 |
|
---|
| 19 | $width=350; $height=300;
|
---|
| 20 | $graph = new MatrixGraph($width,$height);
|
---|
| 21 | $graph->title->Set('Add ine row/col labels');
|
---|
| 22 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
|
---|
| 23 |
|
---|
| 24 | $mp = new MatrixPlot($data,1);
|
---|
| 25 | $mp->SetSize(0.55);
|
---|
| 26 | $mp->SetCenterPos(0.45, 0.45);
|
---|
| 27 |
|
---|
| 28 | $rowtitles = array();
|
---|
| 29 | for( $i=0; $i < $nrow; ++$i ) {
|
---|
| 30 | $rowtitles[$i] = sprintf('Row: %02d',$i);
|
---|
| 31 | }
|
---|
| 32 | $coltitles = array();
|
---|
| 33 | for( $i=0; $i < $ncol; ++$i ) {
|
---|
| 34 | $coltitles[$i] = sprintf('Col: %02d',$i);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | $mp->rowlabel->Set($rowtitles);
|
---|
| 38 | $mp->rowlabel->SetFont(FF_ARIAL,FS_NORMAL,10);
|
---|
| 39 | $mp->rowlabel->SetFontColor('blue');
|
---|
| 40 | $mp->rowlabel->SetSide('left');
|
---|
| 41 |
|
---|
| 42 | $mp->collabel->Set($coltitles);
|
---|
| 43 | $mp->collabel->SetFont(FF_ARIAL,FS_NORMAL,10);
|
---|
| 44 | $mp->collabel->SetFontColor('darkred');
|
---|
| 45 | $mp->collabel->SetAngle(70); // 90 is default for col titles
|
---|
| 46 | $mp->collabel->SetSide('bottom');
|
---|
| 47 |
|
---|
| 48 | $graph->Add($mp);
|
---|
| 49 | $graph->Stroke();
|
---|
| 50 |
|
---|
| 51 | ?>
|
---|