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.2.tar.gz (8.3 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.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: OneCharts-0.1.2.tar.gz
  • Upload date:
  • Size: 8.3 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.2.tar.gz
Algorithm Hash digest
SHA256 6e1c69739d96addf4dc9764c39547d3963d4ab533e87fe33459be9e9cbfe16e9
MD5 807fd088465052f2d573e6199ba7d007
BLAKE2b-256 5946636b24316b1de2d43c005b4de6657fa0efaf958bdde8342a77f957be8828

See more details on using hashes here.

File details

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

File metadata

  • Download URL: OneCharts-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 526fb762488a5d09e7d5829f50a055727a1f52193aeffc8e2d9da09367149f97
MD5 6958974779efb42bc11a22eee05e24f0
BLAKE2b-256 6edd0d40091e1c47d2b3a1ed033121914b98d6f7c76d19c19e648f2971e00075

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