datastorm-open / ramcharts Goto Github PK
View Code? Open in Web Editor NEWAPI for Amcharts
API for Amcharts
Hi,
I'm considering to utilize this package but my server that hosts application does not have access to internet. What's the purpose of pathToImages = "http://www.amcharts.com/lib/3/images/ in waterfall report example? Can such internet dependency be removed?
Thanks
I have an amStockChart containing 3 time series. During initialization, only the first time series is visible. Now, using the DataSelector list box in the UI, i selected the remaining two series for comparison. Now I used a checkboxinput in the UI to change the scale from normal to logarithmic. The chart refreshes and 2/3 time series get deselected. How can I retain the initial settings in the chart prior to such events invoked by a user in the UI. I am assuming I should use validateNow() method but not sure how and where to invoke it in my shiny code. A working example would be much appreciated
Thank you
I'm using a mouse click listener like below
addListener(name = 'clickGraphItem', expression = paste0('function(event){',
'Shiny.onInputChange('clickedVal', event.item.category)',
'}'))
However, there are cases that I need to reset input$clickedVal to '' or NULL. Shiny won't allow me to modify the input value directly. Is there anything can be done to reset the listener?
detailed case
listener is based on chart 1.
clicked value is one of the inputs for chart 2, act as a filter.
if the dataprovider chart 1 is updated, the listener should be reset to NULL, which disables chart 2, as previously clicked value is no longer valid.
Thanks.
I would like to make my amCharts responsive to smaller screens.
Example: http://codepen.io/amcharts/pen/QwgEKQ/
When I use the R equivalent of it "setResponsive(enabled=TRUE)", it throws an error
Error in : unable to find an inherited method for function ‘setResponsive’ for signature ‘"AmStockChart", "logical"’
Wonder where did I go wrong
Hi,
What am I trying to achieve here? I want the charts to render as fast as they can. So I load limited data (monthly) in the first instance. Now when user zooms in (say a period of last 60 days), I use the zoom event listener to trigger an R script which will now load the daily data for that period. Now this time, with new 60 day daily data + previous monthly data (this is needed to make sure user can zoom-out), the chart gets re-rendered but I would need it to retain the "zoomed- in" period (last 60 days window) so that user gets to see the zoomed in period only with the daily data.
I am going by the thread amcharts/amcharts3#26.
AmCharts team gave me the solution to use zoomOutOnDataUpdate = FALSE.
I am unable to make zoomOutOnDataUpdate = FALSE in shiny. Can you give me an example where the zoom period remains constant when we change the data in the dataSets.
Hi,
could you provide an example on assigning a value from the listened event to a session variable on shiny? The purpose is to enable cross filtering or drill down.
Thanks,
Hi,
I am trying to kind of replicate the example "http://www.amcharts.com/tips/dynamically-changing-granularity-data-based-zoom-scope/"
I have two dataSets - dataSets_Daily and dataSets_Monthly. I want the monthly to be loaded first and then when zoomed, the daily should get loaded. The following listener code is not responding
addListener('zoomed' , 'function(event){chart.dataSets = dataSets_Price;chart.validateNow(false, true);}'),
Please suggest where am I going wrong here
Thank you as always
SD
In the latest version of rAmChart (post v1.1.3), data frame containing column headers with special character or numbers are not rendered. It worked fine in v1.1.3
Example , if I change the data frame column name from runExamples() and introduce a space " ", the chart does not render. Please help me resolve this bug in the package
## Data
times <- as.POSIXct(seq(-60 * 60 * 24 * 50 + 1, 0, by = 3600), origin = Sys.time(), tz = 'UTC')
times <- round(times,'hours')
times <- data.frame(times)
times$Mesure <- 1:length(times$times) + rep(cos(seq(-pi,pi,length.out = 100)), 12) * 500 + runif(length(times$times)) * 200
colnames(times)[2]<-"20 Micron"
# dummy1<<-times
mycategoryBalloonDateFormat <- list(list(period = 'YYYY', format = 'YYYY'),
list(period='MM', format = 'YYYY-MM'),
list(period = 'WW', format = 'YYYY-MM-DD'),
list(period='DD', format = 'YYYY-MM-DD'),
list(period = 'hh', format = 'YYYY-MM-DD JJ:NN'),
list(period='mm', format = 'YYYY-MM-DD JJ:NN'),
list(period = 'ss', format = 'YYYY-MM-DD JJ:NN:ss'),
list(period='fff', format = 'YYYY-MM-DD JJ:NN:ss'))
## Plot
graph<-pipeR::pipeline(
amStockChart(dataDateFormat = 'YYYY-MM-DD JJ:NN:ss') ,
addDataSet(pipeR::pipeline(
dataSet(title = 'first data set', categoryField = 'times') ,
setDataProvider(times,keepNA=FALSE),
addFieldMapping(fromField = colnames(times)[2], toField = colnames(times)[2]))),
addPanel(pipeR::pipeline(
stockPanel(showCategoryAxis = TRUE, title = 'Value') ,
addStockGraph(id = 'g1',connect=FALSE, valueField = colnames(times)[2], comparable = TRUE,periodValue = 'Average',type='column',
compareField = colnames(times)[2], balloonText = 'Value : <b>[[value]] Unit</b>', precision = 0,
compareGraphBalloonText = '[[title]] =<b>[[value]]</b>'))),
setChartScrollbarSettings(graph = 'g1'),
setChartCursorSettings( valueBalloonsEnabled = TRUE, fullWidth = TRUE,
cursorAlpha = 0.1, valueLineBalloonEnabled = TRUE,
valueLineEnabled = TRUE, valueLineAlpha = 0.5,
categoryBalloonDateFormats = mycategoryBalloonDateFormat),
setPeriodSelector(pipeR::pipeline( periodSelector( position = 'bottom' ,inputFieldsEnabled=FALSE) ,
addPeriod( period = 'DD', selected = TRUE, count = 1, label = '1 day') ,
addPeriod( period = 'WW', count = 1, label = '1 week' ) ,
addPeriod( period = 'MAX', label = 'All' ))),
setCategoryAxesSettings(parseDates = TRUE, minPeriod = '1hh',
groupToPeriods = c('hh','3hh', '12hh','1DD'),maxSeries = 50),
setPanelsSettings(recalculateToPercents = 'never', creditsPosition='top-left')
)
Is this intentional or?
Hi,
1 bug detected - if you use drawingIconsEnabled = TRUE and double click the erase button two times, it takes you to Amcharts HomePage.
Also, would like to replicate the example "http://www.amcharts.com/tips/catching-click-events-putting-markers-stock-chart/" but not sure how. I would like to trigger the drawing functionality on click of a random button
Thank you
Sushanta
How do we load the language file in Shiny? I was able to work with below code in ui.R but not sure if this is how it is supposed to be done
tags$head(tags$script(src="http://cdn.amcharts.com/lib/3/lang/cn.js")),
Maybe a workaround based on https://www.amcharts.com/demos/stacked-clustered-column-chart/?
Hi:
I would like to dynamically add the numbers of series to an rAmchart based on user input. How can I achieve the same.
Data Table a has n number of columns and I would like each column to represent a line series
Working example below is not working:
"fdyG1"= pipeR::pipeline(
amSerialChart(addClassNames = TRUE, autoMargins = FALSE,
marginLeft = 30, marginRight = 8,
marginTop = 10, marginBottom = 26, startDuration = 1,
categoryField = 'PERIOD', startDuration = 0),
addGraph(bullet = 'round', lineThickness = 3,
bulletSize = 7, bulletBorderAlpha = 1, bulletColor = '#FFFFFF',
useLineColorForBulletBorder = TRUE, bulletBorderThickness = 3,
fillAlphas = 0, lineAlpha = 1, title = colnames(a)[2], valueField = colnames(a)[2],
balloonText = balloonText),
setDataProvider(dataProvider = a)
)
for (ctr in 3:NROW(a)){
"fdyG1"= pipeR::pipeline(fdyG1,addGraph(bullet = 'round', lineThickness = 3,
bulletSize = 7, bulletBorderAlpha = 1, bulletColor = '#FFFFFF',
useLineColorForBulletBorder = TRUE, bulletBorderThickness = 3,
fillAlphas = 0, lineAlpha = 1, title = colnames(a)[ctr], valueField = colnames(a)[ctr],
balloonText = balloonText),
setDataProvider(dataProvider = a)
)
}
I try to use rAmCharts with FlexDashboard from RStudio (http://rstudio.github.io/flexdashboard/using.html)
I played around with the layout and it seems to me that rAmCharts could not auto re-size the chart to fit the size of the dashboard.
Is there anything I could do to fix the issue?
title: "Demo of Flex Dashboard from RStudio"
output:
flexdashboard::flex_dashboard:
orientation: columnsvertical_layout: fill
# Load packages and initialize data here library(flexdashboard) library(pipeR) library(rAmCharts)Column
Angular Gauge
bands <- data.frame(start = c(0, 40, 60), end = c(40, 60, 100), color = c("#00CC00", "#ffac29", "#ea3838"), stringsAsFactors = FALSE) bands2 <- data.frame(start = c(100, 130, 170), end = c(130, 170, 200), color = c("#00CC00", "#ffac29", "#ea3838"), stringsAsFactors = FALSE) amAngularGauge(x = 25, start = 0, end = 100, bands = bands, secondAxe = TRUE, start2 = 100, end2 = 200, bands2 = bands2)3D Bar plot
data("data_bar") amBarplot(x = "country", y = "visits", data = data_bar, horiz = TRUE, depth = 15)Column
Pie chart
data("data_pie") amPie(data = data_pie) %>>% amOptions(legend = TRUE)Chart D
data <- data.frame(label = c("A", "Z", "E", "R", "T"), Product1 = c(1, 2, 3, 4, 2), Product2 = c(2, 8, 1, 1, 0), Product3 = c(1,1,2,2,4)) amRadar(data = data, pch = "bubble", backTransparency = 0) %>>% amOptions(legend = TRUE, legendPosition = "left")
Hello, I have been trying to use amStockChart, but no success so far. It ends up printing data to the screen, rather than charting. Haven't spent too much time on it, but is there an example to follow for this function?
Thanks in advance
Hi Jeff,
I would like to know the following:
Data Frame:
Period Value1 Value2
2010-01-01 30 NaN
2010-06-01 NaN 67
2010-09-01 45 NaN
2011-03-31 NaN 34
and so on
Apologies for so many queries regarding amStockCharts. Thank you
Hi,
Native Amcharts allow asynchronous loading of data using the dataloader pluggin (async=TRUE). Since rAmCharts does not use the data loader pluggin, how can we build this effect in our shinyapp?
This will be a great boon to apps using a lot of data as the user will not have to wait until the entire data gets loaded
Thank you as always for all your help so far.
SD
Hi,
I would like to use the WordPress Pluggin so that my users can copy the charts and use it in their blogs. How can I implement the same. Can you please create an example of such a functionality
Thank you
SD
Hi,
It's a bit strange to me that the amRadar does not take dbl as input for columns other than label. Is this intentional? What's the suggested data format then?
Error in amRadar(.) : All column of data except label must be numeric
Hi,
Could you provide a minimal example of the below chart? Thanks.
http://www.amcharts.com/demos/stacked-bar-chart-with-negative-values/
http://rpubs.com/thonguyenduy/181447
I test with a 23' LCD with the resolution of 1920 x 1080, Google Chrome and I must view the page in full screen mode to see the charts properly.
Source code was included in the page.
Please help investigating.
Kind regards.
Your package manual/documentation rAmcharts.pdf provides below language
"chartScrollbarSettings
ChartScrollbar. If you change a property after the chart is initialized, you should
call stockChart.validateNow() method in order for it to work. If there is no
default value specified, default value of ChartScrollbar class will be used"
I would like to see the validateNow() method being triggered in an example. Usage of validateNow() and validateData() methods is probably the most important part of the package that I am missing today as I enter the final stages of my webapp development.
I have implemented it within an amChart "event" [panelRemoved event] using addListener.
The below works perfectly - I had two panels in my chart. I tried to change the chart type of the first panel stockGraph from line to column using the validateNow() method when user tries to close the second panel. I simple wanted to see if validateNow() method works and it does.
addListener('panelRemoved', 'function(event){
event.chart.panels[0].stockGraphs[0].type = "column";
event.chart.validateNow();
}')
But I really need to be able to call this method anytime based on R events and not just amCharts events. When I say R events, I am referring to say the click of an actionbutton within ui.R. Does the below work for you?
ui.R
actionbutton("samplebtn", label="Click Me"),
amChartsOutput("pic", type = NULL, width = "100%", height = "400px")
server.R
output$pic<-renderAmCharts({
stockChart<<-pipeR::pipeline(
amSerialChart(dataDateFormat = 'YYYY',categoryField = 'year', startDuration = 0),
setDataProvider(data.frame(year = 1990:2015, value = runif(length(1990:2015), -1, 1))),
addValueAxes(axisAlpha = 0, position = 'left'),
addGraph(id = 'g1', type = 'column', valueField = 'value', fillAlphas = 1),
setCategoryAxis(minPeriod = 'YYYY', parseDates = TRUE),
addListener('init', paste('function(event) {',
'setTimeout(function() {',
' event.chart.allLabels = [{',
' x: event.chart.marginLeftReal + 20,',
' y: event.chart.marginTopReal + 20,',
' text: "Watermark label",',
' size: 20,',
' color: "green",',
' alpha: 1',
' }];',
' event.chart.validateNow()',
'}, 100)}'))
)
return(plot(chart))
})
shinyjs::onclick("samplebtn", stockChart.validateNow())
.....
.....
stockChart.validateNow()
})
Thank you for your cooperation and I am willing to bring ideas to the table,if needed, to implement it.
Thank you as always
SD
Hi,
I have the below settings for legend. However because the value is too big, I'd like to divide it by 1,000 or 1,000,000 and round it.
I have tried [[ Math.round(value.sum/1000)]] but it didn't work.
Also, is it possible to do if/else clause inside the [[ ]]?
Thanks.
setLegend(position = 'bottom' ,useGraphSettings = TRUE, periodValueText = ' {[[value.sum]]}', valueWidth = 80) %>%
Hi,
Can you double check if this switch is working or not?
In addition, is it possible to change the position and layout of legend? for example, put it on left/right side vertically. like the one implemented in visNetwork.
Thanks.
I have seen websites like http://thestockmarketwatch.com/stock/stock-chart.aspx?stock=AAPL
use the drawing toolbox but I am unable to find these options in my library. What am I missing. I also do not see any form of documentation around it. Please help
referencing
#11
Hi,
It seems when I use the complex function, the dataProvider has to be data frame class.
If I feed in a tbl_df object without the as.data.frame(), below error msg will show up.
amSerialChart(graphs = graphs_ls, theme = 'light',categoryField = 'Week') %>%
setDataProvider(dataProvider = dat)
Warning: Error in : unable to find an inherited method for function ‘setDataProvider’ for signature ‘"AmChart", "tbl_df", "missing"’
Stack trace (innermost first):
Hi,
I'm experimenting to use candlestick diagram to visualize some weekly dataset (non-stock related)
Is it possible to make the date column to a sorted vector or something like that type?
for example, the category I am using is like '2016W01, 2016W02, .....'
Thanks
Hi Jeff,
Currently, it seems that setExport feature is not available for amStockCharts. How can I get those features to work such as annotate and save as in amStockCharts. I was trying to play around with the below example but could not make it work.
http://codepen.io/amcharts/embed/54438738eb344e96a063ee2d4821ed7b?height=598
Request you to kindly help me with this
Regards,
Sushanta
Hi,
While it's doable outside of the amFunctions, it might just be easier to implement inside them.
Would amFunction be able to take both character and factor columns in x-axis?
Example error code
Error in amBarplot(x = c("Quarter"), y = nms, data = dat, labelRotation = 90, :
The column Quarter of the dataframe must be character.
Hi,
I'm wondering if there are more options to adjust boxplot like the other chart types.
Thanks.
Hi,
I was trying to make this parameter dynamic by changing it with the # of axis on radar map
fontSize <- max(as.integer(16 / (log(nrow(dat))+1)),8L)
amRadar(dat, mainSize = fontSize,legend = FALSE)
But somehow it throws an error below
Error in amRadar(dat, mainSize = fontSize) :
mainSize must be a numeric or double
thanks.
AmCharts gives an example of how to do it here:
http://extra.amcharts.com/tutorials/save-on-server/
https://www.amcharts.com/tutorials/saving-exported-chart-image-server/
I am able to get the JS and R part right. So running below code saves the base64 onto the console.
exportMenu<-c(Draw,list(DownloadAs),list(SaveAs),list(PRINT),list(list(label="Share",click=htmlwidgets::JS('function () {
alert( "Clicked JPEG. Wow cool!" );
this.capture( {}, function() {
this.toJPG( {}, function( base64 ) {
console.log(base64)
} );
} );
}')
)))
Now the tutorial says I must create a php file and I have no clue about php. So, I create the save.php file within rStudio directory where my ui.R and server.R files are. I type the below code in that file
Finally when I run the program, the base64 URI data gets logged onto the console but does not save the png file in my server path.
I am seeking your help in case there is someone in your team who understand php and how this should work. Thank you as always
SD
Can you please provide an example where StockEvents feature has been used. My current attempts to use StockEvents is giving a blank screen.
A working example is highly appreciated.
Thank you
SD
It's not on the example nor Rd file. Thanks.
Hi,
When I use the setExport feature to extract the data associated with an AmStockChart in an excel format or any other format, the file name is always "AmCharts". Can I configure the settings to change the filename?
Regards,
SD
I try to use rAmCharts with FlexDashboard from RStudio (http://rstudio.github.io/flexdashboard/using.html)
I played around with the layout and it seems to me that rAmCharts could not auto re-size the chart to fit the size of the dashboard.
Is there anything I could do to fix the issue?
Attachment is my Rmd (I have to put it in a docx since GitHub does not accept zip or rmd file extension)
Thank you in advance
Hi,
Apologies for opening another issue in such short duration.
I am unable to create Guidelines in a AmStockChart. I used the shiny example of an AmSerialChart with guidelines in it but could not reproduce it in AmStockChart. I played with both setGuides and addGuide functions but got error messages in both cases
addGuide(category = '2001', toCategory = '2003',
lineColor = '#CC0000', lineAlpha = 1, fillAlpha = 0.2,
fillColor = '#CC0000', dashLength = 2, inside = TRUE,
labelRotation = 90, label = 'fines for speeding increased')
Error: unable to find an inherited method for function ‘addGuide’ for signature ‘"AmStockChart", "missing"’
Thanks
Hi,
The theme patterns does not work in shinyserver (shinyapps.io).
Also was curious to see if there is a theme called "black" available. I could see js file inside the package but when I tried theme="black", I got an error so not sure
PS: I am using stockchart
I get the following new warning messages in v2.0.0
Warning in FUN(X[[i]], ...) :
You should use setter for property 'creditsPosition'
Warning in FUN(X[[i]], ...) :
You should use setter for property 'allLabels'
How to fix these?
Latest version of rAmCharts was installed from CRAN and now some of the features do not function anymore.
For example,
Hi,
I'm experimenting candlestick chart. When user hover over the chart to see detailed number, I'd like to limit the precision to be 0 digits, instead of 2.
Can this be done as a parameter for candlestick and possibly other charts?
Thanks.
rAmCharts
is wonderful, but now that it is official on CRAN, I am quite surprised that there is no attribution for AmCharts
in the DESCRIPTION, and no mention of commercial license options. At a minimum I would have expected based on CRAN policies, something like these lines from visNetwork or as another example taucharts. It seems well worth a link to the commercial license options http://www.amcharts.com/online-store/ in DESCRIPTION/DESCRIPTION.
I'm very sensitive to this since htmlwidgets
depend so much on the hard work of the JavaScript developers, and I try to err on the side of over-attribution and over-disclosure.
Thanks so much for your work on visNetwork
and rAmCharts
. They really are well designed.
My issue is related to the performance of RAmcharts
The example given here "https://www.amcharts.com/demos/stock-comparing-external-data/#theme-light" takes around 3 seconds to load and render the chart. The same chart when built in shiny takes ~6 seconds. Can you help me with some tips which will help me improve the performance or recreate the above chart with a load and render time of ~ 3 sec.
Greatly appreciate all your help so far
Regards,
SD
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.