Giter Site home page Giter Site logo

Comments (3)

bthieurmel avatar bthieurmel commented on July 16, 2024

Hi,
Can you first send us some code ?

from ramcharts.

debsush avatar debsush commented on July 16, 2024

I will give this a try.

Let us use some large data sets

http://ichart.yahoo.com/table.csv?s=GOOG&a=0&b=1&c=2000&d=0&e=31&f=2015&g=d&ignore=.csv

Now we try and plot a stockChart out of it.. Say it takes us 3-4 seconds to pull the data and extract the chart. Now if we parameterize the StockGraphType using a radio button. Now every time the radio button is changed, the entire plot is built from scratch once again because of the reactive nature of render function and hence takes ~3-4 seconds each time the radio button option is changed.

Now when you compare this with the below Javascript version of the example, ValiDateNow() is triggered which only changes the chart type instead of building the entire chart from scratch and hence boosts the performance.

JS Fiddle: http://jsfiddle.net/amcharts/32usT/

Shiny Code:

ui.R

shinyUI(fluidPage(

useShinyjs(),

fluidRow(
column(12,radioButtons("fcharttype4", label =NULL, choices = c("candlestick"="candlestick",
"ohlc"="ohlc",
"line" = "line"),
selected = "line",inline = TRUE, width = NULL)),
column(12,amChartsOutput("fspanel4a",height="100%"))
)
))

server.R

server = function(input, output, session) {

Prepare the Data - This is the data from the URL

datagoog<-fmydata4[,c("Date","Close","Volume")]
datagoog$Date = format(as.Date(datagoog$Date),"%Y-%m-%d")

Render the Chart

output$fspanel4a <- renderAmCharts({

K1<-pipeR::pipeline(
  amStockChart(startDuration = 0, 
               theme = "light"),
  addDataSet(dataSet(title = "Main", 
                     categoryField = "Date",
                     compared=TRUE,
                     dataProvider = data.table(datagoog)) %>>%
               addFieldMapping(fromField = "Close", 
                               toField = "Close") %>>%
               addFieldMapping(fromField = "Volume", 
                               toField = "Volume")),      
  addPanel(stockPanel(showCategoryAxis = FALSE, title = 'Price', percentHeight = 70) %>>%
             addStockGraph(id = 'g1', 
                           valueField = "Close", 
                           type=input$fcharttype4,
                           comparable = TRUE,
                           balloonText = '[[title]] =<b>[[value]]</b>',
                           compareGraphBalloonText = '[[title]] =<b>[[value]]</b>') %>>%
             setStockLegend(periodValueTextComparing = '[[percents.value.close]]%',
                            periodValueTextRegular = '[[value.close]]') %>>%
             addListener('zoomed', 'function(event) {alert("zoomed")}')),
  addPanel(stockPanel(title = 'Volume', 
                      percentHeight = 30) %>>%
             addStockGraph(valueField = "Volume", 
                           type = "column", 
                           fillAlphas = 1) %>>%
             setStockLegend(periodValueTextRegular = '[[value.close]]')),
  setChartScrollbarSettings(graph = 'g1'),
  setChartCursorSettings(valueBalloonsEnabled = TRUE, 
                         fullWidth = TRUE,
                         cursorAlpha = 0.1, 
                         valueLineBalloonEnabled = TRUE,
                         valueLineEnabled = TRUE, 
                         valueLineAlpha = 0.5),
  setPeriodSelector(periodSelector(position = 'left') %>>%
                      addPeriod(period = 'DD', selected = TRUE, count = 7, label = '1 week') %>>%
                      addPeriod(period = 'MAX', label = 'MAX') %>>%
                      addListener('changed', 'function(event) {alert("changed")}')),
  setDataSetSelector(dataSetSelector(position = 'left') %>>%
                       addListener('dataSetCompared', 'function(event) {alert("dataSetCompared")}')),
  setPanelsSettings(recalculateToPercents = FALSE)
)


})  

}

So the question is how can we intelligently change parameters within the AmStockChart without having to rebuild it every time

from ramcharts.

debsush avatar debsush commented on July 16, 2024

The latest version of amCharts renders at a very high speed so closing the issue

from ramcharts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.