Tag Archives: yaxes

Set X Axes, and Y Axes Properties

You can also set individual x, y axes properties. To set only x axes properties, use set_xaxes() method. Likewise, to set only y axes properties, use set_yaxes().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
$s1 = array(11, 9, 5, 12, 14);
$s2 = array(6, 8, 7, 13, 9);

$pc = new C_PhpChartX(array($s1, $s2),'basic_chart');
$pc->set_animate(true);
$pc->set_title(array('text'=>'Basic Chart'));

$pc->set_series_default(array(
    'renderer'=>'plugin::BarRenderer',
    'rendererOptions'=>array('sliceMargin'=>2,'innerDiameter'=>110,'startAngle'=>-90,'highlightMouseDown'=>true),
    'shadow'=>true
    ));

$pc->add_plugins(array('highlighter', 'canvasTextRenderer'));

//set phpChart grid properties
$pc->set_grid(array(
    'background'=>'lightyellow',
    'borderWidth'=>0,
    'borderColor'=>'#000000',
    'shadow'=>true,
    'shadowWidth'=>10,
    'shadowOffset'=>3,
    'shadowDepth'=>3,
    'shadowColor'=>'rgba(230, 230, 230, 0.07)'
    ));

//set axes
$pc->set_axes(array(
    'xaxis'=>array('rendnerer'=>'plugin::CategoryAxisRenderer'),
    'yaxis'=>array('padMax'=>2.0)));
//set axes
$pc->set_xaxes(array(
    'xaxis'  => array(
        'borderWidth'=>2,
        'borderColor'=>'#999999',
        'tickOptions'=>array('showGridline'=>false))
    ));

$pc->set_yaxes(array(
    'yaxis' => array(
        'borderWidth'=>0,
        'borderColor'=>'#ffffff',
        'autoscale'=>true,
        'min'=>'0',
        'max'=>20,
        'numberTicks'=>21,
        'labelRenderer'=>'plugin::CanvasAxisLabelRenderer',
        'label'=>'Energy Use')
    ));
$pc->draw();

Live demo

Top

Clicky