Chapter 17. Additional graph types
| Part IV. Creating linear and non-linear graphs |

## Chapter 17. Additional graph types

These chapter describes the types of graphs supported by the library that is not a standard graph type used to display data series.

## LED bill boards

This feature allows the creation of displayed letters (some) and digits which have the look of a 4x7 LED display.

In order to use this feature the module "`jpgraph_led.php`" must be included.

### Caution

In order to use the LED module the PHP installation must have multi-byte strings enabled so that the function `mb_strlen()` is available. This is normally enabled at compile time for PHP by specifying the options `--enable-mbstring --enable-mbregex` when configuring the compile options.

The figures below shows some samples of the characters supported and the available colors

Figure 17.1. LEDC_GREEN `(`ledex1.php`)`
Figure 17.2. LEDC_RED `(`ledex2.php`)`
Figure 17.3. LEDC_YELLOW `(`ledex3.php`)`
Figure 17.4. LEDC_BLUE `(`ledex5.php`)`
Figure 17.5. LEDC_GRAY `(`ledex6.php`)`
Figure 17.6. LEDC_INVERTGRAY `(`ledex17.php`)`
Figure 17.7. LEDC_CHOCOLATE `(`ledex7.php`)`
Figure 17.8. LEDC_PERU `(`ledex8.php`)`
Figure 17.9. LEDC_GOLDENROD `(`ledex9.php`)`
Figure 17.10. LEDC_KHAKI `(`ledex10.php`)`
Figure 17.11. LEDC_OLIVE `(`ledex11.php`)`
Figure 17.12. LEDC_LIMEGREEN `(`ledex12.php`)`
Figure 17.13. LEDC_FORESTGREEN `(`ledex13.php`)`
Figure 17.14. LEDC_TEAL `(`ledex14.php`)`
Figure 17.15. LEDC_STEELBLUE `(`ledex15.php`)`
Figure 17.16. LEDC_NAVY `(`ledex16.php`)`

A LED display is constructed by creating an instance of class DigitalLED47

- `DigitalLED47::__construct($aRadius = 2, $aMargin= 0.6)`

  The first argument specifies the radius of each "led-light" and the second argument the margin around each character. Adjusting the radius is the only way to adjust the size of the LED characters.

In order to generate the billboard the method

- `DigitalLED47::Stroke($aValStr, $aColor , $aFileName = '')`

  `$aValStr`, The string to be displayed

  `$aColor`, one of the available colors as shown in the figures above

  `$aFileName`, An optional file name which specifies a file that the image will be written to. No image will be streamed back to the browser in this case.

is called with the string to be displayed as the first argument. The following code snippet shows how to create a green LED bill board

    1
    2
    $led = new DigitalLED74();
    $led->Stroke('0123456789. ABCDEFGHIJKL',LEDC_GREEN);

In order to improve visual quality of the LED display it uses super sampling internally to achieve the anti-alias smoothing effect. The number of oversampling is specified with

- `DigitalLED47::SetSupersampling($aSuperSampling)`

  By default a 2:times super-sampling is used. Using any value higher than 4 does not give any visual improvements

In the three figures below different levels of super sampling is used, in the left most image no super sampling is used (super sampling=1), in the middle figure super sampling=2 (the default) and in the rightmost figure super sampling is set to 4

Figure 17.17. Supersampling=1 `(`ledex4.php`)` | Figure 17.18. Supersampling=2 (default) `(`ledex4.1.php`)` | Figure 17.19. Supersampling=4 `(`ledex4.2.php`)`

### Cyrillic character support

In addition to most of the basic latin characters the library also have some support for Cyrillic characters. Due to the limed resolution (4x7) some more complex cyrillic characters are not rendered very faithfully. The available rendering for the cyrillic alphabet is shown in Figure 17.20. LED 4x7 Cyrillic alphabet support

Figure 17.20. LED 4x7 Cyrillic alphabet support

### Caution

Since the library internally uses utf8 character encoding it means that the string passed on to the library must also be encoded in utf8. In case the characters have another encoding, say cp1251, they must first be converted to utf8. This could for example be done by the PHP function `iconv()`..

(This is the only place in the library that is truly multi-byte text safe.)

| Up |
| Home |