Skip to main content

Create and Manage Charts with Ease

Project description

Python wrapper for One Charts API

One Charts - Create and Manage charts with Ease!

One Charts is a data visualization platform, using which, users can create various charts such as Line Charts, Pie Charts, Bar Charts, Scatter Charts etc., (supported charts) and customize them easily.

One Charts API - using One charts REST API, users can create, update charts programatically and in realtime.

This repository contains the python wrapper to interact with the One Charts API.

Authentication

The One Charts API uses API key to authenticate requests. You can view and manage your API key in the user profile.

Installation

$ git clone https://github.com/onechartsio/onecharts-py.git
$ cd onecharts-py
$ python setup.py install

Basic Usage

Import and initialize the onecharts object as:

>>> import onecharts
>>> oc = onecharts.OneCharts(API_KEY)  # Add your API Key.

Get User Charts

oc.get_user_charts() method can be used to retrieve public charts of an user. Example usage:

>>> charts = oc.get_user_charts('adam', q='stock')
>>> print(charts)
{
   "charts":[
      {
         "chart_id":"k-jOPzitp-MzB6",
         "chart_title":"top 10 stocks",
         "created_time":"2022-12-17T11:04:21.307Z",
         "chart_type":"pie",
         "chart_sub_type":"basic_pie",
         "thumbnail_path":"piechart",
         "cloned_from":"piechart"
      },
      {
         "chart_id":"o-SDEvxw9-7A0g",
         "chart_title":"dowjones Stocks daily trend",
         "created_time":"2022-12-17T11:04:21.307Z",
         "chart_type":"line",
         "chart_sub_type":"basicline",
         "thumbnail_path":"linechart",
         "cloned_from":"linechart"
      },
   ],
   "success":true
}

Create a New Chart

oc.create_new_chart() method can be used to create a new chart. Example usage:

>>> data = None  # Can contain some dictionary to overwrite the default data that's being cloned from.
>>> res = oc.create_new_chart('piechart', chart_title='Rainfall in 2023', visibility='private', notes='Some notes', data=data)
>>> print(res)
{
    'chart_id': 'KArrNpHzM-RLCo',
    'success': True
}

The above method creates a new piechart as shown below, which can be accessed using The created chart can be accessed using https://onecharts.io/chart/KArrNpHzM-RLCo image

Get Chart Config

oc.get_chart_config() method can be used to get the config of a chart. Example usage:

>>> res = oc.get_chart_config('KArrNpHzM-RLCo')
>>> print(res)
{
    "chart": {
        "chart_id": "KArrNpHzM-RLCo",
        "chart_title": "Rainfall in 2023",
        "created_time": "2023-09-10T06:03:20.694646Z",
        "modified_time": "2023-09-10T06:03:20.694646Z",
        "chart_type": "pie",
        "chart_sub_type": "basic_pie",
        "thumbnail_path": "piechart",
        "cloned_from": "piechart",
        "owner": "onecharts",
        "notes": "Some notes",
        "visibility": "private",
        "chart_options": {
            "emphasis": [
                {
                    "itemStyle": {
                        "shadowBlur": 10,
                        "shadowColor": "rgba(0, 0, 0, 0.5)",
                        "shadowOffsetX": 0,
                    }
                }
            ],
            "legend": [{"align": "auto", "bottom": "0%", "left": "45%", "right": "0%"}],
            "series": [{"radius": "70%", "seriesLayoutBy": "row", "type": "pie"}],
            "title": [
                {"left": "50%", "text": "Pie Chart", "textAlign": "center", "top": "0%"}
            ],
            "tooltip": [{"trigger": "item"}],
        },
    },
    "success": True,
}

Get Chart Data

oc.get_chart_data() method can be used to get the data of a chart. Example usage:

>>> res = oc.get_chart_data('KArrNpHzM-RLCo')
>>> print(res)
{
    "data": {
        "labels": ["Jan", "Feb", "Mar", "Apr"],
        "dataset": [
            {"name": "Jan", "value": 12},
            {"name": "Feb", "value": 16},
            {"name": "Mar", "value": 19},
            {"name": "Apr", "value": 22},
        ],
    },
    "success": True,
}

Update Chart Data

oc.update_chart_data() method can be used to get the data of a chart. Example usage:

>>> # The data should follow specific format.
>>> # Learn more about the format from here: https://onecharts.io/api#update_chart_data
>>> data = {
    'dataset': [
        {
            'name': "Jan",
            "value": 120
        }
    ]
}
>>> res = oc.update_chart_data('KArrNpHzM-RLCo', overwrite=False, data=data)
>>> print(res)
{
    'success': True
}

The above method updates an existing chart (corresponding to chart id: KArrNpHzM-RLCo) as shown below. image

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

OneCharts-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

OneCharts-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file OneCharts-0.1.0.tar.gz.

File metadata

  • Download URL: OneCharts-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for OneCharts-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4c7fd624168955d0d1e59bc08f13d281f3790f1342d997ef307f96f668dafd38
MD5 1b10a83556b26627b1c9a270925f2aa2
BLAKE2b-256 b08b9700dd9cc842e247cdd6323aa05fd2769f055c75ccb2c0123476597b319f

See more details on using hashes here.

File details

Details for the file OneCharts-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: OneCharts-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for OneCharts-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4732dbcc4af62e11a89df285447a01d4e42d2f7ae07a0356af74f481452103d
MD5 60e331892f7e0da3343889fb11daef4b
BLAKE2b-256 6c01187ab50bcaac48592d888945e03caf3c5787c1e47a8545b61f65301286c6

See more details on using hashes here.

Supported by

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