How to embed a dynamic graph in a WEB page
This example intends to demostrate the case where
  • you already have a CGI program using a rather complex external HTML script, and
  • you want to insert a dynamic chart into one of its WEB pages, but
  • without redesigning the external HTML script nor the CGI program itself.
You can achieve your objective having the CGI program doing the following:
  1. Produce its usual HTML output up to the point where the graph should show up
  2. Run command graphit/chartit to create a graph stream file
  3. Execute CGIDEV2 procedure LoadStreamFile() to load in memory the graph stream file
  4. Execute CGIDEV2 procedure WrtNoSection() to write this memory to the output buffer
  5. Add to the ouput buffer the remaining part of the usual HTML
In this example, step 1 above ("Produce its usual HTML ouput up to the point ..." ends here.
World population distribution
World population distribution
Country populations (millions)
Other 173 countries 1711
China 1357
India 1252
United States 320
Indonesia 250
Brazil 200
Pakistan 191
Nigeria 174
Bangladesh 157
Russia 144
Japan 127
Mexico 122
Philippines 99
Ethiopia 94
Vietnam 90
Egypt 88
Germany 81
Iran 80
Turkey 77
Thailand 70
Congo 68
France 66
United Kingdom 65
Italy 61
South Africa 51
Canada 34
Australia 24
This is the remaining part of the usual HTML output.
If you like, you can display the HTML and the RPG source used to build the example case: