danvk / danvk/dygraphs

second y-axis unexpectedly flipping (more negative toward the top of the graph)

Open
#653 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
3.2k
Forks
589
PR merge metrics
No merged PRs in 30d

Description

When graphing this data set that contains a spike, the y-axis inverts. If I switch the y axis with the y2 axis, it works as expected. If I graph a subset of the data that does not contain the spike, it works as expected (although that changes the "minimum" of the data, which changes the slider settings, which changes the axis settings, but only in magnitude; the min is always less than the max anyway, so scale shouldn't matter.)
good dychart
bad dychart
Here's some relevant code in case something jumps out that I'm doing wrong... I can include more code and the raw data set if nobody thinks this is already a known issue.

this is buggy:

output$DXGraph <- renderDygraph({
df1 <- DXDataSubset()
if (length(df1) > 1){
DXxts <- xts(df1,
order.by = as.POSIXlt(as.character(unlist(df1[, 'utc_datetime']))),
tz = "UTC")
dygraph(DXxts[,c('premium','mid.x')],
main = "Premium and Mid.x of DX data") %>%
dyAxis("y", label = "mid.x", valueRange = c(input$YAxisSlider[1],input$YAxisSlider[2])) %>%
dySeries('premium',axis = 'y2') %>%
dyOptions(connectSeparatedPoints = FALSE) %>%
dyOptions(animatedZooms = TRUE) %>%
dyRangeSelector()
}

this works:

output$DXGraph <- renderDygraph({
df1 <- DXDataSubset()
if (length(df1) > 1){
DXxts <- xts(df1,
order.by = as.POSIXlt(as.character(unlist(df1[, 'utc_datetime']))),
tz = "UTC")
dygraph(DXxts[,c('premium','mid.x')],
main = "Premium and Mid.x of DX data") %>%
dyAxis("y", label = "premium", valueRange = c(input$YAxisSlider[1],input$YAxisSlider[2])) %>% ###only change: changed premium <--> mid.x from the line below
dySeries('mid.x',axis = 'y2') %>%
dyOptions(connectSeparatedPoints = FALSE) %>%
dyOptions(animatedZooms = TRUE) %>%
dyRangeSelector()
}
})

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dyAxis valueRange and dySeries axis='y2' calls in the provided R example, then reproduce the second-axis inversion using data containing a spike. Compare the behavior with the axes swapped and with the spike removed; done means the second y-axis keeps the expected ordering in all cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.