0
我正在做一個測試,將Tableau JavaScript API集成到一個單頁閃亮的應用程序中。我已成功呈現Tableau Viz,但過濾器功能無法正常工作。Shiny R中的Tableau JavaScript API過濾器函數
這裏是我的代碼:
library(shiny)
library(shinyjs)
shinyApp(
ui = fluidPage(
useShinyjs(),
tags$head(tags$script(src="https://public.tableau.com/javascripts/api/tableau-2.min.js")),
extendShinyjs(text='shinyjs.initializeViz = function(){
var placeholderDiv = document.getElementById("tableauViz");
var url = "http://public.tableau.com/views/WorldIndicators/GDPpercapita";
var options = {
hideTabs: true,
hideToolbar: true,
onFirstInteractive: function() {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
viz = new tableau.Viz(placeholderDiv, url, options);
}
shinyjs.filterSingleValue= function(filtername, value){
activeSheet.applyFilterAsync(
filtername,
value,
tableau.FilterUpdateType.REPLACE);
} '),
titlePanel("Tableau JavaScript API in Shiny App"),
selectInput('region', 'Region: ',
c('The Americas', 'Europe', 'Middle East')),
tags$div(id = 'tableauViz')
),
server = function(input, output, session){
observeEvent(input$region, {
js$filterSingleValue('Region', input$region)
js$initializeViz()
})
}
)
任何想法,爲什麼?