diff --git a/packages/python/plotly/plotly/figure_factory/_gantt.py b/packages/python/plotly/plotly/figure_factory/_gantt.py index e8e5ec42d57..dda8177c3e0 100644 --- a/packages/python/plotly/plotly/figure_factory/_gantt.py +++ b/packages/python/plotly/plotly/figure_factory/_gantt.py @@ -412,7 +412,7 @@ def gantt_colorscale( ) layout["shapes"] = tasks - fig = dict(data=data, layout=layout) + fig = graph_objs.Figure(data=data, layout=layout) return fig @@ -567,7 +567,7 @@ def gantt_dict( ) layout["shapes"] = tasks - fig = dict(data=data, layout=layout) + fig = graph_objs.Figure(data=data, layout=layout) return fig @@ -582,7 +582,7 @@ def create_gantt( showgrid_x=False, showgrid_y=False, height=600, - width=900, + width=800, tasks=None, task_names=None, data=None, diff --git a/packages/python/plotly/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py b/packages/python/plotly/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py index 2f431ffb356..a792cee7f41 100644 --- a/packages/python/plotly/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py +++ b/packages/python/plotly/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py @@ -2090,7 +2090,7 @@ def test_df_dataframe_all_args(self): ], "showlegend": False, "title": {"text": "Gantt Chart"}, - "width": 900, + "width": 800, "xaxis": { "rangeselector": { "buttons": [ diff --git a/packages/python/plotly/plotly/tests/test_optional/test_tools/test_figure_factory.py b/packages/python/plotly/plotly/tests/test_optional/test_tools/test_figure_factory.py index fdf3808e7f9..1fd0b059664 100644 --- a/packages/python/plotly/plotly/tests/test_optional/test_tools/test_figure_factory.py +++ b/packages/python/plotly/plotly/tests/test_optional/test_tools/test_figure_factory.py @@ -1809,191 +1809,193 @@ def test_gannt_groups_and_descriptions(self): group_tasks=True, ) - exp_gantt_chart = { - "data": [ - { - "marker": {"color": "white"}, - "name": "", - "showlegend": False, - "text": "Task A - 1", - "x": ["2008-10-05", "2009-04-15"], - "y": [2, 2], - }, - { - "marker": {"color": "white"}, - "name": "", - "showlegend": False, - "text": "Task B - 1", - "x": ["2008-12-06", "2009-03-15"], - "y": [1, 1], - }, - { - "marker": {"color": "white"}, - "name": "", - "showlegend": False, - "text": "Task C - 1", - "x": ["2008-09-07", "2009-03-15"], - "y": [0, 0], - }, - { - "marker": {"color": "white"}, - "name": "", - "showlegend": False, - "text": "Task C - 2", - "x": ["2009-05-08", "2009-04-15"], - "y": [0, 0], - }, - { - "marker": {"color": "white"}, - "name": "", - "showlegend": False, - "text": "Task A - 2", - "x": ["2009-04-20", "2009-05-30"], - "y": [2, 2], - }, - { - "hoverinfo": "none", - "marker": {"color": "rgb(220, 0, 0)", "size": 1}, - "name": "TA", - "showlegend": True, - "x": ["2009-04-20", "2009-04-20"], - "y": [0, 0], - }, - { - "hoverinfo": "none", - "marker": {"color": "rgb(170, 14, 200)", "size": 1}, - "name": "TB", - "showlegend": True, - "x": ["2009-04-20", "2009-04-20"], - "y": [1, 1], - }, - { - "hoverinfo": "none", - "marker": {"color": "rgb(255, 230, 41)", "size": 1}, - "name": "TC", - "showlegend": True, - "x": ["2009-04-20", "2009-04-20"], - "y": [2, 2], - }, - ], - "layout": { - "height": 600, - "hovermode": "closest", - "shapes": [ + exp_gantt_chart = graph_objs.Figure( + { + "data": [ { - "fillcolor": "rgb(220, 0, 0)", - "line": {"width": 0}, - "opacity": 1, - "type": "rect", - "x0": "2008-10-05", - "x1": "2009-04-15", - "xref": "x", - "y0": 1.8, - "y1": 2.2, - "yref": "y", + "marker": {"color": "white"}, + "name": "", + "showlegend": False, + "text": "Task A - 1", + "x": ["2008-10-05", "2009-04-15"], + "y": [2, 2], }, { - "fillcolor": "rgb(170, 14, 200)", - "line": {"width": 0}, - "opacity": 1, - "type": "rect", - "x0": "2008-12-06", - "x1": "2009-03-15", - "xref": "x", - "y0": 0.8, - "y1": 1.2, - "yref": "y", + "marker": {"color": "white"}, + "name": "", + "showlegend": False, + "text": "Task B - 1", + "x": ["2008-12-06", "2009-03-15"], + "y": [1, 1], }, { - "fillcolor": "rgb(255, 230, 41)", - "line": {"width": 0}, - "opacity": 1, - "type": "rect", - "x0": "2008-09-07", - "x1": "2009-03-15", - "xref": "x", - "y0": -0.2, - "y1": 0.2, - "yref": "y", + "marker": {"color": "white"}, + "name": "", + "showlegend": False, + "text": "Task C - 1", + "x": ["2008-09-07", "2009-03-15"], + "y": [0, 0], }, { - "fillcolor": "rgb(255, 230, 41)", - "line": {"width": 0}, - "opacity": 1, - "type": "rect", - "x0": "2009-05-08", - "x1": "2009-04-15", - "xref": "x", - "y0": -0.2, - "y1": 0.2, - "yref": "y", + "marker": {"color": "white"}, + "name": "", + "showlegend": False, + "text": "Task C - 2", + "x": ["2009-05-08", "2009-04-15"], + "y": [0, 0], }, { - "fillcolor": "rgb(220, 0, 0)", - "line": {"width": 0}, - "opacity": 1, - "type": "rect", - "x0": "2009-04-20", - "x1": "2009-05-30", - "xref": "x", - "y0": 1.8, - "y1": 2.2, - "yref": "y", + "marker": {"color": "white"}, + "name": "", + "showlegend": False, + "text": "Task A - 2", + "x": ["2009-04-20", "2009-05-30"], + "y": [2, 2], + }, + { + "hoverinfo": "none", + "marker": {"color": "rgb(220, 0, 0)", "size": 1}, + "name": "TA", + "showlegend": True, + "x": ["2009-04-20", "2009-04-20"], + "y": [0, 0], + }, + { + "hoverinfo": "none", + "marker": {"color": "rgb(170, 14, 200)", "size": 1}, + "name": "TB", + "showlegend": True, + "x": ["2009-04-20", "2009-04-20"], + "y": [1, 1], + }, + { + "hoverinfo": "none", + "marker": {"color": "rgb(255, 230, 41)", "size": 1}, + "name": "TC", + "showlegend": True, + "x": ["2009-04-20", "2009-04-20"], + "y": [2, 2], }, ], - "showlegend": True, - "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"}, - ] + "layout": { + "height": 600, + "hovermode": "closest", + "shapes": [ + { + "fillcolor": "rgb(220, 0, 0)", + "line": {"width": 0}, + "opacity": 1, + "type": "rect", + "x0": "2008-10-05", + "x1": "2009-04-15", + "xref": "x", + "y0": 1.8, + "y1": 2.2, + "yref": "y", + }, + { + "fillcolor": "rgb(170, 14, 200)", + "line": {"width": 0}, + "opacity": 1, + "type": "rect", + "x0": "2008-12-06", + "x1": "2009-03-15", + "xref": "x", + "y0": 0.8, + "y1": 1.2, + "yref": "y", + }, + { + "fillcolor": "rgb(255, 230, 41)", + "line": {"width": 0}, + "opacity": 1, + "type": "rect", + "x0": "2008-09-07", + "x1": "2009-03-15", + "xref": "x", + "y0": -0.2, + "y1": 0.2, + "yref": "y", + }, + { + "fillcolor": "rgb(255, 230, 41)", + "line": {"width": 0}, + "opacity": 1, + "type": "rect", + "x0": "2009-05-08", + "x1": "2009-04-15", + "xref": "x", + "y0": -0.2, + "y1": 0.2, + "yref": "y", + }, + { + "fillcolor": "rgb(220, 0, 0)", + "line": {"width": 0}, + "opacity": 1, + "type": "rect", + "x0": "2009-04-20", + "x1": "2009-05-30", + "xref": "x", + "y0": 1.8, + "y1": 2.2, + "yref": "y", + }, + ], + "showlegend": True, + "title": "Gantt Chart", + "width": 800, + "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, 4], + "showgrid": False, + "ticktext": ["Task C", "Task B", "Task A"], + "tickvals": [0, 1, 2], + "zeroline": False, }, - "showgrid": False, - "type": "date", - "zeroline": False, - }, - "yaxis": { - "autorange": False, - "range": [-1, 4], - "showgrid": False, - "ticktext": ["Task C", "Task B", "Task A"], - "tickvals": [0, 1, 2], - "zeroline": False, }, - }, - } + } + ) self.assertEqual(test_gantt_chart["data"][0], exp_gantt_chart["data"][0]) @@ -2039,103 +2041,105 @@ def test_gantt_all_args(self): width=500, ) - exp_gantt_chart = { - "data": [ - { - "marker": {"color": "white"}, - "name": "", - "x": ["2010-01-01", "2011-02-02"], - "y": [0, 0], - }, - { - "marker": {"color": "white"}, - "name": "", - "x": ["2011-01-01", "2012-06-05"], - "y": [1, 1], - }, - ], - "layout": { - "height": 500, - "hovermode": "closest", - "shapes": [ + exp_gantt_chart = graph_objs.Figure( + { + "data": [ { - "fillcolor": "rgb(220.0, 220.0, 220.0)", - "line": {"width": 0}, - "opacity": 1, - "type": "rect", - "x0": "2010-01-01", - "x1": "2011-02-02", - "xref": "x", - "y0": -0.5, - "y1": 0.5, - "yref": "y", + "marker": {"color": "white"}, + "name": "", + "x": ["2010-01-01", "2011-02-02"], + "y": [0, 0], }, { - "fillcolor": "rgb(166.25, 167.5, 208.0)", - "line": {"width": 0}, - "opacity": 1, - "type": "rect", - "x0": "2011-01-01", - "x1": "2012-06-05", - "xref": "x", - "y0": 0.5, - "y1": 1.5, - "yref": "y", + "marker": {"color": "white"}, + "name": "", + "x": ["2011-01-01", "2012-06-05"], + "y": [1, 1], }, ], - "showlegend": False, - "title": "Title", - "width": 500, - "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"}, - ] + "layout": { + "height": 500, + "hovermode": "closest", + "shapes": [ + { + "fillcolor": "rgb(220.0, 220.0, 220.0)", + "line": {"width": 0}, + "opacity": 1, + "type": "rect", + "x0": "2010-01-01", + "x1": "2011-02-02", + "xref": "x", + "y0": -0.5, + "y1": 0.5, + "yref": "y", + }, + { + "fillcolor": "rgb(166.25, 167.5, 208.0)", + "line": {"width": 0}, + "opacity": 1, + "type": "rect", + "x0": "2011-01-01", + "x1": "2012-06-05", + "xref": "x", + "y0": 0.5, + "y1": 1.5, + "yref": "y", + }, + ], + "showlegend": False, + "title": "Title", + "width": 500, + "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": True, + "type": "date", + "zeroline": False, + }, + "yaxis": { + "autorange": False, + "range": [-1, 3], + "showgrid": True, + "ticktext": ["Run", "Fast"], + "tickvals": [0, 1], + "zeroline": False, }, - "showgrid": True, - "type": "date", - "zeroline": False, - }, - "yaxis": { - "autorange": False, - "range": [-1, 3], - "showgrid": True, - "ticktext": ["Run", "Fast"], - "tickvals": [0, 1], - "zeroline": False, }, - }, - } + } + ) self.assertEqual(test_gantt_chart["data"][0], exp_gantt_chart["data"][0]) diff --git a/packages/python/plotly/plotly/tests/test_orca/test_sg_scraper.py b/packages/python/plotly/plotly/tests/test_orca/test_sg_scraper.py index abb68af292f..837943ab45b 100644 --- a/packages/python/plotly/plotly/tests/test_orca/test_sg_scraper.py +++ b/packages/python/plotly/plotly/tests/test_orca/test_sg_scraper.py @@ -12,6 +12,9 @@ def setup(): plotly.io.orca.config.restore_defaults(reset_server=False) +here = os.path.dirname(os.path.abspath(__file__)) + + # Run setup before every test function in this file pytestmark = pytest.mark.usefixtures("setup") @@ -47,7 +50,7 @@ def test_scraper(): import tempfile tempdir = tempfile.mkdtemp() - gallery_conf = {"src_dir": tempdir, "examples_dirs": "plotly/tests/test_orca"} + gallery_conf = {"src_dir": tempdir, "examples_dirs": here} names = iter(["0", "1", "2"]) block_vars = {"image_path_iterator": names} execute_plotly_example()