From 80690482f3a16ca1164eb42c1d595fd160460457 Mon Sep 17 00:00:00 2001 From: mokaithered <34481098+mokaithered@users.noreply.github.com> Date: Tue, 12 Dec 2017 15:38:07 +0100 Subject: [PATCH 1/2] Clearing data list Hi all, I was playing around with gantt charts and experience that the legend (colorbar) needs to be scrolled to see my defined 'Tasks' at the very bottom (which is actually visible at the examples as well, above the 'Tasks' are hidden traces, which are even clickable). After checking through _gantt.py I identified following two rows, where the variable 'data' has many entries (why this is I could not tell precisely). However, clearing this data list showed only the 'Tasks' at the colorbar: new line 277: adding 'data=[]' to clear the filled list data to display only 'Tasks' and not many hidden trace entries. same applies for row 359 same apploes for row 517 Can you please verify and if you agree, push the change to the repo? Many thanks Cheers J --- plotly/figure_factory/_gantt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plotly/figure_factory/_gantt.py b/plotly/figure_factory/_gantt.py index e8c8a90e40f..43f5258957a 100644 --- a/plotly/figure_factory/_gantt.py +++ b/plotly/figure_factory/_gantt.py @@ -274,6 +274,7 @@ def gantt_colorscale(chart, colors, title, index_col, show_colorbar, bar_width, if show_colorbar is True: # generate dummy data for colorscale visibility + data=[] data.append( dict( x=[tasks[index]['x0'], tasks[index]['x0']], @@ -355,6 +356,7 @@ def gantt_colorscale(chart, colors, title, index_col, show_colorbar, bar_width, if show_colorbar is True: # generate dummy data to generate legend + data=[] showlegend = True for k, index_value in enumerate(index_vals): data.append( @@ -512,6 +514,7 @@ def gantt_dict(chart, colors, title, index_col, show_colorbar, bar_width, if show_colorbar is True: # generate dummy data to generate legend + data=[] showlegend = True for k, index_value in enumerate(index_vals): data.append( From 30aa836968e416d2c3a9fee81b0044746ad13790 Mon Sep 17 00:00:00 2001 From: mokaithered <34481098+mokaithered@users.noreply.github.com> Date: Thu, 14 Dec 2017 09:44:44 +0100 Subject: [PATCH 2/2] Update _gantt.py --- plotly/figure_factory/_gantt.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/plotly/figure_factory/_gantt.py b/plotly/figure_factory/_gantt.py index 43f5258957a..f12b281a7b8 100644 --- a/plotly/figure_factory/_gantt.py +++ b/plotly/figure_factory/_gantt.py @@ -274,8 +274,10 @@ def gantt_colorscale(chart, colors, title, index_col, show_colorbar, bar_width, if show_colorbar is True: # generate dummy data for colorscale visibility - data=[] - data.append( + datalisted = data + newentries = [] + + newentries.append( dict( x=[tasks[index]['x0'], tasks[index]['x0']], y=[index, index], @@ -287,6 +289,7 @@ def gantt_colorscale(chart, colors, title, index_col, show_colorbar, bar_width, 'cmin': 0} ) ) + data = newentries + datalisted if isinstance(chart[0][index_col], str): index_vals = [] @@ -356,10 +359,12 @@ def gantt_colorscale(chart, colors, title, index_col, show_colorbar, bar_width, if show_colorbar is True: # generate dummy data to generate legend - data=[] + datalisted = data + newentries = [] + showlegend = True for k, index_value in enumerate(index_vals): - data.append( + newentries.append( dict( x=[tasks[index]['x0'], tasks[index]['x0']], y=[k, k], @@ -372,6 +377,7 @@ def gantt_colorscale(chart, colors, title, index_col, show_colorbar, bar_width, ) ) ) + data = newentries + datalisted layout = dict( title=title, @@ -514,10 +520,12 @@ def gantt_dict(chart, colors, title, index_col, show_colorbar, bar_width, if show_colorbar is True: # generate dummy data to generate legend - data=[] + datalisted = data + newentries = [] + showlegend = True for k, index_value in enumerate(index_vals): - data.append( + newentries.append( dict( x=[tasks[index]['x0'], tasks[index]['x0']], y=[k, k], @@ -530,6 +538,7 @@ def gantt_dict(chart, colors, title, index_col, show_colorbar, bar_width, ) ) ) + data = newentries + datalisted layout = dict( title=title,