Add preliminary button to toggle between log/linear y scale
Resolves #4
Change-Id: I9b3278fa896812709f8bf1afdb23c104af1e612c
diff --git a/shiny/app.R b/shiny/app.R
index 1755347..80159a2 100644
--- a/shiny/app.R
+++ b/shiny/app.R
@@ -14,6 +14,23 @@
str_replace_all(" +", " ")
}
+hc_add_log_linear_toggle <- function(hc, index=50) {
+ hc_add_series(hc, name="[toggle log/linear]", legendIndex=index, visible=TRUE, type="spline", color="white") %>%
+
+ hc_plotOptions(spline = list(
+ events = list(legendItemClick = JS("
+ function() {
+ var conall = $(this.chart.container).parents('.hc-link-legend').find('div.highchart');
+ for(var i = 0; i < conall.length; i++) {
+ var hc = $(conall[i]).highcharts();
+ hc.yAxis[0].update({type: hc.yAxis[0].options['type']=='logarithmic' ? 'linear' : 'logarithmic'});
+ }
+ }
+ "))
+ ))
+}
+
+
ui <- fluidPage(
theme = shinytheme("paper"),
@@ -64,7 +81,8 @@
hc_add_onclick_korap_search() %>%
hc_yAxis(type = "logarithmic") %>%
hc_legend(enabled=F) %>%
- hc_plotOptions(series = list(events = list(legendItemClick = sharelegend)))
+ hc_plotOptions(series = list(events = list(legendItemClick = sharelegend))) %>%
+ hc_add_log_linear_toggle()
}
prettifyCorpusNames <- function(df) {