fixed passing JS func from proxy

This commit is contained in:
pvictor 2021-02-11 21:52:55 +01:00
parent 3e85bd477a
commit 9efca10228
6 changed files with 75 additions and 66 deletions

View File

@ -1,5 +1,5 @@
Package: apexcharter Package: apexcharter
Version: 0.1.8.910 Version: 0.1.8.9100
Title: Create Interactive Chart with the JavaScript 'ApexCharts' Library Title: Create Interactive Chart with the JavaScript 'ApexCharts' Library
Description: Provides an 'htmlwidgets' interface to 'apexcharts.js'. Description: Provides an 'htmlwidgets' interface to 'apexcharts.js'.
'Apexcharts' is a modern JavaScript charting library to build interactive charts and visualizations with simple API. 'Apexcharts' is a modern JavaScript charting library to build interactive charts and visualizations with simple API.

View File

@ -86,6 +86,7 @@ importFrom(htmltools,resolveDependencies)
importFrom(htmltools,tagList) importFrom(htmltools,tagList)
importFrom(htmltools,tags) importFrom(htmltools,tags)
importFrom(htmlwidgets,JS) importFrom(htmlwidgets,JS)
importFrom(htmlwidgets,JSEvals)
importFrom(htmlwidgets,createWidget) importFrom(htmlwidgets,createWidget)
importFrom(htmlwidgets,getDependency) importFrom(htmlwidgets,getDependency)
importFrom(htmlwidgets,shinyRenderWidget) importFrom(htmlwidgets,shinyRenderWidget)

View File

@ -153,6 +153,8 @@ ax_proxy_series <- function(proxy, newSeries, animate = TRUE) {
#' #'
#' @export #' @export
#' #'
#' @importFrom htmlwidgets JSEvals
#'
#' @examples #' @examples
#' #'
#' if (interactive()) { #' if (interactive()) {
@ -211,7 +213,7 @@ ax_proxy_options <- function(proxy, options) {
.ax_proxy2( .ax_proxy2(
proxy = proxy, proxy = proxy,
name = "options", name = "options",
l = list(options = options) l = list(options = options, evals = JSEvals(options))
) )
} }

View File

@ -332,7 +332,13 @@ if (HTMLWidgets.shinyMode) {
Shiny.addCustomMessageHandler("update-apexchart-options", function(obj) { Shiny.addCustomMessageHandler("update-apexchart-options", function(obj) {
var chart = apexcharter.getWidget(obj.id); var chart = apexcharter.getWidget(obj.id);
if (typeof chart != "undefined") { if (typeof chart != "undefined") {
chart.updateOptions(obj.data.options); var options = obj.data.options;
var evals = obj.data.evals;
if (!(evals instanceof Array)) evals = [evals];
for (var k = 0; evals && k < evals.length; k++) {
window.HTMLWidgets.evaluateStringMember(options, evals[k]);
}
chart.updateOptions(options);
} }
}); });