Giter Site home page Giter Site logo

Comments (10)

AliciaSchep avatar AliciaSchep commented on May 16, 2024 1

Hi @Tomer-Tsaban this is not currently readily configurable with iheatmapr, unfortunately. However, there is a hacky back-door approach you can use to get this effect:

# q is the heatmap object created above
# first convert it to an htmlwidgets object proper (this is normally done during the print process)
q_widget <- to_widget(q)
# Edit the htmlwidget object itself
q_widget$x$config$modeBarButtonsToRemove <- list(
'sendDataToCloud',
'toImage',
'autoScale2d',
'resetScale2d',
'hoverClosestCartesian',
'hoverCompareCartesian'
)
# you should be able to display the heatmap using q_widget similarly to how you would q.  

Having a modify_config function to enable this customization directly seems like a good feature to add though going forward.

from iheatmapr.

liangyu02 avatar liangyu02 commented on May 16, 2024 1

NiuBi!

from iheatmapr.

AliciaSchep avatar AliciaSchep commented on May 16, 2024

Re the 2nd question -- I don't know. I am not aware of a way to do that.

from iheatmapr.

Tomer-Tsaban avatar Tomer-Tsaban commented on May 16, 2024

Hi Alicia, thanks for your answer!

I tried to implement what you suggested (exactly your code) and for some reason I get this error:
ERROR: unable to find an inherited method for function ‘to_widget’ for signature ‘"iheatmapr"

are you familiar with this?

from iheatmapr.

AliciaSchep avatar AliciaSchep commented on May 16, 2024

Try iheatmapr::to_widget -- maybe another package is loaded that also has to_widget method that is shadowing iheatmapr's.

from iheatmapr.

Tomer-Tsaban avatar Tomer-Tsaban commented on May 16, 2024

Hi, thanks for your quick responses!

I tried again and figured out that the problem is with shiny package.
I use iheatmapr in a shiny app, and this is how the error was received. sorry for foolishly not stating that out previously.

anyhow, when trying the to_widget function in a non-shiny context, it works smoothly.
however when trying to embed in shiny, this error comes up again. here's a simple reproducible example with the measles data:
`
data(measles, package = "iheatmapr")

ui<-fluidPage(
iheatmaprOutput("output_q_widget")
)

server<-function(session,input,output){

    q<-main_heatmap(measles, name = "Measles<br>Cases", x_categorical = FALSE,
                    layout = list(font = list(size = 8))) %>%
            add_col_groups(ifelse(1930:2001 < 1961,"No","Yes"),
                           side = "bottom", name = "Vaccine<br>Introduced?",
                           title = "Vaccine?",
                           colors = c("lightgray","blue")) %>%
            add_col_labels(ticktext = seq(1930,2000,10),font = list(size = 8)) %>%
            add_row_labels(size = 0.3,font = list(size = 6)) %>%
            add_col_summary(layout = list(title = "Average<br>across<br>states"),
                            yname = "summary")  %>%
            add_col_title("Measles Cases from 1930 to 2001", side= "top") %>%
            add_row_summary(groups = TRUE,
                            type = "bar",
                            layout = list(title = "Average<br>per<br>year",
                                          font = list(size = 8)))
    
    q_widget <- to_widget(q)
    # Edit the htmlwidget object itself
    q_widget$x$config$modeBarButtonsToRemove <- list(
            'sendDataToCloud',
            'toImage',
            'autoScale2d',
            'resetScale2d',
            'hoverClosestCartesian',
            'hoverCompareCartesian'
    )
    #q_widget
    
    output$output_q_widget<-renderIheatmap({
            q_widget
            
    })

}

shinyApp(ui,server)
`
Thanks, and again sorry for lacking this information in my previous question.
EDIT: also, for some reason github won't accept the whole code snippet as code-text... sorry.

from iheatmapr.

AliciaSchep avatar AliciaSchep commented on May 16, 2024

Thanks for additional details... the issue is that renderIheatmap will call 'to_widget' but with the above approach that has already been done. As another temporary workaround, you could define

renderIheatmap2 <- function(expr, env = parent.frame(), quoted = FALSE) {
  if (!quoted) { expr <- substitute(expr) } # force quoted
  htmlwidgets::shinyRenderWidget(expr, iheatmaprOutput, env, quoted = TRUE)
}

and use that instead of renderIheatmap (basically an edit of that function that removes the call to 'to_widget')

Will be much better to add ability to edit config directly to the package, but in meantime hope that unblocks whatever app you are working on.

from iheatmapr.

Tomer-Tsaban avatar Tomer-Tsaban commented on May 16, 2024

This works beautifully!
thanks alot

from iheatmapr.

rfenouil avatar rfenouil commented on May 16, 2024

@AliciaSchep May I had a question to your suggestion ?

I succesfully removed logo using the strategy you suggested:

heatmapPlot_widget <- iheatmapr::to_widget(heatmapPlot);

heatmapPlot_widget[["x"]][["config"]][["displaylogo"]] = FALSE;
heatmapPlot_widget[["x"]][["config"]][["toImageButtonOptions"]] = list( format='svg');

But the 'svg' output does not seem to work.
Is the plotly version embedded in iHeatmapr too old to include this option ?

Thank you.

from iheatmapr.

daattali avatar daattali commented on May 16, 2024

Another vote for allowing a custom config.

This issue is currently unresolvable (even with the hacky way) in shiny apps because of #71 which was mentioned by @Tomer-Tsaban

from iheatmapr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.