Data Point Labels on PHP Graph

You can label specific data points in a graph with additional text or even image to further describe the data presented in PHP chart. To do that, the non-renderer plugin, “pointLabels”, is required. This plugin places labels on the plot at the data point locations.

The last value in the data point array in a data series is used for the label by default. The following example uses HTML image for data points.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$s1 = array(
        array(0, 300, '<img height="30px" width="30px" src="images/new.png"/>'),
        array(1, 150, '<img height="30px" width="30px" src="images/new.png"/>'),
        array(2, 35, '<img height="30px" width="30px" src="images/new.png"/>'));
 
....

$pc->add_plugins(array('cursor','pointLabels','barRenderer','categoryAxisRenderer'),true);

....

$pc->set_series_default(array(
           'pointLabels'=> array(
              'show'=> true,
              'escapeHTML'=> false,
              'ypadding'=> -15
           )
       ));

Complete pointLabels reference:
http://www.jqplot.com/docs/files/plugins/jqplot-pointLabels-js.html

Live demo

No related content found.

Tags: ,

Top

Clicky

PHP Charts & Graphs
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.