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.1.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.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: OneCharts-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 767fdbce411794b02db36797c2932448befa5e939518ae81809e3e24812f26d7
MD5 0fadc46d5a01a25bc5a8281c9453729e
BLAKE2b-256 9bddb3d2adc4f3242889feb853f0d319461393df48a8c7034b8c0789e711531d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: OneCharts-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d71e0984c702d1472fb7ff6183e6565acd48df608b4db0b55f9218982975977
MD5 f831e9f286fe9daa60260ae0d391d566
BLAKE2b-256 a13d9d3bfd052f1f54cdcb374f5feafe3ac365b0d394c95020162832c40046ae

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