Tag Archives: Arbitrary

Data Series With Arbitrary Values

It’s common to have series that pairs data value with arbitrary text. The key is pair both data value and text in array in the following format and include three plugins: canvasTextRenderer, CategoryAxisRenderer, and CategoryAxisRenderer.

1
array(array("text 1", 3), array("another text", 4)...)

Complete example:

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
$line = array(array('Cup Holder Pinion Bob', 7), array('Generic Fog Lamp', 9), array('HDTV Receiver', 15), array('8 Track Control Module', 12), array(' Sludge Pump Fourier Modulator', 3),array('Transcender/Spice Rack', 6), array('Hair Spray Danger Indicator', 18));
$pc = new C_PhpChartX(array($line),'chart_1');
$pc->add_plugins(array('canvasTextRenderer'));

//set animation
$pc->set_animate(true);
//set title
$pc->set_title(array('text'=>'Concern vs. Occurrance'));

//set series
$pc->add_series(array('renderer'=>'plugin::BarRenderer'));
//set axes
$pc->set_axes(array(
        'xaxis'  => array(
            'renderer'=>'plugin::CategoryAxisRenderer',
            'label'=>'Warranty Concern',
            'tickOptions'=>array(
                'enableFontSupport'=>true,'angle'=>-30),
            'tickRenderer'=>'plugin::CanvasAxisTickRenderer'),
        'yaxis'  => array(
            'autoscale'=>true,
            'label'=>'Occurance',
            'tickOptions'=>array('enableFontSupport'=>true,'angle'=>-30),
            'tickRenderer'=>'plugin::CanvasAxisTickRenderer')
     ));

$pc->draw(800,500);

Live demo

Top

Clicky