Skip to content

Commit

Permalink
Added more formating for Plotly
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed Mar 22, 2021
1 parent 13302f3 commit 86f0907
Show file tree
Hide file tree
Showing 5 changed files with 482 additions and 249 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
recursive-include chartpy *

global-exclude *.py[cod] __pycache__ *.so *.pdf
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ In chartpy/examples you will find several demos

# Coding log

* 22 Mar 2020
* Added more formatting for Plotly (eg. text font etc.)
* 02 Dec 2020
* Added animation for Plotly
* 08 Jun 2020
Expand Down
35 changes: 18 additions & 17 deletions chartpy/chart.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import division

__author__ = 'saeedamen' # Saeed Amen
__author__ = 'saeedamen' # Saeed Amen

#
# Copyright 2016 Cuemacro
Expand All @@ -14,23 +14,19 @@
# See the License for the specific language governing permissions and limitations under the License.
#

"""
Chart
Creates chart using several underlying plotting libraries (Matplotlib, Plotly and Bokeh) using the same interface
"""

from chartpy.twitter import Twitter
from chartpy.chartconstants import ChartConstants
from chartpy.style import Style
from chartpy.engine import EngineMatplotlib, EngineBokeh, EngineBqplot, EnginePlotly, EngineVisPy

import pandas


class Chart(object):
"""Creates chart using several underlying plotting libraries (Matplotlib, Plotly and Bokeh) using the same interface
"""

def __init__(self, df = None, engine = None, chart_type = None, style = None):
def __init__(self, df=None, engine=None, chart_type=None, style=None):

self.df = None
self.engine = ChartConstants().chartfactory_default_engine
Expand All @@ -51,7 +47,7 @@ def __init__(self, df = None, engine = None, chart_type = None, style = None):
##### bar (Bokeh, Matplotlib, Plotly)
##### stacked (Bokeh, Matplotlib, Plotly)
##### surface (Plotly)
def plot(self, df = None, engine = None, chart_type = None, style = None, twitter_msg = None, twitter_on = False):
def plot(self, df=None, engine=None, chart_type=None, style=None, twitter_msg=None, twitter_on=False):

if style is None: style = self.style
if df is None: df = self.df
Expand Down Expand Up @@ -98,12 +94,18 @@ def plot(self, df = None, engine = None, chart_type = None, style = None, twitte

def get_engine(self, engine):

if engine is None: return self.get_engine(self.engine)
elif engine == 'matplotlib': return EngineMatplotlib()
elif engine == 'bokeh': return EngineBokeh()
elif engine == 'bqplot': return EngineBqplot()
elif engine == 'vispy': return EngineVisPy()
elif engine == 'plotly': return EnginePlotly()
if engine is None:
return self.get_engine(self.engine)
elif engine == 'matplotlib':
return EngineMatplotlib()
elif engine == 'bokeh':
return EngineBokeh()
elif engine == 'bqplot':
return EngineBqplot()
elif engine == 'vispy':
return EngineVisPy()
elif engine == 'plotly':
return EnginePlotly()

return None

Expand All @@ -112,4 +114,3 @@ def _iplot(self, data_frame, engine=None, chart_type=None, style=None):
return Chart.get_engine(engine).plot_chart(data_frame, style, chart_type)

#######################################################################################################################

Loading

0 comments on commit 86f0907

Please sign in to comment.