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

Commit ec54d9d

Browse filesBrowse files
authored
Merge pull request plotly#811 from plotly/return_figure
return gantt and dendrogram figure
2 parents 4d96cff + adbd900 commit ec54d9d
Copy full SHA for ec54d9d

File tree

Expand file treeCollapse file tree

4 files changed

+71
-57
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+71
-57
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [2.0.13] - UNRELEASED
5+
## [2.0.13] - 2017-08-04
66
### Updated
77
- Updated `plotly.min.js` to version 1.29.1 for `plotly.offline`.
88
- 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.
9+
- `figure_factory.create_gantt` and `figure_factory.create_dendrogram` now return a Plotly figure (consistent with other figure factory chart types).
10+
- `offline.init_notebook_mode()` is now optional when using `offline.iplot()`.
911

1012
## [2.0.12] - 2017-06-30
1113
### Updated

‎plotly/figure_factory/_dendrogram.py

Copy file name to clipboardExpand all lines: plotly/figure_factory/_dendrogram.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ def create_dendrogram(X, orientation="bottom", labels=None,
8787
dendrogram = _Dendrogram(X, orientation, labels, colorscale,
8888
distfun=distfun, linkagefun=linkagefun)
8989

90-
return {'layout': dendrogram.layout,
91-
'data': dendrogram.data}
90+
return graph_objs.Figure(data=dendrogram.data, layout=dendrogram.layout)
9291

9392

9493
class _Dendrogram(object):

‎plotly/figure_factory/_gantt.py

Copy file name to clipboardExpand all lines: plotly/figure_factory/_gantt.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from plotly import exceptions, optional_imports
66
from plotly.figure_factory import utils
7+
from plotly.graph_objs import graph_objs
78

89
pd = optional_imports.get_module('pandas')
910

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

173-
fig = dict(data=data, layout=layout)
174+
fig = graph_objs.Figure(data=data, layout=layout)
174175
return fig
175176

176177

‎plotly/tests/test_optional/test_figure_factory.py

Copy file name to clipboardExpand all lines: plotly/tests/test_optional/test_figure_factory.py
+65-53Lines changed: 65 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,59 +1273,71 @@ def test_df_dataframe_all_args(self):
12731273

12741274
test_gantt_chart = ff.create_gantt(df)
12751275

1276-
exp_gantt_chart = {
1277-
'data': [{'marker': {'color': 'white'},
1278-
'name': '',
1279-
'x': ['2009-01-01', '2009-02-30'],
1280-
'y': [0, 0]}],
1281-
'layout': {'height': 600,
1282-
'hovermode': 'closest',
1283-
'shapes': [{'opacity': 1,
1284-
'y1': 0.2,
1285-
'xref': 'x',
1286-
'fillcolor': 'rgb(31, 119, 180)',
1287-
'yref': 'y',
1288-
'y0': -0.2,
1289-
'x0': '2009-01-01',
1290-
'x1': '2009-02-30',
1291-
'type': 'rect',
1292-
'line': {'width': 0}},
1293-
{'opacity': 1,
1294-
'y1': 1.2,
1295-
'xref': 'x',
1296-
'fillcolor': 'rgb(255, 127, 14)',
1297-
'yref': 'y',
1298-
'y0': 0.8,
1299-
'x0': '2009-03-05',
1300-
'x1': '2009-04-15',
1301-
'type': 'rect',
1302-
'line': {'width': 0}}],
1303-
'showlegend': False,
1304-
'title': 'Gantt Chart',
1305-
'width': 900,
1306-
'xaxis': {'rangeselector': {'buttons': [
1307-
{'count': 7, 'label': '1w',
1308-
'step': 'day', 'stepmode': 'backward'},
1309-
{'count': 1, 'label': '1m',
1310-
'step': 'month', 'stepmode': 'backward'},
1311-
{'count': 6, 'label': '6m',
1312-
'step': 'month', 'stepmode': 'backward'},
1313-
{'count': 1, 'label': 'YTD',
1314-
'step': 'year', 'stepmode': 'todate'},
1315-
{'count': 1, 'label': '1y',
1316-
'step': 'year', 'stepmode': 'backward'},
1317-
{'step': 'all'}
1318-
]},
1319-
'showgrid': False,
1320-
'type': 'date',
1321-
'zeroline': False},
1322-
'yaxis': {'autorange': False,
1323-
'range': [-1, 3],
1324-
'showgrid': False,
1325-
'ticktext': ['Job A', 'Job B'],
1326-
'tickvals': [0, 1],
1327-
'zeroline': False}}
1328-
}
1276+
exp_gantt_chart = {'data': [{'marker': {'color': 'white'},
1277+
'name': '',
1278+
'type': 'scatter',
1279+
'x': ['2009-01-01', '2009-02-30'],
1280+
'y': [0, 0]},
1281+
{'marker': {'color': 'white'},
1282+
'name': '',
1283+
'type': 'scatter',
1284+
'x': ['2009-03-05', '2009-04-15'],
1285+
'y': [1, 1]}],
1286+
'layout': {'height': 600,
1287+
'hovermode': 'closest',
1288+
'shapes': [{'fillcolor': 'rgb(31, 119, 180)',
1289+
'line': {'width': 0},
1290+
'opacity': 1,
1291+
'type': 'rect',
1292+
'x0': '2009-01-01',
1293+
'x1': '2009-02-30',
1294+
'xref': 'x',
1295+
'y0': -0.2,
1296+
'y1': 0.2,
1297+
'yref': 'y'},
1298+
{'fillcolor': 'rgb(255, 127, 14)',
1299+
'line': {'width': 0},
1300+
'opacity': 1,
1301+
'type': 'rect',
1302+
'x0': '2009-03-05',
1303+
'x1': '2009-04-15',
1304+
'xref': 'x',
1305+
'y0': 0.8,
1306+
'y1': 1.2,
1307+
'yref': 'y'}],
1308+
'showlegend': False,
1309+
'title': 'Gantt Chart',
1310+
'width': 900,
1311+
'xaxis': {'rangeselector': {'buttons': [{'count': 7,
1312+
'label': '1w',
1313+
'step': 'day',
1314+
'stepmode': 'backward'},
1315+
{'count': 1,
1316+
'label': '1m',
1317+
'step': 'month',
1318+
'stepmode': 'backward'},
1319+
{'count': 6,
1320+
'label': '6m',
1321+
'step': 'month',
1322+
'stepmode': 'backward'},
1323+
{'count': 1,
1324+
'label': 'YTD',
1325+
'step': 'year',
1326+
'stepmode': 'todate'},
1327+
{'count': 1,
1328+
'label': '1y',
1329+
'step': 'year',
1330+
'stepmode': 'backward'},
1331+
{'step': 'all'}]},
1332+
'showgrid': False,
1333+
'type': 'date',
1334+
'zeroline': False},
1335+
'yaxis': {'autorange': False,
1336+
'range': [-1, 3],
1337+
'showgrid': False,
1338+
'ticktext': ['Job A', 'Job B'],
1339+
'tickvals': [0, 1],
1340+
'zeroline': False}}}
13291341

13301342
self.assertEqual(test_gantt_chart['data'][0],
13311343
exp_gantt_chart['data'][0])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.