##
ITK Dynamic chart demo

The following charts are generated "on-the-fly" by 4D+4D Chart+ITK team.

- Chart#1 is created using the browser information used to access it. It gives an idea of the most frequently Web browsers used.
- Chart#2 is generated with pseudo-random data. The chart type is also selected randomly.

Both charts use transparency which take the color of the first pixel of the picture as the transparent color (which is fine for most pictures).
The first one also uses interlaced GIF.

## Most frequently Web browsers used to access this chart :

## Dynamic Random Chart :

### Here is how it works:

#### 1- 4D receive an HTTP request with ITK's help,

#### 2- An offscreen chart is generated by 4D Chart with the following 4D/4DChart commands:

        ` Generate chart data
      $nCat:=5
      $nSer:=1+(Random%20)
      ARRAY TEXT($aCat;$nCat)
      ARRAY TEXT($aSer;$nSer)
      ARRAY REAL($aVal;$nCat*$nSer)
      For ($i;1;$nCat)
        $aCat{$i}:="Cat. "+String($i)
        For ($j;1;$nSer)
          $aSer{$j}:="Serie "+String($j)
          If ($i=1)
            $aVal{($i-1)*$nSer+$j}:=Random
          Else
            $aVal{($i-1)*$nSer+$j}:=$aVal{($i-2)*$nSer+$j}*1,2
          End if
        End for
      End for

        ` Generate chart
      $chart:=CT New offscreen area
      $area:=CT Chart arrays ($chart;(Random%6)+1+((Random%2)*99);2;$aCat;$aSer;$aVal)
      CT SIZE ($chart;-1;400;300)

        ` Convert chart to picture
      $pict:=CT Area to picture ($Chart;-1)
      CT DELETE OFFSCREEN AREA ($chart)

#### 3- The chart picture is converted to GIF using ITK's ITK_Pict2GIF routine in the following single line:

        ` Convert picture to GIF
       $pict:=ITK_Pict2GIF ($pict;2)  ` transparent GIF please !

#### 4- The picture data is sent using ITK with the following commands:

        ` send HTTP header
    $err:=ITK_TCPSend ($1;"HTTP/1.0 200 OK"+$crlf;1)
    $err:=ITK_TCPSend ($1;"MIME-Version: 1.0"+$crlf;1)
    $err:=ITK_TCPSend ($1;"Content-type: image/gif"+$crlf)
    $err:=ITK_TCPSend ($1;"Content-length: "+String(Picture size($pict))+$crlf+$crlf)
    $err:=ITK_TCPSendPict ($1;$pict)

These are small examples of ITK's picture routines...