{"id":31799759,"url":"https://github.com/ceccode/quadrant-gen","last_synced_at":"2025-10-10T22:49:38.049Z","repository":{"id":311998859,"uuid":"1045925501","full_name":"ceccode/quadrant-gen","owner":"ceccode","description":"A Python library for creating quadrant charts with customizable labels and data points, optimized for web applications and API integrations.","archived":false,"fork":false,"pushed_at":"2025-09-01T22:39:00.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-24T18:59:19.621Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ceccode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-08-27T23:30:21.000Z","updated_at":"2025-09-01T22:39:04.000Z","dependencies_parsed_at":"2025-08-28T07:26:31.955Z","dependency_job_id":"131d1737-5769-44a2-b3a6-5bcde131588e","html_url":"https://github.com/ceccode/quadrant-gen","commit_stats":null,"previous_names":["ceccode/quadrant-gen"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ceccode/quadrant-gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceccode%2Fquadrant-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceccode%2Fquadrant-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceccode%2Fquadrant-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceccode%2Fquadrant-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceccode","download_url":"https://codeload.github.com/ceccode/quadrant-gen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceccode%2Fquadrant-gen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005458,"owners_count":26083902,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-10T22:49:37.135Z","updated_at":"2025-10-10T22:49:38.041Z","avatar_url":"https://github.com/ceccode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quadrant Generator\n\nA Python library for creating quadrant charts with customizable labels and data points, optimized for web applications and API integrations.\n\n## Features\n\n- Create quadrant charts from CSV strings or data points\n- Customizable axis labels and titles\n- Automatic text positioning to prevent overlap\n- Generate base64-encoded images for easy web integration\n- Clean, minimalist design\n\n## Installation\n\n### From Source\n\n```bash\n# Clone the repository\ngit clone https://github.com/ceccode/quadrant-gen.git\ncd quadrant-gen\n\n# Install the package\npip install -e .\n```\n\n### Using pip\n\n```bash\npip install quadrant-gen\n```\n\n## Usage\n\nThe library is designed to be used programmatically in your Python applications, particularly for web applications and APIs.\n\n### CSV Format\n\nYour CSV file should have the following columns:\n- `name`: Name of the data point\n- `description`: Description of the data point\n- `x`: X-coordinate (0.0 to 1.0)\n- `y`: Y-coordinate (0.0 to 1.0)\n\nExample:\n```csv\nname,description,x,y\nProduct A,High quality,0.2,0.8\nProduct B,Low cost,0.7,0.3\n```\n\n### Python API\n\n#### Using CSV String Input\n\n```python\nfrom quadrant_gen.chart import csv_to_quadrant_chart\n\n# CSV string with your data\ncsv_string = \"\"\"\nname,description,x,y\nProduct A,High quality,0.2,0.8\nProduct B,Low cost,0.7,0.3\n\"\"\"\n\n# Generate chart directly to base64-encoded image\nbase64_image = csv_to_quadrant_chart(\n    csv_string=csv_string,\n    title=\"My Quadrant Chart\",\n    x_left=\"Low X\",\n    x_right=\"High X\",\n    y_bottom=\"Low Y\",\n    y_top=\"High Y\",\n    format=\"png\"  # or \"pdf\"\n)\n\n# Use the base64 image in HTML\nhtml = f'\u003cimg src=\"{base64_image}\" alt=\"Quadrant Chart\"\u003e'  \n```\n\n#### Using Data Points\n\n```python\nfrom quadrant_gen.chart import generate_quadrant_chart, sample_points\n\n# Use sample data\npoints = sample_points()\n\n# Or create your own data\npoints = [\n    {\"label\": \"Item 1\\n(Description)\", \"x\": 0.2, \"y\": 0.8},\n    {\"label\": \"Item 2\\n(Description)\", \"x\": 0.7, \"y\": 0.3},\n]\n\n# Generate chart directly to base64-encoded image\nbase64_image = generate_quadrant_chart(\n    points=points,\n    title=\"My Quadrant Chart\",\n    x_left=\"Low X\",\n    x_right=\"High X\",\n    y_bottom=\"Low Y\",\n    y_top=\"High Y\",\n    format=\"png\"  # or \"pdf\"\n)\n```\n\n## Examples\n\nThe following examples are included in the repository:\n\n- **Simple Integration Example**: `examples/integration_example.py` - Shows how to use the library in a Python script\n- **Flask API Example**: `examples/flask_api_example.py` - RESTful API for generating charts\n- **Flask CSV App**: `examples/flask_csv_app/` - Web application with CSV input form\n\n### Live Demo\n\nTry the Flask CSV App online: **https://quadrant-gen-example.onrender.com/**\n\nSource code for the live demo: **https://github.com/ceccode/quadrant-gen-example**\n\n## Integration with Web Applications\n\nThe Quadrant Generator is optimized for web applications and API integrations:\n\n### Flask Integration Example\n\n```python\n# Important: Set matplotlib backend to 'Agg' before importing any matplotlib modules\n# This is required for web applications to avoid GUI-related errors\nimport matplotlib\nmatplotlib.use('Agg')\n\nfrom flask import Flask, render_template_string\nfrom quadrant_gen.chart import csv_to_quadrant_chart\n\napp = Flask(__name__)\n\n@app.route('/')\ndef index():\n    # Sample CSV data\n    csv_data = \"\"\"\nname,description,x,y\nProduct A,High quality,0.2,0.8\nProduct B,Low cost,0.7,0.3\n    \"\"\".strip()\n    \n    # Generate chart as base64 image\n    base64_image = csv_to_quadrant_chart(\n        csv_string=csv_data,\n        title=\"Product Analysis\",\n        x_left=\"Low Cost\", x_right=\"High Cost\",\n        y_bottom=\"Low Value\", y_top=\"High Value\"\n    )\n    \n    # Return HTML with embedded image\n    return render_template_string(\"\"\"\n        \u003c!DOCTYPE html\u003e\n        \u003chtml\u003e\n        \u003chead\u003e\n            \u003ctitle\u003eQuadrant Chart Example\u003c/title\u003e\n        \u003c/head\u003e\n        \u003cbody\u003e\n            \u003ch1\u003eProduct Analysis\u003c/h1\u003e\n            \u003cimg src=\"{{ chart }}\" alt=\"Quadrant Chart\"\u003e\n        \u003c/body\u003e\n        \u003c/html\u003e\n    \"\"\", chart=base64_image)\n\nif __name__ == '__main__':\n    app.run(debug=True)\n```\n\n\u003e **Note:** When using Matplotlib in web applications, you must set the backend to a non-interactive one like 'Agg' before importing any Matplotlib modules. This prevents GUI-related errors, especially on macOS where GUI operations must be on the main thread.\n\nSee the complete Flask integration example in `examples/flask_api_example.py`.\n\n### Flask CSV Web Application\n\nThe repository includes a complete web application for generating quadrant charts from CSV data:\n\n```bash\n# Run the Flask CSV app\ncd examples/flask_csv_app\npython app.py\n# Then open http://127.0.0.1:5001/ in your browser\n```\n\nThis application provides:\n- A form for entering CSV data\n- Options to customize chart title and axis labels\n- Preview of the generated chart\n- Download options for PNG or PDF formats\n\nSee `examples/flask_csv_app/` for the complete application.\n\n### API Integration\n\nThe library is perfect for API services that need to generate charts on-the-fly:\n\n```python\n# In a FastAPI application\nfrom fastapi import FastAPI, Response\nfrom pydantic import BaseModel\nfrom quadrant_gen.chart import csv_to_quadrant_chart\n\napp = FastAPI()\n\nclass ChartRequest(BaseModel):\n    csv_data: str\n    title: str = \"Quadrant Chart\"\n    x_left: str = \"Low X\"\n    x_right: str = \"High X\"\n    y_bottom: str = \"Low Y\"\n    y_top: str = \"High Y\"\n\n@app.post(\"/generate-chart/\")\nasync def generate_chart(request: ChartRequest):\n    # Generate base64 image\n    base64_image = csv_to_quadrant_chart(\n        csv_string=request.csv_data,\n        title=request.title,\n        x_left=request.x_left,\n        x_right=request.x_right,\n        y_bottom=request.y_bottom,\n        y_top=request.y_top\n    )\n    \n    # Return JSON with the base64 image\n    return {\"chart_data\": base64_image}\n```\n\n### Output Formats\n\nThe library generates base64-encoded images in two formats:\n\n- **PNG**: Web-friendly format for digital display\n- **PDF**: Vector format for high-quality printing and scaling\n\n## Contributing\n\n### For Developers\n\nIf you're a developer looking to contribute or maintain this package:\n\n- See [PUBLISHING.md](PUBLISHING.md) for instructions on how to build and publish new versions to PyPI\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceccode%2Fquadrant-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceccode%2Fquadrant-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceccode%2Fquadrant-gen/lists"}