Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/wily/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,11 @@ def diff(ctx, files, metrics, all, detail, revision, wrap):
default=False,
help=_("Aggregate if path is directory"),
)
@click.option(
"-f", "--format", default="html", help=_("Format to output, can be html or png")
) # Supported formats: html, png, jpg, webp, svg or pdf
@click.pass_context
def graph(ctx, path, metrics, output, x_axis, changes, aggregate):
def graph(ctx, path, metrics, output, x_axis, changes, aggregate, format):
"""Output report to specified HTML path, e.g. reports/out.html."""
config = ctx.obj["CONFIG"]

Expand All @@ -434,6 +437,7 @@ def graph(ctx, path, metrics, output, x_axis, changes, aggregate):
x_axis=x_axis,
changes=changes,
aggregate=aggregate,
format=format,
)


Expand Down
33 changes: 20 additions & 13 deletions src/wily/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def graph(
changes=True,
text=False,
aggregate=False,
format="html",
):
"""
Graph information about the cache and runtime.
Expand Down Expand Up @@ -153,17 +154,23 @@ def graph(
filename = output
auto_open = False
else:
filename = "wily-report.html"
filename = f"wily-report.{format}"
auto_open = True
plotly.offline.plot(
{
"data": data,
"layout": go.Layout(
title=title,
xaxis={"title": x_axis},
yaxis={"title": y_metric.description},
),
},
auto_open=auto_open,
filename=filename,
)
if format == "html":
plotly.offline.plot(
{
"data": data,
"layout": go.Layout(
title=title,
xaxis={"title": x_axis},
yaxis={"title": y_metric.description},
),
},
auto_open=auto_open,
filename=filename,
)
else:
fig = go.Figure()
for trace in data:
fig.add_trace(trace)
fig.write_image(filename)