{"id":13803246,"url":"https://github.com/0xClandestine/solplot","last_synced_at":"2025-05-13T15:32:46.375Z","repository":{"id":62971645,"uuid":"562349209","full_name":"0xClandestine/solplot","owner":"0xClandestine","description":"A Foundry plugin that enables you to plot charts within solidity.","archived":false,"fork":false,"pushed_at":"2024-01-04T05:58:27.000Z","size":129,"stargazers_count":156,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-04T01:02:10.232Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xClandestine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2022-11-06T03:48:15.000Z","updated_at":"2024-08-04T01:02:12.487Z","dependencies_parsed_at":"2023-12-14T20:49:06.455Z","dependency_job_id":"319aa9db-8ea5-4f22-bccd-16ac21b746ea","html_url":"https://github.com/0xClandestine/solplot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xClandestine%2Fsolplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xClandestine%2Fsolplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xClandestine%2Fsolplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xClandestine%2Fsolplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xClandestine","download_url":"https://codeload.github.com/0xClandestine/solplot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225239729,"owners_count":17442817,"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-08-04T01:00:26.296Z","updated_at":"2024-11-18T19:31:27.620Z","avatar_url":"https://github.com/0xClandestine.png","language":"Solidity","readme":"# 🖌️solplot\nA Foundry plugin that enables you to plot charts within solidity.\n\n![output](output.svg)\n\n\n\u0026nbsp;\n# Installation\nFirst, make sure that you have [Rust installed](https://www.rust-lang.org/tools/install). Then install source as directed below.\n\n\u003c!-- \u0026nbsp;\n### Install from crates.io\n```\ncargo install solplot\n``` --\u003e\n\n\u0026nbsp;\n### Installing binary from source\n```\ngit clone https://github.com/0xClandestine/solplot \u0026\u0026\ncd solplot \u0026\u0026\ncargo install --path .\n```\n\nThen add `solplot` to your foundry project.\n\n```\nforge install 0xClandestine/solplot\n```\n\nNow simply inherit `Plot` into your test contract, and you'll have access to plotting methods.\n\n```js\n// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.0;\n\nimport {Plot} from \"solplot/src/Plot.sol\";\n\n// Some math to plot out...\nfunction expToLevel(uint256 x, uint256 y, uint256 i, uint256 h) pure returns (uint256 z) {\n    z = x \u003e\u003e (i / h);\n    z -= (z * (i % h) / h) \u003e\u003e 1;\n    z += (x - z) * y / x;\n}\n\ncontract DemoPlot is Plot {\n    function testPlot() public {\n        unchecked {\n            // Remove previous demo input CSV if it exists locally\n            try vm.removeFile(\"input.csv\") {} catch {}\n\n            // Write legend on the first line of demo output CSV\n            // NOTE: Use the 'writeRowToCSV(string memory, string[] memory)'\n            //       if more than 9 columns are needed.\n            writeRowToCSV(\n                \"input.csv\", \"x-axis\", \"h=5\", \"h=10\", \"h=15\", \"h=20\", \"h=25\", \"h=30\", \"h=35\", \"h=40\"\n            );\n\n            // Loop over a range, and compute the results of some math\n            for (uint256 i; i \u003c 150; ++i) {\n                // NOTE: Use the 'writeRowToCSV(string memory, uint256[] memory)'\n                //       if more than 9 columns are needed.\n                writeRowToCSV(\n                    \"input.csv\",\n                    i * 1 ether,\n                    expToLevel(1 ether, 0.9 ether, i, 5),\n                    expToLevel(1 ether, 0.9 ether, i, 10),\n                    expToLevel(1 ether, 0.9 ether, i, 15),\n                    expToLevel(1 ether, 0.9 ether, i, 20),\n                    expToLevel(1 ether, 0.9 ether, i, 25),\n                    expToLevel(1 ether, 0.9 ether, i, 30),\n                    expToLevel(1 ether, 0.9 ether, i, 35),\n                    expToLevel(1 ether, 0.9 ether, i, 40)\n                );\n            }\n\n            // Once the input CSV is fully created, use it to plot the output SVG\n            // NOTE: Output file can be .png or .svg\n            plot(\"input.csv\", \"output.svg\", \"ExpToLevel(x, y, i, h) -\u003e (z) Plot\", 18, 9, 900, 600, true);\n        }\n    }\n}\n```\n\n\u0026nbsp;\n# Usage\n\n```\nUsage: solplot [OPTIONS] --input-file \u003cINPUT_FILE\u003e --output-file \u003cOUTPUT_FILE\u003e --precision \u003cPRECISION\u003e --columns \u003cCOLUMNS\u003e\n\nOptions:\n  -i, --input-file \u003cINPUT_FILE\u003e\n  -o, --output-file \u003cOUTPUT_FILE\u003e\n  -p, --precision \u003cPRECISION\u003e\n  -c, --columns \u003cCOLUMNS\u003e\n  -w, --width \u003cWIDTH\u003e              [default: 800]\n  -h, --height \u003cHEIGHT\u003e            [default: 600]\n  -t, --title \u003cTITLE\u003e\n  -l, --legend\n  -h, --help                       Print help\n```","funding_links":[],"categories":["Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xClandestine%2Fsolplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xClandestine%2Fsolplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xClandestine%2Fsolplot/lists"}