jeromeku / dash-chartjs

A Plotly-Dash component for Chart.js.

Home Page:https://pypi.org/project/dash-chartjs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dash Chartjs Component

Chart.js is one the most popular javascript charting library. Dash Chartjs Component is a Dash component library that renders ChartJs React component inside Dash App.

Installation

pip install dash-chartjs

Basic Usage

from dash import dash,html
import pandas as pd
from dash_chartjs import ChartJs

app = dash.Dash(__name__,meta_tags=[{"name": "viewport", "content": "width=device-width, initial-scale=1"}])

df = pd.read_csv('https://raw.githubusercontent.com/JetBlack101/visitors-to-georgia-ts-analysis/main/Data/VisitorsToGeorgia_2011-2019.csv')

df['Date'] = pd.to_datetime(df['Date'])

x = df['Date']
y = df['Visitors']

data = {
    'labels': x,
    'datasets': [{
        'label': 'Visitors to Georgia',
        'data': y,
        'fill':'false',
        'borderColor': 'rgb(75, 192, 192)',
        'tension': 0.1
    }]
}
options = {
    'scales': {
        'x': {
            'type':'time'
        }
    },
    'plugins':{
        'zoom':{
            'zoom':{
                'wheel':{
                    'enabled': True
                },
            'mode':'xy'
            }
        }
    } 
}


app.layout = html.Div(
    [
        ChartJs(type='line',data=data,options=options)
    ]
)

if __name__ == '__main__':
    app.run_server(debug=False)

Demo

Dash_ChartJS.mp4

About

A Plotly-Dash component for Chart.js.

https://pypi.org/project/dash-chartjs/

License:MIT License


Languages

Language:Python 54.8%Language:JavaScript 32.3%Language:Julia 6.5%Language:R 5.0%Language:HTML 0.7%Language:CSS 0.6%