Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heatmap breaks down for large numer of data #9

Closed
ziyadsaeed opened this issue Jan 14, 2016 · 4 comments
Closed

heatmap breaks down for large numer of data #9

ziyadsaeed opened this issue Jan 14, 2016 · 4 comments
Milestone

Comments

@ziyadsaeed
Copy link

The heatmap example in the documentation uses nyears = 5. Change that to 500 and heatmap just shrinks to the bottom of the chart
heatmap using highcharter

@jbkunst
Copy link
Owner

jbkunst commented Jan 14, 2016

Thanks. Let's see what's going on. If I have news I'll write you in this issue.

@jbkunst jbkunst added the bug label Jan 18, 2016
@jbkunst jbkunst added this to the v0.2.0 milestone Jan 18, 2016
@jbkunst
Copy link
Owner

jbkunst commented Jan 18, 2016

@ziyadsaeed

I found this option in highcharts:

turboThreshold: NumberSince 2.2
When a series contains a data array that is longer than this, only one dimensional arrays of numbers, or two dimensional arrays with x and y values are allowed. Also, only the first point is tested, and the rest are assumed to be the same format. This saves expensive data checking and indexing in long series. Set it to 0 disable. Defaults to 1000.

To change this parameter you need to override the default value.

hcopts <- getOption("highcharter.options")
hcopts <- rlist::list.merge(
  hcopts,
  list(chart = list(
    plotOptions = list(
      series = list(
        turboThreshold = 0
      )
    )
  ))
)
options(highcharter.options = hcopts)

Then run your code

nyears <- 500

df <- expand.grid(seq(12) - 1, seq(nyears) - 1)
df$value <- abs(seq(nrow(df)) + 10 * rnorm(nrow(df))) + 10
df$value <- round(df$value, 2)

head(df)
tail(df)

nrow(df) == nyears*12

ds <- setNames(list.parse2(df), NULL)
head(ds)
tail(ds)

highchart() %>% 
  hc_chart(type = "heatmap") %>% 
  hc_title(text = "Simulated values by years and months") %>% 
  hc_xAxis(categories = month.abb) %>% 
  hc_yAxis(categories = 2016 - nyears + seq(nyears),
           showFirstLabel = FALSE,
           showLastLabel = FALSE) %>% 
  hc_add_serie(name = "value", data = ds) %>% 
  hc_colorAxis( minColor = "#FFFFFF", maxColor = "#434348")

Finally, I'll disable this threshold parameter in the next versión of highcharter.

Regards,

@jbkunst jbkunst added enhancement and removed bug labels Jan 18, 2016
@ziyadsaeed
Copy link
Author

Still has some display issues
image 1

@jbkunst
Copy link
Owner

jbkunst commented Jan 25, 2016

This are highcharts issues. The line at the top is a gridline. So add gridLineWidth = 0 in hc_yAxis options to remove that line. The first label dont show due the showFirstLabel option.

nyears <- 500

df <- expand.grid(seq(12) - 1, seq(nyears) - 1)
df$value <- abs(seq(nrow(df)) + 2000 * rnorm(nrow(df))) + 10
df$value <- round(df$value, 2)

head(df)
tail(df)

nrow(df) == nyears*12

ds <- setNames(list.parse2(df), NULL)
head(ds)
tail(ds)


fntltp <- JS("function(){
                  return this.series.xAxis.categories[this.point.x] + '<br>' +
             this.series.yAxis.categories[this.point.y] + '<br>' +
             Highcharts.numberFormat(this.point.value, 2);
             ; }")

highchart() %>% 
  hc_chart(type = "heatmap", zoomType = "xy") %>% 
  hc_title(text = "Simulated values by years and months") %>% 
  hc_xAxis(categories = month.abb) %>% 
  hc_yAxis(categories = 2016 - nyears + seq(nyears),
           gridLineWidth = 0,
           showFirstLabel = TRUE,
           showLastLabel = FALSE) %>% 
  hc_add_serie(name = "value", data = ds) %>% 
  hc_tooltip(formatter = fntltp) %>% 
  hc_colorAxis(minColor = "#434348", maxColor = "#000000")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants