Skip to content

Commit

Permalink
New version
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed Apr 10, 2024
1 parent fe6664a commit cc7144d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 66 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ In chartpy/examples you will find several demos

# Recent Release Notes

* 10 Apr 2024 - v0.1.14
* 12 Oct 2023 - v0.1.13
* 07 Jul 2022 - v0.1.12
* 06 Oct 2021 - v0.1.11
Expand All @@ -172,6 +173,8 @@ In chartpy/examples you will find several demos

# Coding log

* 10 Apr 2024
* Added option to create Plotly charts without JavaScript embedding (smaller file sizes)
* 02 Nov 2022
* Added data parameter for creation of Dash table
* 01 Sep 2022
Expand Down
113 changes: 52 additions & 61 deletions chartpy/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,67 +1733,54 @@ def plot_chart(self, data_frame, style, chart_type):
"%Y-%m-%d"), 'color': 'rgba(30,30,30,0.3)',
'fill': True, 'opacity': .4}

# Sometimes Plotly has issues generating figures in dash, so if fails first, try again
while m < 10:

if True:
if vspan is None:
fig = data_frame.iplot(kind=chart_type_ord,
title=title,
xTitle=style.x_title,
yTitle=style.y_title,
x=x, y=y, z=z,
subplots=False,
sharing=style.plotly_sharing,
mode=mode,
secondary_y=y_axis_2_series,
size=marker_size,
theme=plotly_theme,
colorscale='dflt',
bestfit=style.line_of_best_fit,
legend=style.display_legend,
width=style.linewidth,
color=color_spec1,
dimensions=(
style.width * abs(
style.scale_factor) * scale,
style.height * abs(
style.scale_factor) * scale),
asFigure=True)
else:
fig = data_frame.iplot(kind=chart_type_ord,
title=title,
xTitle=style.x_title,
yTitle=style.y_title,
x=x, y=y, z=z,
subplots=False,
sharing=style.plotly_sharing,
mode=mode,
secondary_y=y_axis_2_series,
size=marker_size,
theme=plotly_theme,
colorscale='dflt',
bestfit=style.line_of_best_fit,
legend=style.display_legend,
width=style.linewidth,
color=color_spec1,
dimensions=(
style.width * abs(
style.scale_factor) * scale,
style.height * abs(
style.scale_factor) * scale),
vspan=vspan,
asFigure=True)

m = 10;
break
# except Exception as e:
print("Will attempt to re-render: " + str(e))

import time
time.sleep(0.3)

m = m + 1
if True:
if vspan is None:
fig = data_frame.iplot(kind=chart_type_ord,
title=title,
xTitle=style.x_title,
yTitle=style.y_title,
x=x, y=y, z=z,
subplots=False,
sharing=style.plotly_sharing,
mode=mode,
secondary_y=y_axis_2_series,
size=marker_size,
theme=plotly_theme,
colorscale='dflt',
bestfit=style.line_of_best_fit,
legend=style.display_legend,
width=style.linewidth,
color=color_spec1,
dimensions=(
style.width * abs(
style.scale_factor) * scale,
style.height * abs(
style.scale_factor) * scale),
asFigure=True)
else:
fig = data_frame.iplot(kind=chart_type_ord,
title=title,
xTitle=style.x_title,
yTitle=style.y_title,
x=x, y=y, z=z,
subplots=False,
sharing=style.plotly_sharing,
mode=mode,
secondary_y=y_axis_2_series,
size=marker_size,
theme=plotly_theme,
colorscale='dflt',
bestfit=style.line_of_best_fit,
legend=style.display_legend,
width=style.linewidth,
color=color_spec1,
dimensions=(
style.width * abs(
style.scale_factor) * scale,
style.height * abs(
style.scale_factor) * scale),
vspan=vspan,
asFigure=True)

# For lines set the property of connectgaps (cannot specify directly in cufflinks)
if full_line:
Expand Down Expand Up @@ -2321,6 +2308,10 @@ def publish_plot(self, fig, style):
elif style.plotly_plot_mode == 'offline_html':
py_offline.plot(fig, filename=style.html_file_output,
auto_open=not (style.silent_display))
elif style.plotly_plot_mode == 'offline_html_exc_embed_js':
py_offline.plot(fig, filename=style.html_file_output,
include_plotlyjs="cdn",
auto_open=not(style.silent_display))
elif style.plotly_plot_mode == 'offline_png':
# Needs orca
fig.write_image(style.file_output)
Expand Down
8 changes: 4 additions & 4 deletions chartpy_examples/canvas_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
df.columns = ["Real QoQ"]

# Chart object is initialised with the dataframe and our chart style
chart_bokeh = Chart(df=df, chart_type='line', engine='bokeh',
style=Style(title="US GDP", source="Quandl/Fred", scale_factor=-2, width=500, height=300, silent_display=True))
# chart_bokeh = Chart(df=df, chart_type='line', engine='bokeh',
# style=Style(title="US GDP", source="Quandl/Fred", scale_factor=-2, width=500, height=300, silent_display=True))

chart_plotly = Chart(df=df, chart_type='line', engine='plotly',
style=Style(title="US GDP", source="Quandl/Fred", scale_factor=-2, width=500, height=300, silent_display=True))
Expand All @@ -53,11 +53,11 @@
text = "A demo of chartpy canvas!!"

# using plain template
canvas = Canvas([[text, chart_bokeh], [chart_plotly, df.tail(n=5)]])
canvas = Canvas([[text, chart_plotly], [chart_plotly, df.tail(n=5)]])

canvas.generate_canvas(silent_display=False, canvas_plotter='plain')

# using the Keen template (needs static folder in the same place as final HTML file)
canvas = Canvas([[chart_bokeh, chart_plotly], [chart_plotly, chart_matplotlib]])
canvas = Canvas([[chart_plotly, chart_plotly], [chart_plotly, chart_matplotlib]])

canvas.generate_canvas(silent_display=False, canvas_plotter='keen')
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
also works well with Dash, plotly's web server library built on top of Flask."""

setup(name='chartpy',
version='0.1.13',
version='0.1.14',
description='chartpy creates a simple easy to use API to plot in a number of great Python chart libraries',
author='Saeed Amen',
author_email='[email protected]',
Expand Down

0 comments on commit cc7144d

Please sign in to comment.