Git Product home page Git Product logo

Comments (1)

jbkunst avatar jbkunst commented on May 22, 2024

Hi @royfrancis !

This package is a really straight forward wrapper for highcharts. So we need to construct the data as highcharts need. So it is really useful if you study the api via examples. In particular lets see http://www.highcharts.com/demo/bubble, and click View options then look how is the data and you'll see:

   series: [{
            data: [
                { x: 95, y: 95, z: 13.8, name: 'BE', country: 'Belgium' },
                { x: 86.5, y: 102.9, z: 14.7, name: 'DE', country: 'Germany' },
                ....

To add this type of data to highcarts via highcarter we need to parse the data frame using list.parse (basically put a dataframe in a list form) function from rlist package (I change the z name colum because if the type of chart is bubble this value will be used to get the bubble's size:

So internally we'll have something like:

   series: [{
            data: [
                { x: 4, y: 2, text: 'A'},
                { x: 5, y: 4, text: 'A'},
                ....

Well TLDR. Here's the code.

library("highcharter")
library("rlist")


df <- data.frame(
  x=c(4,5,6,3),
  y=c(2,4,3,2),
  text=c("A","A","A","B"), stringsAsFactors = FALSE)

# ds: data series
ds <- list.parse(df)
names(ds) <- NULL

head(ds)


highchart() %>% 
  hc_add_serie(data = ds, name = "data.frame data",
               type = "scatter") %>% 
  hc_tooltip(headerFormat = "<b>This is a custom tooltip</b><br>",
             pointFormat = "x: {point.x} <br> y: {point.y} <br> text: {point.text}")

from highcharter.

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.