better auto update method

This commit is contained in:
pvictor 2020-04-15 14:41:15 +02:00
parent 5728a361da
commit ea901187ac
3 changed files with 20 additions and 3 deletions

View File

@ -87,13 +87,13 @@ add_locale_apex <- function(widget) {
#' @param options_redrawPaths When the chart is re-rendered, #' @param options_redrawPaths When the chart is re-rendered,
#' should it draw from the existing paths or completely redraw #' should it draw from the existing paths or completely redraw
#' the chart paths from the beginning. By default, the chart #' the chart paths from the beginning. By default, the chart
#' is re-rendered from the existing paths #' is re-rendered from the existing paths.
#' #'
#' @export #' @export
config_update <- function(series_animate = TRUE, config_update <- function(series_animate = TRUE,
update_options = FALSE, update_options = FALSE,
options_animate = TRUE, options_animate = TRUE,
options_redrawPaths = FALSE) { options_redrawPaths = TRUE) {
list( list(
series_animate = series_animate, series_animate = series_animate,
update_options = update_options, update_options = update_options,

View File

@ -136,6 +136,21 @@ HTMLWidgets.widget({
axOpts.chart.parentHeightOffset = 0; axOpts.chart.parentHeightOffset = 0;
} }
// added events to remove minheight container
if (!axOpts.chart.hasOwnProperty("events")) {
axOpts.chart.events = {};
}
if (!axOpts.chart.events.hasOwnProperty("mounted")) {
axOpts.chart.events.mounted = function(chartContext, config) {
el.style.minHeight = 0;
};
}
if (!axOpts.chart.events.hasOwnProperty("updated")) {
axOpts.chart.events.updated = function(chartContext, config) {
el.style.minHeight = 0;
};
}
if (x.hasOwnProperty("shinyEvents") & HTMLWidgets.shinyMode) { if (x.hasOwnProperty("shinyEvents") & HTMLWidgets.shinyMode) {
if (!axOpts.hasOwnProperty("chart")) { if (!axOpts.hasOwnProperty("chart")) {
axOpts.chart = {}; axOpts.chart = {};
@ -226,8 +241,10 @@ HTMLWidgets.widget({
apexchart.render(); apexchart.render();
} else { } else {
if (x.auto_update) { if (x.auto_update) {
//console.log(x.auto_update);
apexchart.updateSeries(axOpts.series, x.auto_update.series_animate); apexchart.updateSeries(axOpts.series, x.auto_update.series_animate);
if (x.auto_update.update_options) { if (x.auto_update.update_options) {
delete axOpts.series;
apexchart.updateOptions( apexchart.updateOptions(
axOpts, axOpts,
x.auto_update.options_redrawPaths, x.auto_update.options_redrawPaths,

View File

@ -8,7 +8,7 @@ config_update(
series_animate = TRUE, series_animate = TRUE,
update_options = FALSE, update_options = FALSE,
options_animate = TRUE, options_animate = TRUE,
options_redrawPaths = FALSE options_redrawPaths = TRUE
) )
} }
\arguments{ \arguments{