{"id":19911043,"url":"https://github.com/streetsidesoftware/thistogram","last_synced_at":"2025-06-11T17:02:13.162Z","repository":{"id":222343045,"uuid":"756767032","full_name":"streetsidesoftware/thistogram","owner":"streetsidesoftware","description":"A simple text based histogram generator.","archived":false,"fork":false,"pushed_at":"2025-06-09T12:10:23.000Z","size":609,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T13:24:49.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/streetsidesoftware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["streetsidesoftware"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-02-13T09:17:13.000Z","updated_at":"2025-04-23T17:06:04.000Z","dependencies_parsed_at":"2024-02-13T18:27:09.053Z","dependency_job_id":"a23dd70b-68cb-424f-8401-afaafa3a7d56","html_url":"https://github.com/streetsidesoftware/thistogram","commit_stats":null,"previous_names":["streetsidesoftware/thistogram"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/streetsidesoftware/thistogram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streetsidesoftware%2Fthistogram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streetsidesoftware%2Fthistogram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streetsidesoftware%2Fthistogram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streetsidesoftware%2Fthistogram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streetsidesoftware","download_url":"https://codeload.github.com/streetsidesoftware/thistogram/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streetsidesoftware%2Fthistogram/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259301636,"owners_count":22836966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T21:23:15.968Z","updated_at":"2025-06-11T17:02:13.107Z","avatar_url":"https://github.com/streetsidesoftware.png","language":"TypeScript","funding_links":["https://github.com/sponsors/streetsidesoftware"],"categories":[],"sub_categories":[],"readme":"# Thistogram\n\nA simple text based histogram and chart generator.\n\n## Usage\n\n### Histogram\n\n\u003c!--- @@inject: samples/histogram.js ---\u003e\n\n```js\nimport { histogram } from 'thistogram';\n\nconst data = [\n  ['one', 1],\n  ['two', 2],\n  ['three', 3],\n  ['four', 4],\n  ['2.5', 2.5]\n];\nconst hist = histogram(data, {\n  width: 40,\n  maxLabelWidth: 5,\n  title: 'Numbers',\n  headers: ['Label', 'Value']\n});\nconsole.log(hist);\n```\n\n\u003c!--- @@inject-end: samples/histogram.js ---\u003e\n\nResult:\n\n\u003c!--- @@inject: static/histogram.txt ---\u003e\n\n```\nNumbers\nLabel ┃                          ┃ Value\n━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━\none   ┃██████▌                   ┃     1\ntwo   ┃█████████████             ┃     2\nthree ┃███████████████████▌      ┃     3\nfour  ┃██████████████████████████┃     4\n2.5   ┃████████████████▎         ┃   2.5\n```\n\n\u003c!--- @@inject-end: static/histogram.txt ---\u003e\n\n### Point-Min-Max Chart\n\nCode:\n\n\u003c!--- @@inject: samples/temperature.js ---\u003e\n\n```js\nimport { histogram } from 'thistogram';\n\nconst data = [\n  ['Jan', 2, 1, 6],\n  ['Feb', 2, 0, 6],\n  ['Mar', 4, 2, 10],\n  ['Apr', 8, 4, 13],\n  ['May', 12, 8, 17],\n  ['Jun', 16, 12, 20],\n  ['Jul', 18, 13, 22],\n  ['Aug', 18, 13, 23],\n  ['Sep', 14, 10, 19],\n  ['Oct', 10, 6, 15],\n  ['Nov', 6, 4, 10],\n  ['Dec', 3, 2, 7]\n];\nconst graph = histogram(data, {\n  width: 70,\n  maxLabelWidth: 5,\n  title: 'Temperature Degrees C',\n  type: 'point-min-max',\n  headers: ['Month', 'Avg', 'Min', 'Max']\n});\nconsole.log(graph);\n```\n\n\u003c!--- @@inject-end: samples/temperature.js ---\u003e\n\nResult:\n\n\u003c!--- @@inject: static/temperature.txt ---\u003e\n\n```\nTemperature Degrees C\nMonth ┃                                              ┃ Avg ┃ Min ┃ Max\n━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━╋━━━━━╋━━━━\nJan   ┃  ┣━●━━━━━━━┫                                 ┃   2 ┃   1 ┃   6\nFeb   ┃┣━━━●━━━━━━━┫                                 ┃   2 ┃   0 ┃   6\nMar   ┃    ┣━━━●━━━━━━━━━━━┫                         ┃   4 ┃   2 ┃  10\nApr   ┃        ┣━━━━━━━●━━━━━━━━┫                    ┃   8 ┃   4 ┃  13\nMay   ┃                ┣━━━━━━●━━━━━━━━━┫            ┃  12 ┃   8 ┃  17\nJun   ┃                       ┣━━━━━━━●━━━━━━━┫      ┃  16 ┃  12 ┃  20\nJul   ┃                         ┣━━━━━━━━━●━━━━━━━┫  ┃  18 ┃  13 ┃  22\nAug   ┃                         ┣━━━━━━━━━●━━━━━━━━━┫┃  18 ┃  13 ┃  23\nSep   ┃                    ┣━━━━━━●━━━━━━━━━┫        ┃  14 ┃  10 ┃  19\nOct   ┃            ┣━━━━━━━●━━━━━━━━┫                ┃  10 ┃   6 ┃  15\nNov   ┃        ┣━━━●━━━━━━━┫                         ┃   6 ┃   4 ┃  10\nDec   ┃    ┣━●━━━━━━━┫                               ┃   3 ┃   2 ┃   7\n```\n\n\u003c!--- @@inject-end: static/temperature.txt ---\u003e\n\n### Simple Histogram\n\nCode:\n\n\u003c!--- @@inject: samples/table.js ---\u003e\n\n```js\nimport { simpleHistogram } from 'thistogram';\n\nconst data = [\n  ['jan', [5, 7, 9, 12]],\n  ['feb', [13, 10, 8, 15]],\n  ['mar', [14, 11, 9, 16]],\n  ['apr', [17, 15, 22, 18]]\n];\n\nfunction calcAvg(arr) {\n  return arr.reduce((a, b) =\u003e a + b, 0) / arr.length;\n}\n\nfunction table() {\n  const lines = [];\n  const allTemps = data.flatMap(([, d]) =\u003e d);\n  const tempMax = Math.max(...allTemps);\n  const tempMin = Math.min(...allTemps);\n  const tempRange = tempMax - tempMin;\n  const margin = tempRange * 0.1;\n  const graphMin = Math.floor(tempMin - margin);\n  const graphMax = Math.ceil(tempMax + margin);\n  lines.push('| Month | Avg |  Min |  Max | Graph |');\n  lines.push('|-------|----:|-----:|-----:|-------|');\n  for (const [month, monthData] of data) {\n    const avg = calcAvg(monthData);\n    const min = Math.min(...monthData);\n    const max = Math.max(...monthData);\n    const histo = simpleHistogram(monthData, graphMin, graphMax);\n    lines.push(`| ${month} | ${avg.toFixed(1)} | ${min} | ${max} | \\`${histo}\\` |`);\n  }\n  lines.push('');\n  lines.push('The table above shows the average, minimum, and maximum temperature for each month.');\n  const trendGraph = simpleHistogram(allTemps, graphMin, graphMax);\n  lines.push('');\n  lines.push(`Weekly Trend: \\`${trendGraph}\\``);\n  return lines.join('\\n');\n}\n\nconsole.log(table());\n```\n\n\u003c!--- @@inject-end: samples/table.js ---\u003e\n\nResult:\n\n\u003c!--- @@inject: static/table.md ---\u003e\n\n| Month |  Avg | Min | Max | Graph  |\n| ----- | ---: | --: | --: | ------ |\n| jan   |  8.3 |   5 |  12 | `▁▂▃▄` |\n| feb   | 11.5 |   8 |  15 | `▄▃▂▅` |\n| mar   | 12.5 |   9 |  16 | `▅▄▃▅` |\n| apr   | 18.0 |  15 |  22 | `▆▅█▆` |\n\nThe table above shows the average, minimum, and maximum temperature for each month.\n\nWeekly Trend: `▁▂▃▄▄▃▂▅▅▄▃▅▆▅█▆`\n\n\u003c!--- @@inject-end: static/table.md ---\u003e\n\n## Examples\n\n```\nSine\n0  ┃██▊                ┃  0.00\n1  ┃█████▌             ┃  0.17\n2  ┃████████▎          ┃  0.34\n3  ┃██████████▉        ┃  0.50\n4  ┃█████████████▏     ┃  0.64\n5  ┃███████████████▏   ┃  0.77\n6  ┃████████████████▊  ┃  0.87\n7  ┃██████████████████ ┃  0.94\n8  ┃██████████████████▊┃  0.98\n9  ┃███████████████████┃  1.00\n10 ┃██████████████████▊┃  0.98\n11 ┃██████████████████ ┃  0.94\n12 ┃████████████████▊  ┃  0.87\n13 ┃███████████████▏   ┃  0.77\n14 ┃█████████████▏     ┃  0.64\n15 ┃██████████▉        ┃  0.50\n16 ┃████████▎          ┃  0.34\n17 ┃█████▌             ┃  0.17\n18 ┃██▊                ┃  0.00\n19 ┃▏                  ┃ -0.17\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreetsidesoftware%2Fthistogram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreetsidesoftware%2Fthistogram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreetsidesoftware%2Fthistogram/lists"}