Comments (6)
Hi,
I'm afraid of not to understand what you really want to do. Does your question deal with shiny reactivity or JavaScript listener ? Could you maybe give an illustrative example ?
from ramcharts.
Hi,
for example, you have the following code that will show up an alert prompt window when band is clicked.
addListener('clickBand', 'function(event) { alert('clicked on band !') }')
instead of showing an alert window, can this selected value be assigned to a session object?
See Interaction with Shiny section
http://rstudio.github.io/DT/shiny.html
I personally find such very useful because it allows me to link with other diagram/tables for drilling down.
from ramcharts.
Hi,
We can use the event properties of the listener functions and combine this with the JavaScript function "Shiny.onInputChange
". You can refer to this for more details: https://ryouready.wordpress.com/2013/11/20/sending-data-from-client-to-server-and-back-using-shiny/.
This is a simple example in which we are able to get the value clicked. The "event" object is detailed in the official API (http://docs.amcharts.com/3/javascriptstockchart/AmSerialChart).
library(rAmCharts)
library(shiny)
library(pipeR)
shinyApp(
ui = fluidPage(
amChartsOutput(outputId = "chart"),
fluidRow(
column(width = 1, strong("Values: ")),
column(width = 3, verbatimTextOutput("result"))
)
),
server = function(input, output) {
output$chart <- renderAmCharts({
# prepare data
dp <- data.table(name = paste0('foo', 1:5),
income = round(rnorm(5, mean = 30000, sd = 2000)))
# build the chart
pipeline(
amSerialChart(categoryField = 'name', dataProvider = dp),
addGraph(type = 'column', valueField = "income", fillAlphas = .6),
addListener(name = 'clickGraphItem',
expression = paste('function(event){',
'Shiny.onInputChange(\'myValues\', event.item.values);',
'}'))
)
})
output$result <- renderPrint({
input$myValues
})
}
)
I hope this will help.
from ramcharts.
It works, thanks
from ramcharts.
@Djaiff Could you help look into why below code didn't work? Thanks.
data("data_candleStick1")
amCandlestick(data = data_candleStick1, names = c("min", "begin", "end", "max")) %>%
addListener(name = 'clickItem', expression = "function(event){ alert('ok !'); }")
from ramcharts.
Nevermind, figured out the name has to be 'clickGraphItem' If you could provide more documentation on available names in ?addListener, it would be great.
from ramcharts.
Related Issues (20)
- Setting Axis via minimum and maximum properties not working HOT 7
- amTimeSeries, different hours are grouped at the same hour on the x-axis ? HOT 2
- pieChart with broken slices
- Functionality to create Time-lapse animation in rAmCharts HOT 3
- Display message when amCharts renders a chart onto screen HOT 1
- Compatibility with IE HOT 1
- jquery slider with rAmChart HOT 1
- amBoxplot with formula in shiny not working HOT 2
- Issue with amTimeSeries (groupToPeriods) HOT 1
- Example of stacked area / line chart? HOT 4
- amTimeSeries dont work with time < minute HOT 1
- multiple value axes HOT 1
- [Question] hyperlink on waterfall chart
- Default handling of date/time basis dataset for amStockMultiSet
- amchart v4 ? HOT 3
- how to apply my paid license on rAmchart
- [Question] Number formatting ? HOT 1
- Number formatting for amAngularGauge() HOT 1
- Error when calling plot()
- donut pie legend entries: sorting doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ramcharts.