jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
720 stars 148 forks source link

Highcharter doesn't play nice in xaringan's moon reader #422

Closed charliejhadley closed 2 years ago

charliejhadley commented 6 years ago

@yihui's awesome infinite moon reader addin for RStudio (https://github.com/yihui/xaringan) doesn't play nice with highcharter

  1. Install moon reader addin install.packages("xaringan")
  2. Create the following test.Rmd file:
---
title: "Untitled"
output: html_document
---

## R Markdown

```{r}
library("highcharter")
my_hc <- iris %>%
  hchart(
    type = "scatter",
    hcaes(
      x = Petal.Width,
      y = Petal.Length
    )
  )
my_hc
  1. Select 'Infinite Moon Reader' from RStudio's Addins menu

  2. Navigate to the "Viewer" panel in RStudio.

The document now shows this error:

' + this.getTable(true) + '', base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))); // #50 }; getContent( this, uri + base64(template), 'xls', template, 'application/vnd.ms-excel' ); }; /** * View the data in a table below the chart */ Highcharts.Chart.prototype.viewData = function () { if (!this.insertedTable) { var div = document.createElement('div'); div.className = 'highcharts-data-table'; // Insert after the chart container this.renderTo.parentNode.insertBefore(div, this.renderTo.nextSibling); div.innerHTML = this.getTable(); this.insertedTable = true; } }; // Add "Download CSV" to the exporting menu. Use download attribute if supported, else // run a simple PHP script that returns a file. The source code for the PHP script can be viewed at // https://raw.github.com/highslide-software/highcharts.com/master/studies/csv-export/csv.php if (Highcharts.getOptions().exporting) { Highcharts.getOptions().exporting.buttons.contextButton.menuItems.push({ textKey: 'downloadCSV', onclick: function () { this.downloadCSV(); } }, { textKey: 'downloadXLS', onclick: function () { this.downloadXLS(); } }, { textKey: 'viewData', onclick: function () { this.viewData(); } }); } // Series specific if (seriesTypes.map) { seriesTypes.map.prototype.exportKey = 'name'; } if (seriesTypes.mapbubble) { seriesTypes.mapbubble.prototype.exportKey = 'name'; } });

This is not fixed by downgrading to xaringan version 0.5.

aniruhil commented 6 years ago

Here is some other odd behavior: The points highlighted tend to be edge points rather than the point the cursor is hovering over, in RStudio's viewer as well as in Chrome/Safari.

---
title: "hchart"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---

```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
library(highcharter)
library(caret)
data(Sacramento)
hc1 <- hchart(Sacramento, "scatter", hcaes(x = sqft, y = price, 
    group = city))
hc_size(hc1, 900, 450)
aniruhil commented 6 years ago

This seems to be a known issue with plotly as well. The fix (thanks to @tbrambor) is to wrap it within a frameWidget()

library(highcharter)
hc1 <- hchart(Sacramento, "scatter", 
   hcaes(x = sqft, y = price, group = city))
library(widgetframe)
frameWidget(hc1)
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.

Andina20 commented 3 years ago

I've had my xaringan upgraded too. But then it can't load the tidyverse and RefManager package. Can anybody help?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.