--- title: "Sales Bar Chart" id: 57015 type: "computer_media" slug: "sales-bar-chart" url: "http://localhost/computer_media/sales-bar-chart/" markdown_url: "http://localhost/computer_media/sales-bar-chart.md" published_at: "2024-10-02T07:38:53+00:00" modified_at: "2026-03-30T21:20:10+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/39_Sales.png" excerpt: "A random-data dual-series bar chart using block graphics to show overlapping sales figures for nuts and bolts across five simulated years." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Business" slug: "business" taxonomy: "genre" url: "http://localhost/type/business/" media_contents: - id: 56732 title: "Timex Sinclair Public Domain Library Tape 1001" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1001/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/39_Sales.png" media_type_tags: "Business" --- # Sales Bar Chart This program generates a dual-series horizontal bar chart displaying five years of simulated sales figures for two product lines, nuts and bolts. It uses a 5×2 array to store randomly generated sales values (integers in the range 10–20) and renders the chart using block graphics characters to distinguish where both series overlap, where only nuts exceed a threshold, and where only bolts do. The x-axis labels are printed manually across two lines to represent values 0 through 20 in steps of 2. Output uses tab-separated formatting with inverse-video characters in column headers and a manually positioned axis scale. *** ## Program Analysis ### Program Structure The program is divided into four logical phases, separated by line-number ranges: 1. **Lines 5–10:** Title REM and array declaration. 2. **Lines 100–140:** Data initialisation — fills the 5×2 array `S` with random values. 3. **Lines 200–499:** Output — prints the chart header, iterates over years, draws bars, and prints the x-axis scale. 4. **Lines 500–510:** Save/auto-run block, not part of normal execution. ### Data Generation The two-dimensional array `S(5,2)` stores values for five years and two product lines (nuts = column 1, bolts = column 2). Each value is generated by `INT(RND*11+10)`, producing integers uniformly distributed in the range 10–20 inclusive. This means every bar will be at least half the maximum chart width, giving a reasonably compact but always-populated chart. ### Bar Rendering Technique For each year, a loop over `K` from 1 to 20 tests the relationship between the two series values and the current column position, printing one of three block graphic characters per cell: | Condition | Escape | Glyph | Meaning | | --- | --- | --- | --- | | `S(J,1)>=K` AND `S(J,2)>=K` | `\!!` | ▒ | Both nuts and bolts reach this column | | `S(J,1)>=K` AND `S(J,2)=K` AND `S(J,1)=K AND S(J,2)>=K THEN PRINT "\!!"; 330 IF S(J,1)>=K AND S(J,2)=K AND S(J,1)