Tag Archives: LogAxisRenderer

Logarithmic Axis using LogAxisRenderer

logarithm_chart

Display logarithmic axis using LogAxisRenderer. Make sure the tickDistribution is set to “power” for power of 10 display on its axis.

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
<?php
$line1 = array(array(100,121), array(2000,21), array(5000,35), array(6600,43));
$pc = new C_PhpChartX(array($line1),'chart_1');
$pc->add_plugins(array('canvasTextRenderer'));
// curved line
$pc->set_series_default(array('rendererOptions'=> array('smooth'=>true)));
// Logarithm
$pc->set_axes(array(
    'xaxis'  => array(
        'renderer'=>'plugin::LogAxisRenderer',
        'tickOptions'=>array('tickDistribution' =>"power",  // power of 10
                             'formatString'     => "%'i",
                             'showGridline'=>false),
        'labelRenderer'=>'plugin::CanvasAxisLabelRenderer',
        'min'=>0,
        'showGridline'=>false,
        'ticks'=> array(1, 10, 100, 1000, 10000)
        ),

    'yaxis'  => array(
        'autoscale'=>false,
        'tickOptions'=>array('showGridline'=>false),
        'labelRenderer'=>'plugin::CanvasAxisLabelRenderer')
));
$pc->draw(800,500);

Live demo

Top

Clicky