% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plotly_Utils.R
\name{click_plot}
\alias{click_plot}
\title{Click on plotly plot to highlight traces}
\usage{
click_plot(p, highlight_color = "#1f77b4")
}
\arguments{
\item{p}{The plotly plot to which the click functionality should be added.
Default is the \code{plotly::last_plot()}.}

\item{highlight_color}{The color to use for traces that are highlighted. Colors for non-highlighted
traces will be preserved but dimmed to 20\% opacity. Default highlight color is \code{orange()}.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Adds click functionality to a plotly plot to highlight traces when clicked.
}
\details{
This function modifies a plotly plot to allow clicking on traces to highlight them.
Clicking on a trace will highlight it in orange (default) and dim all other traces.
Clicking on the same trace again will deselect it and restore the original colors.
Clicking on the background will also restore all traces to their original colors.
The function uses the \code{htmlwidgets::onRender} function from the \code{htmlwidgets} package to add
JavaScript code that handles the click events on the plotly plot.
}
\author{
Michael Neely
}
