Creates svg based charts in python
Project description
A Python package for creating and rendering SVG charts, including line charts, axes, legends, and text labels. This package supports both simple and complex chart structures and is highly customizable for various types of visualizations.
Features
Modular Structure: Create SVG charts with reusable components like Line, Text, Axis, and Shape.
Axis Scaling: Automatically generates axis tick values based on the data range with customizable limits.
Customizable Styles: Supports custom styles for lines, text, and axes.
Legends: Add legends to your charts to represent different data series.
Dynamic Rendering: Render a chart in SVG format with full control over size, style, and elements.
Support for Simple and Advanced Charts: Create simple line charts or extend the functionality for more complex visualizations.
Installation
pip install svg-chart-generator
Alternatively, you can clone this repository and install it locally:
git clone https://github.com/arowley-ai/py-svg-chart.git
cd py-svg-chart
pip install .
Usage
Create a simple line chart with the following code:
from svg_chart_generator import SimpleLineChart
# Sample data
x_values = [0, 1, 2, 3, 4, 5]
y_values = [[0, 2, 4, 6, 8, 10], [0, 1, 2, 3, 4, 5]]
# Create the chart
chart = SimpleLineChart(x_values, y_values, y_names=["Series 1", "Series 2"])
# Add a legend
chart.add_legend(x_position=500, y_position=60, element_x=100, element_y=0, line_length=20, line_text_gap=5)
# Render the chart as an SVG string
svg_output = chart.render
# Save the SVG output to a file
with open("chart.svg", "w") as f:
f.write(svg_output)
chart.series[0].styles['stroke'] = 'red'
chart.series[1].styles['stroke'] = 'blue'
chart.x_axis.axis_line.styles['stroke'] = 'black'
Extensible Configuration
The entire codebase is designed to be extensible to enable unlimited customisation. All of the lower level elements are accessible via properties of the charts.
Contributing
We welcome contributions! If you’d like to contribute to the project, please follow these steps:
Fork this repository.
Create a new branch (git checkout -b feature-branch). Commit your changes (git commit -am ‘Add feature’). Push to the branch (git push origin feature-branch). Open a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysvgchart-0.0.3.tar.gz.
File metadata
- Download URL: pysvgchart-0.0.3.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3f679a1fb92f4f555afd2bf9dc720e76d12d3c4eff0b0bd2de56f2e8bcb947c
|
|
| MD5 |
f9378e746b25c3a053671cdf44f10c5e
|
|
| BLAKE2b-256 |
0ae016f7b9ae7c44a4b851e00134037e6eb7c46efc6445a5c8ebddc0ebced68d
|
File details
Details for the file pysvgchart-0.0.3-py2.py3-none-any.whl.
File metadata
- Download URL: pysvgchart-0.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dff3cc20af4c8b4e1c7b3996c4b0baf78d7cba6af9fc9e64708151a8d6dfc1c4
|
|
| MD5 |
3e7ebaa1227be64b2432ba8c8f972def
|
|
| BLAKE2b-256 |
3d147188e11249a305096c5a309068a1501d7055112e7474b7f4be35a126f88e
|