Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.93 KB | None | 0 0
  1. let view (model:Model) dispatch =
  2.  
  3.   div []
  4.       [ input [ unbox ("type", "file")
  5.                 unbox ("name", "files")
  6.                 OnChange (fun f -> (* Fable.Import.Browser.console.log f.target?files *)
  7.                                    let reader = Fable.Import.Browser.FileReader.Create()
  8.                                    reader?onload <- (fun e ->  dispatch (OpenFile e?target?result;) )
  9.                                    reader.readAsText (f.target?files?item 0.)
  10.                          )
  11.               ]
  12.         div [] [ str (string (List.length model.taggedExpenses) + ( string model.status ) ) ]
  13.         model.tags |> List.map (fun t -> option [] [str t] ) |> select [ ]
  14.         model.notes |> List.map (fun t -> option [] [str t] ) |> select [ ]
  15.         div [ unbox ("id","mychart") ] []
  16.  
  17. // Adding this match causes an error about the first input above (in addition of other similar errors):
  18. // The result of this expression has type 'Fable.Import.React.ReactElement' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.
  19.         match model.displayCharts with
  20.         | true ->
  21.  
  22.                   let notesExpenses = model.taggedExpenses
  23.                                         |> List.groupBy (fun e -> e.Note)
  24.                                         |> Expenses.computeExpensesSummaries
  25.  
  26.  
  27.  
  28.                   (* retain only notes with required minimal occurences*)
  29.                   let notesDisplayed = notesExpenses
  30.                                      |> List.filter (fun (_, {Count = count; }) -> count >= 3)
  31.                                      |> List.sortBy (fun (_, {Total = v;}) -> -v)
  32.                   let barChart = Expenses.expensesGroupBarGraph notesDisplayed
  33.  
  34.  
  35.                  
  36.                   R.mountById "mychart" <| barChart()
  37.         |false -> div [] []
  38.  
  39.       ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement