Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

return gantt and dendrogram figure #811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 4, 2017
Merged
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
4 changes: 3 additions & 1 deletion 4 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.13] - UNRELEASED
## [2.0.13] - 2017-08-04
### Updated
- Updated `plotly.min.js` to version 1.29.1 for `plotly.offline`.
- See [the plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#1291----2017-07-25) for additional information regarding the updates.
- `figure_factory.create_gantt` and `figure_factory.create_dendrogram` now return a Plotly figure (consistent with other figure factory chart types).
- `offline.init_notebook_mode()` is now optional when using `offline.iplot()`.

## [2.0.12] - 2017-06-30
### Updated
Expand Down
3 changes: 1 addition & 2 deletions 3 plotly/figure_factory/_dendrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ def create_dendrogram(X, orientation="bottom", labels=None,
dendrogram = _Dendrogram(X, orientation, labels, colorscale,
distfun=distfun, linkagefun=linkagefun)

return {'layout': dendrogram.layout,
'data': dendrogram.data}
return graph_objs.Figure(data=dendrogram.data, layout=dendrogram.layout)


class _Dendrogram(object):
Expand Down
3 changes: 2 additions & 1 deletion 3 plotly/figure_factory/_gantt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from plotly import exceptions, optional_imports
from plotly.figure_factory import utils
from plotly.graph_objs import graph_objs

pd = optional_imports.get_module('pandas')

Expand Down Expand Up @@ -170,7 +171,7 @@ def gantt(chart, colors, title, bar_width, showgrid_x, showgrid_y, height,
)
layout['shapes'] = tasks

fig = dict(data=data, layout=layout)
fig = graph_objs.Figure(data=data, layout=layout)
return fig


Expand Down
118 changes: 65 additions & 53 deletions 118 plotly/tests/test_optional/test_figure_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,59 +1273,71 @@ def test_df_dataframe_all_args(self):

test_gantt_chart = ff.create_gantt(df)

exp_gantt_chart = {
'data': [{'marker': {'color': 'white'},
'name': '',
'x': ['2009-01-01', '2009-02-30'],
'y': [0, 0]}],
'layout': {'height': 600,
'hovermode': 'closest',
'shapes': [{'opacity': 1,
'y1': 0.2,
'xref': 'x',
'fillcolor': 'rgb(31, 119, 180)',
'yref': 'y',
'y0': -0.2,
'x0': '2009-01-01',
'x1': '2009-02-30',
'type': 'rect',
'line': {'width': 0}},
{'opacity': 1,
'y1': 1.2,
'xref': 'x',
'fillcolor': 'rgb(255, 127, 14)',
'yref': 'y',
'y0': 0.8,
'x0': '2009-03-05',
'x1': '2009-04-15',
'type': 'rect',
'line': {'width': 0}}],
'showlegend': False,
'title': 'Gantt Chart',
'width': 900,
'xaxis': {'rangeselector': {'buttons': [
{'count': 7, 'label': '1w',
'step': 'day', 'stepmode': 'backward'},
{'count': 1, 'label': '1m',
'step': 'month', 'stepmode': 'backward'},
{'count': 6, 'label': '6m',
'step': 'month', 'stepmode': 'backward'},
{'count': 1, 'label': 'YTD',
'step': 'year', 'stepmode': 'todate'},
{'count': 1, 'label': '1y',
'step': 'year', 'stepmode': 'backward'},
{'step': 'all'}
]},
'showgrid': False,
'type': 'date',
'zeroline': False},
'yaxis': {'autorange': False,
'range': [-1, 3],
'showgrid': False,
'ticktext': ['Job A', 'Job B'],
'tickvals': [0, 1],
'zeroline': False}}
}
exp_gantt_chart = {'data': [{'marker': {'color': 'white'},
'name': '',
'type': 'scatter',
'x': ['2009-01-01', '2009-02-30'],
'y': [0, 0]},
{'marker': {'color': 'white'},
'name': '',
'type': 'scatter',
'x': ['2009-03-05', '2009-04-15'],
'y': [1, 1]}],
'layout': {'height': 600,
'hovermode': 'closest',
'shapes': [{'fillcolor': 'rgb(31, 119, 180)',
'line': {'width': 0},
'opacity': 1,
'type': 'rect',
'x0': '2009-01-01',
'x1': '2009-02-30',
'xref': 'x',
'y0': -0.2,
'y1': 0.2,
'yref': 'y'},
{'fillcolor': 'rgb(255, 127, 14)',
'line': {'width': 0},
'opacity': 1,
'type': 'rect',
'x0': '2009-03-05',
'x1': '2009-04-15',
'xref': 'x',
'y0': 0.8,
'y1': 1.2,
'yref': 'y'}],
'showlegend': False,
'title': 'Gantt Chart',
'width': 900,
'xaxis': {'rangeselector': {'buttons': [{'count': 7,
'label': '1w',
'step': 'day',
'stepmode': 'backward'},
{'count': 1,
'label': '1m',
'step': 'month',
'stepmode': 'backward'},
{'count': 6,
'label': '6m',
'step': 'month',
'stepmode': 'backward'},
{'count': 1,
'label': 'YTD',
'step': 'year',
'stepmode': 'todate'},
{'count': 1,
'label': '1y',
'step': 'year',
'stepmode': 'backward'},
{'step': 'all'}]},
'showgrid': False,
'type': 'date',
'zeroline': False},
'yaxis': {'autorange': False,
'range': [-1, 3],
'showgrid': False,
'ticktext': ['Job A', 'Job B'],
'tickvals': [0, 1],
'zeroline': False}}}

self.assertEqual(test_gantt_chart['data'][0],
exp_gantt_chart['data'][0])
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.