Skip to content

DashR Oil and Gas Ternary#245

Merged
rpkyle merged 15 commits intomasterfrom
dashr-oil-and-gas-ternary
Aug 22, 2019
Merged

DashR Oil and Gas Ternary#245
rpkyle merged 15 commits intomasterfrom
dashr-oil-and-gas-ternary

Conversation

@KPhans
Copy link
Copy Markdown
Contributor

@KPhans KPhans commented Jul 25, 2019

Issue for app: #[issue number here]

App pull request

  • This is a new app
  • I am improving an existing app (redesigns/code "makeovers")

About

  • Playground deployment URL (new version):
  • Current gallery app URL: (delete this line if inapplicable)
  • Python app repository link: (delete this line if you are working on a Python app)

Workflow

  • I have created a branch in the appropriate monorepo, and the
    elements necessary for successful deployment are in place.
  • If the app is a redesigned and/or restyled version of an
    existing gallery app, I've summarized the changes requested in the
    appropriate Streambed issue and confirm that they have been applied.
  • If the app is on the Dash Gallery portal, I have added a link to
    the GitHub repository for the source code in the portal description.
  • If the app is a reimplementation of a Python gallery app for the
    DashR gallery, the app in this PR mimics, as closely as possible,
    the style and functionality of the existing app.=
  • I have removed all Google Analytics code from the app's
    assets/ folder.

The pre-review review

I have addressed all of the following questions:

  • Does everything in my code serve some purpose? (I have removed
    any dead and/or irrelevant code.)
  • Does everything in my code have a clear purpose? (My code is
    readable and, where it isn't, it has been commented appropriately.)]
  • Am I reinventing the wheel? (I have used appropriate packages to
    lessen the volume of code that needs to be maintained.)

@KPhans KPhans requested a review from rpkyle July 25, 2019 18:49
@KPhans
Copy link
Copy Markdown
Contributor Author

KPhans commented Jul 25, 2019

@rpkyle PR for Ternary app to be merged into master!

@rpkyle rpkyle changed the title Dashr oil and gas ternary DashR Oil and Gas Ternary Jul 30, 2019
@rpkyle rpkyle added the dash-r Dash R applications label Jul 30, 2019
Copy link
Copy Markdown
Contributor

@rpkyle rpkyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app looks great, and is very responsive, which is fantastic. Awesome work!

Just a few comments to address before moving ahead. One thing that we should sort out is the clipping for the ternary axis label on the left side. Compare the R version:

Screenshot 2019-07-30 15 23 19

with the Python version:

Screenshot 2019-07-30 15 31 59

There's a bit more space between the figures in the Python version -- it looks like the "Carbonate" label is being clipped -- i.e. the first letter looks slightly chopped off.

Not sure, but this might be a CSS issue?


```
git clone https://github.com/plotly/dash-sample-apps.git
Run app.R in R Studio
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either make this statement a valid command or remove it from the monospaced code block (to avoid confusion for new users).

@@ -0,0 +1,50 @@
## dashr-oil-gas-ternary

`dash-oil-gas-ternary` creates a dashboard for mineral composition evaluations from natural gas wells.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dashr-oil-gas-ternary

git clone https://github.com/plotly/dash-sample-apps.git
Run app.R in R Studio
```
In UNIX system:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd 🔪 lines 19-37, these are Python-related.

Comment thread apps/dashr-oil-and-gas-ternary/app.R Outdated
df = read.csv("data/test_compositionR.csv")
df_prod = read.csv("data/YearlyProduction_table_1.csv")

colormap = list()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could replace lines 28-33 with the following:

colormap <- setNames(colors[1:length(unique(df$fm_name))], unique(df$fm_name))

Comment thread apps/dashr-oil-and-gas-ternary/app.R Outdated
),
showlegend=TRUE
)
data = list.append(data,new_trace)
Copy link
Copy Markdown
Contributor

@rpkyle rpkyle Jul 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should rename the data object here, because data is an exported function from the namespace of the utils package in R.

Now, as for list.append ... ahem 🙂

Not a criticism of your code at all, but I find this to be a very silly function. Given x <- list(a=1,b=2,c=3):

> list.append(x,d=4,e=5)
$a
[1] 1

$b
[1] 2

$c
[1] 3

$d
[1] 4

$e
[1] 5

compare ☝️ with

> c(x, d=4, e=5)
$a
[1] 1

$b
[1] 2

$c
[1] 3

$d
[1] 4

$e
[1] 5

😄

Comment thread apps/dashr-oil-and-gas-ternary/app.R Outdated
input("operator-select", "value")),
function(map_selected_data, tern_selected_data, op_select){
dff = df[df$op %in% op_select,]
#browser()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔪 #browser()

Comment thread apps/dashr-oil-and-gas-ternary/app.R Outdated
state("ternary-map", "figure")),
function(map_selected_data, bar_selected_data, bar_click_data, op_select,
layer_select, curr_fig){
#browser()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💣 #browser()

Comment thread apps/dashr-oil-and-gas-ternary/app.R Outdated
input("operator-select", "value"),
input("mapbox-view-selector", "value")),
function(tern_selected_data, bar_selected_data, bar_click_data, op_select, mapbox_view){
#browser()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#browser() 🔫

Comment thread apps/dashr-oil-and-gas-ternary/app.R Outdated
input("form-by-bar", "selectedData"),
input("operator-select", "value")),
function(map_select, tern_select, bar_select, op_select){
#browser()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥 ☠️ ⚛️ #browser()

Comment thread apps/dashr-oil-and-gas-ternary/app.R Outdated
if(length(tern_select) > 0){
processed_data = list('well_id' = list(), 'formation' = list())
for (point in tern_select[['points']]) {
#if('customdata' %in% point){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔪 commented out line

@KPhans
Copy link
Copy Markdown
Contributor Author

KPhans commented Jul 31, 2019

@rpkyle i believe everything is corrected. As per the css issue, i did not notice it when i ran it on my system.

@rpkyle rpkyle requested review from HammadTheOne and rpkyle August 8, 2019 20:08
rpkyle
rpkyle previously approved these changes Aug 8, 2019
Copy link
Copy Markdown
Contributor

@rpkyle rpkyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, just had another look at this app, I believe it's ready to go. Awesome work, definitely nice to see callback_context in action here.

Just need to resolve merge conflicts and then I think you're OK to 💃

df_fm <- df_fm[-c(1),]

formation_name <- list()
i <- 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this interesting, looping using an index counter, I see that a lot in Python but not in R. It works fine, and I think it's more of a stylistic choice, personally I would iteratively loop through the range of elements in R, but I think it's your call how you do it. 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now, will stick with an index counter as it seems to work. definitely will use range or seq later on

HammadTheOne
HammadTheOne previously approved these changes Aug 9, 2019
Copy link
Copy Markdown
Contributor

@HammadTheOne HammadTheOne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Kevin, the app code looks pretty solid, and it runs great as Ryan mentioned. The only issue I found was that if I select the "satellite-street" view on the 'Well Map', it seems to break Mapbox and sends a few errors in the browser console and I can no longer return to the other views. Aside from that error, seems like 💃 to me.

@KPhans
Copy link
Copy Markdown
Contributor Author

KPhans commented Aug 9, 2019

@HammadTheOne hmm that is very weird indeed. Ill look into that later today. If all the other options work properly and this one doesn't, then it may not be a problem with the code

@KPhans KPhans dismissed stale reviews from HammadTheOne and rpkyle via 5c5a026 August 13, 2019 02:41
@KPhans
Copy link
Copy Markdown
Contributor Author

KPhans commented Aug 13, 2019

@rpkyle @HammadTheOne Fixed the satellite street view. Was a silly filtering where the : was changed to a = in "mapbox://styles/mapbox/satellite-streets-v9". Since R doesn't utilize colons for equate values. Conflicts have been resolved.

@rpkyle rpkyle self-requested a review August 22, 2019 13:10
Copy link
Copy Markdown
Contributor

@rpkyle rpkyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃 LGTM!

@rpkyle rpkyle merged commit cf67f4e into master Aug 22, 2019
@rpkyle rpkyle deleted the dashr-oil-and-gas-ternary branch August 22, 2019 13:11
@rpkyle rpkyle restored the dashr-oil-and-gas-ternary branch August 22, 2019 13:17
@rpkyle rpkyle deleted the dashr-oil-and-gas-ternary branch August 22, 2019 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dash-r Dash R applications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants