plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
15.98k stars 2.53k forks source link

Sankey chart is not displayed in rmd html output when partial_bundle() is used for another chart. #3724

Closed Bennybeams closed 2 months ago

Bennybeams commented 2 years ago

Hi all,

I'm creating a Rmd document which gather several plotly objects. I have a Sankey chart and other basic line charts. I export my rmd with rmarkdown::render('rmd/test.rmd', output_file = "../themes/emploi.html") to use it on a web site.

To have the html the lighter possible I'm using partial_bundle() command each time I load a plotly object. I know that this is not applicable to every chart styles, and for the snkey chart in particular.

However, when I use partial_bundle on another plot in the same markdown, the sankey chart is not working anymore.

Function partial_bundle() seems to be applied unsuccessfully on sankey chart where it should not if it's applied on another chart.

To reproduce the issue :

Sanker chart : structure(list(x = structure(list(visdat = list(42033236b21= function () plotlyVisDat), cur_data = "42033236b21", attrs = list(42033236b21= list( orientation = "h", valueformat = ".0f", customdata = c("108 600", "76 700", "98 300", "10 300", "17 700", "59 000", "400", "14 600", "2 700"), node = list(label = c("Actifs", "Inactifs", "En emploi", "Chômeurs", "Halo du chômage", "Hors halo du chômage", "Recherche un emploi sans être disponible", "Ne recherche pas d'emploi mais est disponible", "Ne recherche pas d'emploi et n'est pas disponible"), color = c("#56B4E9", "#B359B4", "#009FA4", "#345687", "#CC79A7", "#D55E00", "#999999", "#FF9D37", "#FF0000"), pad = 15, thickness = 20, hovertemplate = "Valeur", line = list(color = "black", width = 0.5)), link = list( source = c(0, 0, 1, 1, 4, 4, 4), target = c(2, 3, 4, 5, 6, 7, 8), value = c(98300L, 10300L, 17700L, 59000L, 400L, 14600L, 2700L), hoverinfo = "none"), alpha_stroke = 1, sizes = c(10, 100), spans = c(1, 20), type = "sankey")), layout = list(width = NULL, height = NULL, margin = list( b = 40, l = 60, t = 25, r = 10)), source = "A", config = list( modeBarButtonsToAdd = c("hoverclosest", "hovercompare" ), showSendToCloud = FALSE, locale = "fr"), layoutAttrs = list( 42033236b21= list(font = list(size = 10)))), TOJSON_FUNC = function (x, ...) { jsonlite::toJSON(x, digits = 50, auto_unbox = TRUE, force = TRUE, null = "null", na = "null", time_format = "%Y-%m-%d %H:%M:%OS6", ...) }), width = NULL, height = NULL, sizingPolicy = list(defaultWidth = "100%", defaultHeight = 400, padding = 0, viewer = list(defaultWidth = NULL, defaultHeight = NULL, padding = NULL, fill = TRUE, suppress = FALSE, paneHeight = NULL), browser = list(defaultWidth = NULL, defaultHeight = NULL, padding = NULL, fill = TRUE, external = FALSE), knitr = list(defaultWidth = NULL, defaultHeight = NULL, figure = TRUE)), dependencies = list(structure(list(name = "typedarray", version = "0.1", src = list(file = "htmlwidgets/lib/typedarray"), meta = NULL, script = "typedarray.min.js", stylesheet = NULL, head = NULL, attachment = NULL, package = "plotly", all_files = FALSE), class = "html_dependency"), structure(list(name = "jquery", version = "3.5.1", src = list( file = "lib/jquery"), meta = NULL, script = "jquery.min.js", stylesheet = NULL, head = NULL, attachment = NULL, package = "crosstalk", all_files = TRUE), class = "html_dependency"), structure(list(name = "crosstalk", version = "1.2.0", src = list(file = "www"), meta = NULL, script = "js/crosstalk.min.js", stylesheet = "css/crosstalk.min.css", head = NULL, attachment = NULL, package = "crosstalk", all_files = TRUE), class = "html_dependency"), structure(list(name = "plotly-htmlwidgets-css", version = "2.5.1", src = list(file = "htmlwidgets/lib/plotlyjs"), meta = NULL, script = NULL, stylesheet = "plotly-htmlwidgets.css", head = NULL, attachment = NULL, package = "plotly", all_files = FALSE), class = "html_dependency"), structure(list( name = "plotly-main", version = "2.5.1", src = list( file = "htmlwidgets/lib/plotlyjs"), meta = NULL, script = "plotly-latest.min.js", stylesheet = NULL, head = NULL, attachment = NULL, package = "plotly", all_files = FALSE), class = "html_dependency"), structure(list( name = "plotly-locale-fr", version = "2.5.1", src = list( file = "htmlwidgets/lib/plotlyjs/locales"), meta = NULL, script = "fr.js", stylesheet = NULL, head = NULL, attachment = NULL, package = "plotly", all_files = FALSE), class = "html_dependency"), structure(list(name = "plotly-locale-fr", version = "2.5.1", src = list(file = "htmlwidgets/lib/plotlyjs/locales"), meta = NULL, script = "fr.js", stylesheet = NULL, head = NULL, attachment = NULL, package = "plotly", all_files = FALSE), class = "html_dependency")), elementId = NULL, preRenderHook = function (p, registerFrames = TRUE) { UseMethod("plotly_build") }, jsHooks = list()), class = c("plotly", "htmlwidget"), package = "plotly")

