From df905fd349b6b49b36d5dfd2f4d7b0dc82061175 Mon Sep 17 00:00:00 2001 From: AcuGIS Date: Sat, 31 Aug 2024 22:59:57 +0000 Subject: [PATCH] Update docs/source/r.rst --- docs/source/r.rst | 53 ++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/docs/source/r.rst b/docs/source/r.rst index 707bff7..7c09cb4 100644 --- a/docs/source/r.rst +++ b/docs/source/r.rst @@ -151,7 +151,7 @@ Give your R code a Name and Description. Example -------------- -The three main components are the plotly, ggplot2, and htmlwidgets function +The three main components are the plotly, ggplot2, and htmlwidgets function. .. code-block:: R @@ -165,51 +165,52 @@ The three main components are the plotly, ggplot2, and htmlwidgets function #saveWidget htmlwidgets::saveWidget(as_widget(p), file="index.html") -An example of a Plotly app is included in the installation. + +An example of a Plotly app is included in the installation. Here, we add the RPostgreSQL library to connect to PostgreSQL. .. code-block:: R library(plotly) library(ggplot2) + library(RPostgreSQL) library(htmlwidgets) - set.seed(100) - d <- diamonds[sample(nrow(diamonds), 1000), ] - p <- plot_ly(d, x=~carat, y=~price, text=~paste("Clarity: ", clarity), mode="markers", color=~carat, size=~carat) + conn <- RPostgreSQL::dbConnect("PostgreSQL", host = "localhost", dbname = "r_examples", user = "admin1", password = "4eA7hDlgYF") + + query_res <- dbGetQuery(conn, 'SELECT * FROM "sensor_readings";'); + sensor_readings <- as.data.frame(query_res); + # sensor_readings$timestamp <- as.Date(sensor_readings$timestamp) + + p <- plot_ly(sensor_readings, x=~timestamp, y=~humidity, text=~paste("Sensor: ", sensor_name), mode="markers", color=~humidity, size=~humidity) %>% + layout( + plot_bgcolor='#e5ecf6', + xaxis = list( matches='x', + zerolinecolor = '#ffff', + zerolinewidth = 2, + gridcolor = 'ffff', + range = list( min(sensor_readings$timestamp), + max(sensor_readings$timestamp)) + ), + yaxis = list( + zerolinecolor = '#ffff', + zerolinewidth = 2, + gridcolor = 'ffff') + ) + htmlwidgets::saveWidget(as_widget(p), file="index.html") There are three options for creating a Map. -Option 1: FTP. ------------- - -FTP Uploads are qgis2web maps you have uploaded directly via FTP. - -It can also maps you uploaded via any FTP client. - - .. image:: images/Map-2.png -Option 2: Archive (Upload) ------------- - -Archive is a zipped archive file you can upload. + - .. image:: images/Map-3.png -Option 3: Paste ------------- - -Paste your R Leaflet code into the code box. - - - .. image:: images/Map-3.png - Name