Make hc_add_onclick_korap_search work with bar and pie charts
TODO: make this parameterizable and only set the option for wanted chart types.
Change-Id: I6cf6b806f4bba73a34ef8c31272bbfa40c7a1058
diff --git a/NEWS.md b/NEWS.md
index 904c40d..30faf72 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
- now fails gracefully with an informative message if the API server is not accessible
- fixed shiny demo
+- `hc_add_onclick_korap_search()` now also works with bar, column and pie highcharts
- new parameters added to `collocationAnalysis` function:
- `maxRecurse` - apply collocation analysis recursively `maxRecurse` times
- `addExamples` - If `TRUE`, examples for instances of collocations will be added in a column `example`. This makes a difference in particular if 'node' is given as a lemma query.
diff --git a/R/hc_add_onclick_korap_search.R b/R/hc_add_onclick_korap_search.R
index 6140ffa..b5c57b2 100644
--- a/R/hc_add_onclick_korap_search.R
+++ b/R/hc_add_onclick_korap_search.R
@@ -28,16 +28,15 @@
#' }
#'
hc_add_onclick_korap_search <- function(hc) {
+ js <- JS("function() { window.open(this.webUIRequestUrl, 'korap'); }")
+ point_events <- list(events = list(click = js))
+ onclick_hc_options <- list(cursor = 'pointer', point = point_events)
hc_plotOptions(
hc,
series = list(enabled = TRUE),
- spline = list(cursor = 'pointer', point = list(events = list(
- click = JS("function() { window.open(this.webUIRequestUrl, 'korap'); }")
- ))),
- column = list(cursor = 'pointer', point = list(events = list(
- click = JS("function() { window.open(this.webUIRequestUrl, 'korap'); }")
- ))),
- line = list(cursor = 'pointer', point = list(events = list(
- click = JS("function() { window.open(this.webUIRequestUrl, 'korap'); }")
- ))))
+ line = onclick_hc_options,
+ spline = onclick_hc_options,
+ column = onclick_hc_options,
+ bar = onclick_hc_options,
+ pie = onclick_hc_options)
}