Basic line chart : structure(list(x = structure(list(visdat = list(42076df6c44= function () plotlyVisDat), cur_data = "42076df6c44", attrs = list(42076df6c44= list( x = ~Date, y = ~Commerce, mode = "none", line = list(color = "#345687"), name = "Commerce", alpha_stroke = 1, sizes = c(10, 100), spans = c(1, 20), type = "scatter"),42076df6c44= list( x = ~Date, y = ~Construction, mode = "none", line = list( color = "#56B4E9"), name = "Construction", alpha_stroke = 1, sizes = c(10, 100), spans = c(1, 20), type = "scatter", inherit = TRUE), 42076df6c44= list(x = ~Date, y = ~Hotellerie, mode = "none", line = list(color = "#CC79A7"), name = "Hôtellerie-Restauration", alpha_stroke = 1, sizes = c(10, 100), spans = c(1, 20 ), type = "scatter", inherit = TRUE),42076df6c44= list( x = ~Date, y = ~Industrie, mode = "none", line = list( color = "#B359B4"), name = "Industrie", alpha_stroke = 1, sizes = c(10, 100), spans = c(1, 20), type = "scatter", inherit = TRUE),42076df6c44= list(x = ~Date, y = ~Marchand, mode = "none", line = list(color = "#D55E00"), name = "Secteur Marchand", alpha_stroke = 1, sizes = c(10, 100), spans = c(1, 20 ), type = "scatter", inherit = TRUE),42076df6c44= list( x = ~Date, y = ~Services, mode = "none", line = list( color = "#FF9D37"), name = "Services", alpha_stroke = 1, sizes = c(10, 100), spans = c(1, 20), type = "scatter", inherit = TRUE)), layout = list(width = NULL, height = NULL, margin = list(b = 40, l = 60, t = 25, r = 10)), source = "A", config = list(modeBarButtonsToAdd = c("hoverclosest", "hovercompare" ), showSendToCloud = FALSE), layoutAttrs = list(42076df6c44= list( yaxis = list(tickformat = ".0f")),42076df6c44= list( yaxis = list(title = "", zeroline = TRUE, showline = TRUE, showticklabels = TRUE, showgrid = TRUE), xaxis = list( title = "", zeroline = TRUE, showline = TRUE)))), TOJSON_FUNC = function (x, ...) { jsonlite::toJSON(x, digits = 50, auto_unbox = TRUE, force = TRUE, null = "null", na = "null", time_format = "%Y-%m-%d %H:%M:%OS6", ...) }), width = NULL, height = NULL, sizingPolicy = list(defaultWidth = "100%", defaultHeight = 400, padding = 0, viewer = list(defaultWidth = NULL, defaultHeight = NULL, padding = NULL, fill = TRUE, suppress = FALSE, paneHeight = NULL), browser = list(defaultWidth = NULL, defaultHeight = NULL, padding = NULL, fill = TRUE, external = FALSE), knitr = list(defaultWidth = NULL, defaultHeight = NULL, figure = TRUE)), dependencies = list(structure(list(name = "typedarray", version = "0.1", src = list(file = "htmlwidgets/lib/typedarray"), meta = NULL, script = "typedarray.min.js", stylesheet = NULL, head = NULL, attachment = NULL, package = "plotly", all_files = FALSE), class = "html_dependency"), structure(list(name = "jquery", version = "3.5.1", src = list( file = "lib/jquery"), meta = NULL, script = "jquery.min.js", stylesheet = NULL, head = NULL, attachment = NULL, package = "crosstalk", all_files = TRUE), class = "html_dependency"), structure(list(name = "crosstalk", version = "1.2.0", src = list(file = "www"), meta = NULL, script = "js/crosstalk.min.js", stylesheet = "css/crosstalk.min.css", head = NULL, attachment = NULL, package = "crosstalk", all_files = TRUE), class = "html_dependency"), structure(list(name = "plotly-htmlwidgets-css", version = "2.5.1", src = list(file = "htmlwidgets/lib/plotlyjs"), meta = NULL, script = NULL, stylesheet = "plotly-htmlwidgets.css", head = NULL, attachment = NULL, package = "plotly", all_files = FALSE), class = "html_dependency"), structure(list( name = "plotly-main", version = "2.5.1", src = list( file = "htmlwidgets/lib/plotlyjs"), meta = NULL, script = "plotly-latest.min.js", stylesheet = NULL, head = NULL, attachment = NULL, package = "plotly", all_files = FALSE), class = "html_dependency")), elementId = NULL, preRenderHook = function (p, registerFrames = TRUE) { UseMethod("plotly_build") }, jsHooks = list()), class = c("plotly", "htmlwidget"), package = "plotly")

And the rmd file is attached (renamed as txt) test.txt

gvwilson commented 2 months ago

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson