Coder Social home page Coder Social logo

leaflet.minicharts's People

Contributors

bthieurmel avatar dependabot[bot] avatar francoisguillem avatar jalazawa avatar julienbretteville avatar mayeulk avatar pvictor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet.minicharts's Issues

Add directed segments

Draw segments with an arrow that indicates the direction of a flow. Useful to represent exchanges between areas

Default color palette has a typo

I generated a reprex below, but essentially the # is missing from one of the hex colors in the palette d3.schemeCategory10. This means that it shows up as blank in legends but black in the charts. This bug only appears when there are >6 categories shown, which is rare I'm sure. Using version 0.6.2 from CRAN today.

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(leaflet)
library(leaflet.minicharts)

# Notice the missing "#..." on color 7?
print(d3.schemeCategory10)
#>  [1] "#1f77b4" "#ff7f0e" "#2ca02c" "#d62728" "#9467bd" "#8c564b" "e377c2" 
#>  [8] "#7f7f7f" "#bcbd22" "#17becf"

# This throws an error because of it
scales::show_col(d3.schemeCategory10)
#> Error in rect(col(colours) - 1, -row(colours) + 1, col(colours), -row(colours), : invalid color name 'e377c2'

# Here's a sample dataset to demonstrate
x <- tibble(
  latitude = 38:40, 
  longitude = -77:-79
) %>% 
  mutate(
    a = runif(3),
    b = runif(3),
    c = runif(3),
    d = runif(3),
    e = runif(3),
    f = runif(3),
    g = runif(3)
  )

leaflet() %>% 
  addTiles() %>% 
  addMinicharts(
    x$longitude, x$latitude,
    type = "pie", 
    chartdata = x %>% select(a:g)
  )

Created on 2022-03-31 by the reprex package (v2.0.1)

legend not adding up to the map

Hello - thank you for creating the wonderful package. I am facing the issue of legend not appearing on the map

this is my code

income_3<- get_acs(geography = "tract", year = 2019, state = "17", 
                                    county = "031", table = "B19001", geometry = T, output = "wide" )

income_all <- st_transform(income_3,4326)

#getting centroids
centroid_income <- setDT(st_centroid(income_all))

pie_income <-  centroid_income %>% 
  separate( col = geometry,into = c("long","lat"), sep = ",") %>%
  mutate(long = gsub(long, pattern = "c\\(", replacement = ""),
          lat = gsub(lat, pattern = "\\)", replacement = ""))

colors_pie <- viridis_pal(alpha = 1, begin = 0, end = 1, direction = 1, 
                          option = "D")

 leaflet() %>% 
  addProviderTiles(providers$CartoDB , 
                   options = providerTileOptions(minZoom = 12)) %>%
  setView(zoom = 12, 
          lng = pie_income$long[150], 
          lat = pie_income$lat[150]) %>%
  addPolygons(data = income_all, weight = 1, fillOpacity = 0, 
              color = "black", group = "tract") %>%
   addScaleBar(position = "bottomright") %>% 
  addMinicharts( lng = pie_income$long,
                 lat = pie_income$lat,
                 width = sqrt(pie_income$Total)/2 ,
    type = "pie", colorPalette = colors_pie(10), transitionTime = 0,
    chartdata = pie_income[ , 10:19] , layerId = pie_income$GEOID, 
    legend = T) 
  
   

Map :

Rplot

when I add a layerID in an incorrect manner the legend shows up but minicharts disappear :

Rplot01

Popup show when mouseover

Hello,

Is it possible to show the popup as mouseover instead of click in the addminicharts (pie chart)?

Visualize the evolution of variables without shiny

One the R side, this could be done by adding a parameter "time". For instance:

leaflet() %>% addTiles() %>%
  addMinicharts(0, 0, data = rnorm(3), time = 1:3)

This would on the map a slider input with a play/pause button.

event Handler missing on flow and minicharts object.

The flow and minicharts object should be at the same level shape or marker in leaflet, therefore, each individual object should be able to assign an layerID instead of the whole layer is just one big object with one ID. I hope this feedback is somehow useful. I'm working on this change, do let me know if you guys want a copy of it. Keep up the great work. The package looks good.

New types of graphs?

I really like your package!

I propose some additional types of graphs. May be you'll like some of them.

  • donuts
  • proportional bar (with the 100% height)
  • Venn diagram

Popup titles other than LayerID?

One feature that I think is missing (or maybe it's not and I just haven't found it documented), is a way to give each popup a unique title beyond the layer name.

In my use case, I might have a choropleth with bar charts and I would like the popup to show the bar chart data for each region along with the name of the region as the title, for example:

Spain
x: 1234
y: 6478

and

France
x: 73907
y: 90682

I got around this with a hacky function I wrote in R and passed to the html parameter of popupArgs() which more or less accomplishes what setPopup() does with the addition of allowing a character vector of titles for each set of values:

popup_gen <- function(title, keys, values) {
  stopifnot(length(title) == dim(values)[1L])

  out <- vector("character", length = dim(values)[1L])

  for (i in seq_along(out)) {
    out[i] <- paste(
      "<div class='popup'>",
      sprintf("<h2>%s</h2>", title[i]),
      "<table><tbody>",
      paste(sprintf(
        "<tr><td class='key'>%s</td><td class='value'>%i</td></tr>",
        keys, values[i, keys]), collapse = ""),
      "</tbody></table>",
      "</div>",
      sep = ""
      )
  }

  return(out)
}

I'm not sure if this is a feature others would like, but it seems like it would be easy to implement in JS (or R as I have done). Happy to help out with a PR if you'd like.

Add minicharts to group layers

Hi,
Thank you for this package, it's extremely useful!

Is it possible/difficult to add to addMinicharts() the ability to add the minicharts to group layers, such as:

leaflet::addCircleMarkers(map, lng = NULL, lat = NULL, radius = 10,
  layerId = NULL, group = "group_name")

So that the charts may be turned on/off via:

addLayersControl(
    overlayGroups = c("group_name"))

Clustered Pie Charts

Hi Minicharts,

I'm redirecting a leaflet issue (rstudio/leaflet#370) to this package as leaflet.minicharts solves displaying a piechart in a leaflet map.

It has been requested to have a piechart for clustered points, similar to clustered markers.

Would this repo be the right repo to submit this to?

Thank you for your time,
Barret

minichart non-reactive (time)

Hi
great package!
I followed your tutorials:
https://cran.r-project.org/web/packages/leaflet.minicharts/vignettes/introduction.html
and here
https://francoisguillem.shinyapps.io/shiny-demo/

with my data, it works just fine with this code:

leaf_map2 %>%
        addMinicharts(
                coordinates_list_all$Longitude, coordinates_list_all$Latitude,
                type = "pie",
                chartdata = coordinates_list_all[, c("VOC50", "VOC90")],
                # colorPalette = colors,
                width = 60 * sqrt(coordinates_list_all$total_cases) / sqrt(max(coordinates_list_all$total_cases)), 
                time = coordinates_list_all$date,
        )
 

but when I try to use within shiny app, the minichart are not updating (the panel looks fine)

 
server = function(input, output, session) {
        # Initialize map
        #
        
        output$map <- renderLeaflet({
                leaf_map2%>% leaflet::addTiles(tilesURL)%>%
                        addMinicharts(
                                coordinates_list_all$Longitude, coordinates_list_all$Latitude,
                                layerId = coordinates_list_all$location,
                                width = 45, height = 45,
                        )
        })
       
        # Update charts each time input value changes
        observe({
                if (length(input$prods) == 0) {
                        data <- 1
                } else {
                        data <- coordinates_list_all[, input$prods]
                }
                maxValue <- max(as.matrix(data))
               
                leafletProxy("map", session) %>%
                        updateMinicharts(
                                coordinates_list_all$location,
                                chartdata = data,
                                maxValues = maxValue,
                                time = coordinates_list_all$date,
                                type = ifelse(length(input$prods) < 2, "polar-area", input$type),
                                showLabels = input$labels
                        )
        })
}
 
ui <- fluidPage(
        titlePanel("COVID-19 Clinical data"),
        p("This application uses the data xxxx COVID-19.",
          "It contains the quarterly data on total cases, VOC 50%, VOC 75% and  VOC 90% from 2020 to 2023."),
       
        sidebarLayout(
               
                sidebarPanel(
                        selectInput("prods", "Select data", choices = dataCols, multiple = TRUE),
                        selectInput("type", "Chart type", choices = c("bar","pie", "polar-area", "polar-radius")),
                        checkboxInput("labels", "Show values")
                ),
               
                mainPanel(
                        leafletOutput("map")
                )
               
        )
)
shinyApp(ui, server)

my data look like that (for now I included same value for the different VOC but won’t be the case after) with prods being total_cases, VOC50, VOC75 and VOC90. the problem seems to be around the time component (nothing change when I click on 'play')

did I miss something here?

Screen Shot 2023-05-03 at 8 16 02 AM

thank you for your help!

Minicharts without R

Hi,

Is it possible to use this plugin without R?

I"d like to create minicharts on top of a normal map included in a webpage not running R.

Thanks and best regards

Need offset for overlaying edges

Hello,

is it possible to integrate the option to use offsets for overlaying edges?

In addPolylines() there is the parameter options and this parameter can be used as: options = list(offset = ~offset).

Can you include this in addFlows()? The rest works perfect, thank you very much.

Display charts only at certain levels of zoom

Depending on the level of zoom, user could display more or less charts. For instance at a low level of zoom, there would a unique chart for all european countries. By zooming in this chart would disappear and country charts would be displayed

synchronize maps

Be able to synchronize center, zoom and time of multiple maps.

Legend beyond the interface and how to add size legend

Dear All
Thanks for your wonderful tool, I use it to show my data, while the legend is quite long out of my interface, show as below:
图片

If you have a parameter to show the legend in two columns, that will be better, I think.
And I cannot find the legend for the size of the dots, can I know how to show my size legend as well.
Thankyou
Xuexue

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.