Skip to main content

git@github.com:tavallaie/pychartjs.git

Project description

Pychartjs

Pychartjs is a Python library for generating dynamic charts using Chart.js and integrating them into web applications. The library is built on top of the Trunco framework, which provides a component-based architecture to make it easy to create and manage various chart types.

Features

  • Support for all major chart types: Line, Bar, Pie, Doughnut, Radar, PolarArea, Bubble, and Scatter.
  • Integration with various web frameworks including Robyn, Django, FastAPI, and other Python web frameworks.
  • Dynamic chart rendering with context variables.
  • Flexible and customizable chart options.

Project Structure

pychartjs/
├── pychartjs/
│   ├── __init__.py
│   ├── charts.py
│   ├── datasets.py
│   ├── enums.py
│   ├── options.py
│   ├── scales.py
│   ├── plugins.py
│   ├── colors.py
├── tests/
│   ├── test_charts.py
│   ├── test_datasets.py
│   ├── test_options.py
│   ├── test_scales.py
│   ├── test_plugins.py
│   ├── test_colors.py
├── integration_tests/
│   ├── app.py
│   └── templates/
│       └── index.html
├── LICENSE
├── README.md
├── poetry.lock
└── pyproject.toml
  • pychartjs/: Contains the core library code, including charts, datasets, enums, options, and scales.
  • tests/: Unit tests for the various components of the library.
  • integration_tests/: A sample application that demonstrates how to integrate pychartjs with a web framework like Robyn.

Installation

  1. Install with Poetry:

    If you are using Poetry for dependency management, you can add pychartjs to your project with:

    poetry add pychartjs
    
  2. Alternatively, install with pip:

    If you're using pip, you can install pychartjs with:

    pip install pychartjs
    

Usage

Running the Integration Tests

The project includes an integration test that sets up a simple web server with Robyn to display all chart types.

  1. Navigate to the integration_tests directory:

    cd integration_tests
    
  2. Run the Application:

    Start the web server:

    python app.py
    
  3. View in Browser:

    Open your browser and go to http://localhost:8080. You should see a page displaying all the supported chart types.

Adding New Charts

To add a new chart type or customize an existing one, modify the app.py file and create new chart instances there.

Context Variables

The charts can be dynamically generated with context variables. For example, you can pass a year or month variable to customize the labels and datasets.

Integration with Other Web Frameworks

Pychartjs is flexible and can be integrated with other popular Python web frameworks such as:

  • Django: Easily render charts within Django views and templates.
  • FastAPI: Use Pychartjs to generate charts in FastAPI routes.
  • Flask: Integrate with Flask to display dynamic charts.
  • Any other WSGI/ASGI framework: Pychartjs can be adapted to work with any Python web framework that supports WSGI or ASGI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pychartjs-1.0.0.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

pychartjs-1.0.0-py3-none-any.whl (8.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page